@kozojs/cli 0.1.18 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +8 -9
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -574,12 +574,9 @@ process.on('SIGINT', () => shutdown.shutdown());
|
|
|
574
574
|
// \u2500\u2500\u2500 Start \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
575
575
|
console.log('');
|
|
576
576
|
console.log('\u{1F525} Kozo server starting\u2026');
|
|
577
|
-
console.log('\u26A1 Powered by uWebSockets.js (native per-route C++ matching)');
|
|
578
577
|
console.log('');
|
|
579
578
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
console.log(\`\u{1F680} Listening on http://localhost:\${port}\`);
|
|
579
|
+
await app.listen(PORT);
|
|
583
580
|
console.log('');
|
|
584
581
|
console.log('\u{1F4DA} Endpoints:');
|
|
585
582
|
console.log(' GET /health Health check');
|
|
@@ -1499,11 +1496,13 @@ ${auth ? "JWT_SECRET=change-me-to-a-random-secret-at-least-32-chars\n" : ""}`;
|
|
|
1499
1496
|
` : "";
|
|
1500
1497
|
const servicesSetup = "\nconst services = {};\n";
|
|
1501
1498
|
const authMiddleware = auth ? `
|
|
1502
|
-
//
|
|
1499
|
+
// JWT protects all /api/* routes except /api/auth/*
|
|
1503
1500
|
const JWT_SECRET = process.env.JWT_SECRET || 'change-me';
|
|
1504
|
-
|
|
1505
|
-
app.use('
|
|
1506
|
-
|
|
1501
|
+
const _jwt = authenticateJWT(JWT_SECRET, { prefix: '' });
|
|
1502
|
+
app.getApp().use('/api/*', (c, next) => {
|
|
1503
|
+
if (c.req.path.startsWith('/api/auth/')) return next();
|
|
1504
|
+
return _jwt(c, next);
|
|
1505
|
+
});
|
|
1507
1506
|
` : "";
|
|
1508
1507
|
await import_fs_extra.default.writeFile(import_node_path.default.join(apiDir, "src", "index.ts"), `import 'dotenv/config';
|
|
1509
1508
|
import { createKozo } from '@kozojs/core';
|
|
@@ -1517,7 +1516,7 @@ export type AppType = typeof app;
|
|
|
1517
1516
|
|
|
1518
1517
|
console.log('\u{1F525} ${projectName} API starting on http://localhost:3000');
|
|
1519
1518
|
console.log('\u{1F4DA} Endpoints: /api/health, /api/users, /api/posts, /api/tasks, /api/stats');
|
|
1520
|
-
await app.
|
|
1519
|
+
await app.listen();
|
|
1521
1520
|
`);
|
|
1522
1521
|
await import_fs_extra.default.writeFile(import_node_path.default.join(apiDir, "src", "data", "index.ts"), `import { z } from 'zod';
|
|
1523
1522
|
|