feat: auth & admin

This commit is contained in:
2026-06-03 10:41:53 +03:00
parent 612d0f0125
commit 7dc59fb3c4
120 changed files with 4683 additions and 2159 deletions
@@ -97,35 +97,31 @@ export async function GET(request: Request) {
**Incorrect (reads config on every call):**
```typescript
import fs from 'node:fs/promises'
import fs from 'node:fs/promises';
export async function processRequest(data: Data) {
const config = JSON.parse(
await fs.readFile('./config.json', 'utf-8')
)
const template = await fs.readFile('./template.html', 'utf-8')
const config = JSON.parse(await fs.readFile('./config.json', 'utf-8'));
const template = await fs.readFile('./template.html', 'utf-8');
return render(template, data, config)
return render(template, data, config);
}
```
**Correct (hoists config and template to module level):**
```typescript
import fs from 'node:fs/promises'
import fs from 'node:fs/promises';
const configPromise = fs
.readFile('./config.json', 'utf-8')
.then(JSON.parse)
const templatePromise = fs.readFile('./template.html', 'utf-8')
const configPromise = fs.readFile('./config.json', 'utf-8').then(JSON.parse);
const templatePromise = fs.readFile('./template.html', 'utf-8');
export async function processRequest(data: Data) {
const [config, template] = await Promise.all([
configPromise,
templatePromise,
])
]);
return render(template, data, config)
return render(template, data, config);
}
```