@kozojs/cli 0.1.18 → 0.1.20

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.
Files changed (2) hide show
  1. package/lib/index.js +9 -9
  2. 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
- const { port } = await app.nativeListen(PORT);
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,14 @@ ${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
- // Protect resource routes with JWT (auth login route remains public)
1499
+ // JWT protects all /api/* routes except public ones
1503
1500
  const JWT_SECRET = process.env.JWT_SECRET || 'change-me';
1504
- app.use('*', authenticateJWT(JWT_SECRET, { prefix: '/api/users' }));
1505
- app.use('*', authenticateJWT(JWT_SECRET, { prefix: '/api/posts' }));
1506
- app.use('*', authenticateJWT(JWT_SECRET, { prefix: '/api/tasks' }));
1501
+ const _jwt = authenticateJWT(JWT_SECRET, { prefix: '' });
1502
+ const publicPaths = ['/api/auth/', '/api/health', '/api/stats'];
1503
+ app.getApp().use('/api/*', (c, next) => {
1504
+ if (publicPaths.some(p => c.req.path.startsWith(p))) return next();
1505
+ return _jwt(c, next);
1506
+ });
1507
1507
  ` : "";
1508
1508
  await import_fs_extra.default.writeFile(import_node_path.default.join(apiDir, "src", "index.ts"), `import 'dotenv/config';
1509
1509
  import { createKozo } from '@kozojs/core';
@@ -1517,7 +1517,7 @@ export type AppType = typeof app;
1517
1517
 
1518
1518
  console.log('\u{1F525} ${projectName} API starting on http://localhost:3000');
1519
1519
  console.log('\u{1F4DA} Endpoints: /api/health, /api/users, /api/posts, /api/tasks, /api/stats');
1520
- await app.nativeListen();
1520
+ await app.listen();
1521
1521
  `);
1522
1522
  await import_fs_extra.default.writeFile(import_node_path.default.join(apiDir, "src", "data", "index.ts"), `import { z } from 'zod';
1523
1523
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kozojs/cli",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "CLI to scaffold new Kozo Framework projects - The next-gen TypeScript Backend Framework",
5
5
  "bin": {
6
6
  "create-kozo": "./lib/index.js",