@kozojs/cli 0.1.17 → 0.1.18
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 +2 -7
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1495,14 +1495,9 @@ ${auth ? "JWT_SECRET=change-me-to-a-random-secret-at-least-32-chars\n" : ""}`;
|
|
|
1495
1495
|
exclude: ["node_modules", "dist"]
|
|
1496
1496
|
};
|
|
1497
1497
|
await import_fs_extra.default.writeJSON(import_node_path.default.join(apiDir, "tsconfig.json"), tsconfig, { spaces: 2 });
|
|
1498
|
-
const dbImport = hasDb ? `import { createDb } from './db/index.js';
|
|
1499
|
-
` : "";
|
|
1500
1498
|
const authImport = auth ? `import { authenticateJWT } from '@kozojs/auth';
|
|
1501
1499
|
` : "";
|
|
1502
|
-
const servicesSetup =
|
|
1503
|
-
const db = await createDb();
|
|
1504
|
-
const services = { db };
|
|
1505
|
-
` : "\nconst services = {};\n";
|
|
1500
|
+
const servicesSetup = "\nconst services = {};\n";
|
|
1506
1501
|
const authMiddleware = auth ? `
|
|
1507
1502
|
// Protect resource routes with JWT (auth login route remains public)
|
|
1508
1503
|
const JWT_SECRET = process.env.JWT_SECRET || 'change-me';
|
|
@@ -1512,7 +1507,7 @@ app.use('*', authenticateJWT(JWT_SECRET, { prefix: '/api/tasks' }));
|
|
|
1512
1507
|
` : "";
|
|
1513
1508
|
await import_fs_extra.default.writeFile(import_node_path.default.join(apiDir, "src", "index.ts"), `import 'dotenv/config';
|
|
1514
1509
|
import { createKozo } from '@kozojs/core';
|
|
1515
|
-
${
|
|
1510
|
+
${authImport}import { registerRoutes } from './routes/index.js';
|
|
1516
1511
|
${servicesSetup}
|
|
1517
1512
|
const app = createKozo({ port: 3000, services });
|
|
1518
1513
|
${authMiddleware}
|