create-astratra-app 0.1.3 → 0.1.5
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/README.md +23 -7
- package/package.json +1 -1
- package/src/createProject.js +321 -51
package/README.md
CHANGED
|
@@ -28,9 +28,12 @@ Il genere :
|
|
|
28
28
|
|
|
29
29
|
- une API Express avec `@astratra/saas-kit` ;
|
|
30
30
|
- une interface React avec `@astratra/saas-kit-ui` ;
|
|
31
|
+
- des fichiers prets a modifier pour `api/security`, `api/stores`,
|
|
32
|
+
`api/db`, `api/ai` et `api/modules` ;
|
|
33
|
+
- une base MongoDB optionnelle via `@astratra/store-mongo` et `mongoose` ;
|
|
34
|
+
- une base IA optionnelle via `@astratra/ai` avec router, tools et agent ;
|
|
31
35
|
- les scripts `dev:api` et `dev:web` ;
|
|
32
|
-
- un `.env.example`
|
|
33
|
-
developpement.
|
|
36
|
+
- un `.env.example` pour l'API, la securite, CORS, MongoDB et Redis.
|
|
34
37
|
|
|
35
38
|
Template API seule :
|
|
36
39
|
|
|
@@ -57,12 +60,25 @@ Pour le template `api`, seul `npm run dev:api` est cree.
|
|
|
57
60
|
|
|
58
61
|
Par defaut, l'API demande un port libre au systeme et ecrit l'URL choisie dans
|
|
59
62
|
`.astratra/api.json`. Lance `dev:api` avant `dev:web` pour que Vite lise la
|
|
60
|
-
bonne URL.
|
|
61
|
-
`PORT=4000 npm run dev:api`.
|
|
63
|
+
bonne URL. Laisse `PORT` vide pour garder le choix automatique.
|
|
62
64
|
|
|
63
65
|
En developpement, l'API accepte automatiquement les origins
|
|
64
|
-
`localhost`/`127.0.0.1`,
|
|
65
|
-
|
|
66
|
+
`localhost`/`127.0.0.1`, quel que soit le port choisi par Vite. En production,
|
|
67
|
+
definis explicitement `CORS_ORIGIN`.
|
|
68
|
+
|
|
69
|
+
## Fichiers generes importants
|
|
70
|
+
|
|
71
|
+
- `api/config/env.js` centralise la configuration.
|
|
72
|
+
- `api/config/cors.js` gere CORS sans port de developpement fixe.
|
|
73
|
+
- `api/security/auth.js`, `api/security/rateLimit.js` et `api/security/waf.js`
|
|
74
|
+
branchent les primitives de securite Astratra.
|
|
75
|
+
- `api/stores/memory.js` lance vite avec des stores en memoire.
|
|
76
|
+
- `api/db/mongo.js` et `api/stores/mongo.js` preparent MongoDB.
|
|
77
|
+
- `api/ai/providers.js`, `api/ai/tools.js` et `api/ai/agent.js` preparent
|
|
78
|
+
la logique IA.
|
|
79
|
+
- `api/modules/users.js`, `api/modules/settings.js` et
|
|
80
|
+
`api/modules/notifications.js` isolent la logique metier de depart.
|
|
66
81
|
|
|
67
82
|
Avant la production, il faut remplacer `JWT_SECRET`, brancher de vrais stores
|
|
68
|
-
et utiliser une vraie verification de mot de passe.
|
|
83
|
+
et utiliser une vraie verification de mot de passe. Definis aussi
|
|
84
|
+
`JWT_ISSUER` et `JWT_AUDIENCE` quand l'API sort du developpement local.
|
package/package.json
CHANGED
package/src/createProject.js
CHANGED
|
@@ -27,8 +27,13 @@ function assertCanCreate(targetDir, force) {
|
|
|
27
27
|
|
|
28
28
|
function packageJson(projectName, template) {
|
|
29
29
|
const dependencies = {
|
|
30
|
-
'@astratra/
|
|
31
|
-
|
|
30
|
+
'@astratra/ai': '^0.1.0',
|
|
31
|
+
'@astratra/core': '^0.1.0',
|
|
32
|
+
'@astratra/saas-kit': '^0.1.1',
|
|
33
|
+
'@astratra/security': '^0.1.1',
|
|
34
|
+
'@astratra/store-mongo': '^0.1.0',
|
|
35
|
+
express: '^4.18.3',
|
|
36
|
+
mongoose: '^8.17.0'
|
|
32
37
|
};
|
|
33
38
|
const devDependencies = {};
|
|
34
39
|
|
|
@@ -61,50 +66,33 @@ function apiServer() {
|
|
|
61
66
|
import fs from 'node:fs';
|
|
62
67
|
import path from 'node:path';
|
|
63
68
|
import saasKit from '@astratra/saas-kit';
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
} catch {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
69
|
+
import { env } from './config/env.js';
|
|
70
|
+
import { createCorsMiddleware } from './config/cors.js';
|
|
71
|
+
import { createAuthSecurity } from './security/auth.js';
|
|
72
|
+
import { createRateLimitSecurity } from './security/rateLimit.js';
|
|
73
|
+
import { createWafSecurity } from './security/waf.js';
|
|
74
|
+
import { createMemoryStores } from './stores/memory.js';
|
|
75
|
+
import { userPublicFields } from './modules/users.js';
|
|
76
|
+
import { createNotificationModule } from './modules/notifications.js';
|
|
77
|
+
|
|
78
|
+
const { createSaasApp } = saasKit;
|
|
79
|
+
const preferredPort = env.port;
|
|
80
|
+
const host = env.host;
|
|
81
|
+
const stores = createMemoryStores();
|
|
82
|
+
const notifications = createNotificationModule();
|
|
82
83
|
|
|
83
84
|
const app = express();
|
|
84
|
-
app.use((
|
|
85
|
-
const origin = req.headers.origin;
|
|
86
|
-
if (origin && (allowedOrigins.has(origin) || isAllowedDevOrigin(origin))) {
|
|
87
|
-
res.setHeader('Access-Control-Allow-Origin', origin);
|
|
88
|
-
res.setHeader('Vary', 'Origin');
|
|
89
|
-
}
|
|
90
|
-
res.setHeader('Access-Control-Allow-Headers', 'content-type, authorization');
|
|
91
|
-
res.setHeader('Access-Control-Allow-Methods', 'GET,POST,PATCH,OPTIONS');
|
|
92
|
-
if (req.method === 'OPTIONS') {
|
|
93
|
-
res.status(204).end();
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
next();
|
|
97
|
-
});
|
|
85
|
+
app.use(createCorsMiddleware({ allowedOrigins: env.corsOrigins }));
|
|
98
86
|
|
|
99
87
|
app.use(createSaasApp({
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
88
|
+
...createAuthSecurity(env),
|
|
89
|
+
...createRateLimitSecurity(env),
|
|
90
|
+
...createWafSecurity(env),
|
|
91
|
+
usersStore: stores.usersStore,
|
|
92
|
+
settingsStore: stores.settingsStore,
|
|
93
|
+
publicUserFields: userPublicFields(),
|
|
106
94
|
verifyPassword: async (user, password) => user.password === password,
|
|
107
|
-
notify:
|
|
95
|
+
notify: notifications.notify
|
|
108
96
|
}));
|
|
109
97
|
|
|
110
98
|
function writeApiRuntimeConfig(port) {
|
|
@@ -142,6 +130,239 @@ listen(preferredPort);
|
|
|
142
130
|
`;
|
|
143
131
|
}
|
|
144
132
|
|
|
133
|
+
function envConfig() {
|
|
134
|
+
return `export const env = {
|
|
135
|
+
nodeEnv: process.env.NODE_ENV || 'development',
|
|
136
|
+
port: process.env.PORT ? Number(process.env.PORT) : 0,
|
|
137
|
+
host: process.env.HOST || '127.0.0.1',
|
|
138
|
+
jwtSecret: process.env.JWT_SECRET || 'change-me-in-production',
|
|
139
|
+
legacyJwtSecret: process.env.LEGACY_JWT_SECRET || '',
|
|
140
|
+
jwtIssuer: process.env.JWT_ISSUER || '',
|
|
141
|
+
jwtAudience: process.env.JWT_AUDIENCE || '',
|
|
142
|
+
mongoUri: process.env.MONGO_URI || '',
|
|
143
|
+
redisUrl: process.env.REDIS_URL || '',
|
|
144
|
+
corsOrigins: (process.env.CORS_ORIGIN || '')
|
|
145
|
+
.split(',')
|
|
146
|
+
.map((origin) => origin.trim())
|
|
147
|
+
.filter(Boolean)
|
|
148
|
+
};
|
|
149
|
+
`;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function corsConfig() {
|
|
153
|
+
return `function isAllowedDevOrigin(origin) {
|
|
154
|
+
if (process.env.NODE_ENV === 'production') return false;
|
|
155
|
+
try {
|
|
156
|
+
const url = new URL(origin);
|
|
157
|
+
return ['127.0.0.1', 'localhost'].includes(url.hostname);
|
|
158
|
+
} catch {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function createCorsMiddleware({ allowedOrigins = [] } = {}) {
|
|
164
|
+
const allowed = new Set(allowedOrigins);
|
|
165
|
+
return (req, res, next) => {
|
|
166
|
+
const origin = req.headers.origin;
|
|
167
|
+
if (origin && (allowed.has(origin) || isAllowedDevOrigin(origin))) {
|
|
168
|
+
res.setHeader('Access-Control-Allow-Origin', origin);
|
|
169
|
+
res.setHeader('Vary', 'Origin');
|
|
170
|
+
}
|
|
171
|
+
res.setHeader('Access-Control-Allow-Headers', 'content-type, authorization');
|
|
172
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET,POST,PATCH,OPTIONS');
|
|
173
|
+
if (req.method === 'OPTIONS') {
|
|
174
|
+
res.status(204).end();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
next();
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
`;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function securityAuth() {
|
|
184
|
+
return `export function createAuthSecurity(env) {
|
|
185
|
+
return {
|
|
186
|
+
jwtSecret: env.jwtSecret,
|
|
187
|
+
legacyJwtSecret: env.legacyJwtSecret || undefined,
|
|
188
|
+
jwtAlgorithms: ['HS256'],
|
|
189
|
+
jwtIssuer: env.jwtIssuer || undefined,
|
|
190
|
+
jwtAudience: env.jwtAudience || undefined,
|
|
191
|
+
roles: {
|
|
192
|
+
adminRoles: ['owner', 'admin']
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
`;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function securityRateLimit() {
|
|
200
|
+
return `export function createRateLimitSecurity(env) {
|
|
201
|
+
return {
|
|
202
|
+
apiRateLimit: {
|
|
203
|
+
windowMs: 15 * 60 * 1000,
|
|
204
|
+
max: 300,
|
|
205
|
+
redisUrl: env.redisUrl || undefined
|
|
206
|
+
},
|
|
207
|
+
loginRateLimit: {
|
|
208
|
+
windowMs: 15 * 60 * 1000,
|
|
209
|
+
max: 10,
|
|
210
|
+
redisUrl: env.redisUrl || undefined
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
`;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function securityWaf() {
|
|
218
|
+
return `export function createWafSecurity() {
|
|
219
|
+
return {
|
|
220
|
+
waf: {
|
|
221
|
+
message: {
|
|
222
|
+
success: false,
|
|
223
|
+
message: 'Request blocked by Astratra security policy.'
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
`;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function memoryStores() {
|
|
232
|
+
return `import saasKit from '@astratra/saas-kit';
|
|
233
|
+
import { defaultSettings } from '../modules/settings.js';
|
|
234
|
+
|
|
235
|
+
const { createMemorySettingsStore, createMemoryUsersStore } = saasKit;
|
|
236
|
+
|
|
237
|
+
export function createMemoryStores() {
|
|
238
|
+
return {
|
|
239
|
+
usersStore: createMemoryUsersStore(),
|
|
240
|
+
settingsStore: createMemorySettingsStore(defaultSettings)
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
`;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function mongoDb() {
|
|
247
|
+
return `import mongoose from 'mongoose';
|
|
248
|
+
|
|
249
|
+
export async function connectMongo(uri, options = {}) {
|
|
250
|
+
if (!uri) {
|
|
251
|
+
throw new Error('MONGO_URI is required to connect MongoDB.');
|
|
252
|
+
}
|
|
253
|
+
await mongoose.connect(uri, options);
|
|
254
|
+
return mongoose.connection;
|
|
255
|
+
}
|
|
256
|
+
`;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function mongoStores() {
|
|
260
|
+
return `import storeMongo from '@astratra/store-mongo';
|
|
261
|
+
|
|
262
|
+
const { createMongoSettingsStore, createMongoUsersStore } = storeMongo;
|
|
263
|
+
|
|
264
|
+
export function createMongoStores({ uri, connection } = {}) {
|
|
265
|
+
const options = connection ? { connection } : { uri };
|
|
266
|
+
return {
|
|
267
|
+
usersStore: createMongoUsersStore(options),
|
|
268
|
+
settingsStore: createMongoSettingsStore(options)
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
`;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function aiProviders() {
|
|
275
|
+
return `import ai from '@astratra/ai';
|
|
276
|
+
|
|
277
|
+
const { createProviderRouter } = ai;
|
|
278
|
+
|
|
279
|
+
export function createAiRouter() {
|
|
280
|
+
return createProviderRouter({
|
|
281
|
+
providers: [
|
|
282
|
+
// Ajoute ici OpenAI, Workers AI, Groq, Mistral, Gemini, etc.
|
|
283
|
+
// Chaque provider doit exposer { id, models, call(prompt, ctx, model) }.
|
|
284
|
+
],
|
|
285
|
+
intentRouting: {}
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
`;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function aiTools() {
|
|
292
|
+
return `import ai from '@astratra/ai';
|
|
293
|
+
|
|
294
|
+
const { createToolRegistry } = ai;
|
|
295
|
+
|
|
296
|
+
export function createAiTools() {
|
|
297
|
+
const registry = createToolRegistry();
|
|
298
|
+
|
|
299
|
+
registry.register({
|
|
300
|
+
name: 'health_check',
|
|
301
|
+
type: 'internal',
|
|
302
|
+
description: 'Retourne un statut simple de l application.',
|
|
303
|
+
roles: ['owner', 'admin'],
|
|
304
|
+
params: {},
|
|
305
|
+
handler: async () => ({ ok: true })
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
return registry;
|
|
309
|
+
}
|
|
310
|
+
`;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function aiAgent() {
|
|
314
|
+
return `import ai from '@astratra/ai';
|
|
315
|
+
import { createAiRouter } from './providers.js';
|
|
316
|
+
import { createAiTools } from './tools.js';
|
|
317
|
+
|
|
318
|
+
const { runAgentLoop } = ai;
|
|
319
|
+
|
|
320
|
+
export function createAgent() {
|
|
321
|
+
const router = createAiRouter();
|
|
322
|
+
const registry = createAiTools();
|
|
323
|
+
|
|
324
|
+
return {
|
|
325
|
+
ask: ({ prompt, userRole = 'owner', ctx = {} }) => runAgentLoop({
|
|
326
|
+
prompt,
|
|
327
|
+
userRole,
|
|
328
|
+
ctx,
|
|
329
|
+
registry,
|
|
330
|
+
router
|
|
331
|
+
}),
|
|
332
|
+
stop: () => router.stop()
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
`;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function usersModule() {
|
|
339
|
+
return `export function userPublicFields() {
|
|
340
|
+
return ['id', 'email', 'role'];
|
|
341
|
+
}
|
|
342
|
+
`;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function settingsModule() {
|
|
346
|
+
return `export const defaultSettings = {
|
|
347
|
+
productName: 'Astratra App',
|
|
348
|
+
supportEmail: 'support@example.test',
|
|
349
|
+
onboardingEnabled: true
|
|
350
|
+
};
|
|
351
|
+
`;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function notificationsModule() {
|
|
355
|
+
return `export function createNotificationModule() {
|
|
356
|
+
return {
|
|
357
|
+
notify: async (message) => ({
|
|
358
|
+
delivered: true,
|
|
359
|
+
message
|
|
360
|
+
})
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
`;
|
|
364
|
+
}
|
|
365
|
+
|
|
145
366
|
function viteConfig() {
|
|
146
367
|
return `import fs from 'node:fs';
|
|
147
368
|
import path from 'node:path';
|
|
@@ -164,8 +385,7 @@ export default defineConfig({
|
|
|
164
385
|
root: 'web',
|
|
165
386
|
plugins: [react()],
|
|
166
387
|
server: {
|
|
167
|
-
host: '127.0.0.1'
|
|
168
|
-
port: 5173
|
|
388
|
+
host: '127.0.0.1'
|
|
169
389
|
}
|
|
170
390
|
});
|
|
171
391
|
`;
|
|
@@ -173,6 +393,7 @@ export default defineConfig({
|
|
|
173
393
|
|
|
174
394
|
function devScript() {
|
|
175
395
|
return `import fs from 'node:fs';
|
|
396
|
+
import net from 'node:net';
|
|
176
397
|
import { spawn } from 'node:child_process';
|
|
177
398
|
|
|
178
399
|
const isWindows = process.platform === 'win32';
|
|
@@ -199,6 +420,19 @@ function run(label, args) {
|
|
|
199
420
|
return child;
|
|
200
421
|
}
|
|
201
422
|
|
|
423
|
+
function findFreePort(host = '127.0.0.1') {
|
|
424
|
+
return new Promise((resolve, reject) => {
|
|
425
|
+
const server = net.createServer();
|
|
426
|
+
server.unref();
|
|
427
|
+
server.on('error', reject);
|
|
428
|
+
server.listen(0, host, () => {
|
|
429
|
+
const address = server.address();
|
|
430
|
+
const port = typeof address === 'object' && address ? address.port : 0;
|
|
431
|
+
server.close(() => resolve(port));
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
|
|
202
436
|
function shutdown(code = 0) {
|
|
203
437
|
shuttingDown = true;
|
|
204
438
|
for (const child of children) {
|
|
@@ -207,9 +441,10 @@ function shutdown(code = 0) {
|
|
|
207
441
|
process.exit(code);
|
|
208
442
|
}
|
|
209
443
|
|
|
210
|
-
function waitForApiConfig() {
|
|
444
|
+
async function waitForApiConfig() {
|
|
211
445
|
if (fs.existsSync(apiConfigPath)) {
|
|
212
|
-
|
|
446
|
+
const webPort = await findFreePort();
|
|
447
|
+
run('web', ['run', 'dev:web', '--', '--port', String(webPort)]);
|
|
213
448
|
return;
|
|
214
449
|
}
|
|
215
450
|
|
|
@@ -219,7 +454,12 @@ function waitForApiConfig() {
|
|
|
219
454
|
return;
|
|
220
455
|
}
|
|
221
456
|
|
|
222
|
-
setTimeout(
|
|
457
|
+
setTimeout(() => {
|
|
458
|
+
waitForApiConfig().catch((error) => {
|
|
459
|
+
console.error(error.message);
|
|
460
|
+
shutdown(1);
|
|
461
|
+
});
|
|
462
|
+
}, pollMs);
|
|
223
463
|
}
|
|
224
464
|
|
|
225
465
|
process.on('SIGINT', () => shutdown(0));
|
|
@@ -227,7 +467,10 @@ process.on('SIGTERM', () => shutdown(0));
|
|
|
227
467
|
|
|
228
468
|
fs.rmSync(apiConfigPath, { force: true });
|
|
229
469
|
run('api', ['run', 'dev:api']);
|
|
230
|
-
waitForApiConfig()
|
|
470
|
+
waitForApiConfig().catch((error) => {
|
|
471
|
+
console.error(error.message);
|
|
472
|
+
shutdown(1);
|
|
473
|
+
});
|
|
231
474
|
`;
|
|
232
475
|
}
|
|
233
476
|
|
|
@@ -299,8 +542,20 @@ npm run dev:api
|
|
|
299
542
|
${webSteps}
|
|
300
543
|
Par defaut, l'API demande un port libre au systeme et ecrit l'URL choisie
|
|
301
544
|
dans \`.astratra/api.json\`. Lance \`dev:api\` avant \`dev:web\` pour que Vite
|
|
302
|
-
lise la bonne URL.
|
|
303
|
-
|
|
545
|
+
lise la bonne URL. Laisse \`PORT\` vide pour garder le choix automatique.
|
|
546
|
+
|
|
547
|
+
## Fichiers importants
|
|
548
|
+
|
|
549
|
+
- \`api/config/env.js\` centralise la configuration.
|
|
550
|
+
- \`api/config/cors.js\` gere CORS sans port de developpement fixe.
|
|
551
|
+
- \`api/security/auth.js\`, \`api/security/rateLimit.js\` et
|
|
552
|
+
\`api/security/waf.js\` branchent les primitives de securite Astratra.
|
|
553
|
+
- \`api/stores/memory.js\` lance vite avec des stores en memoire.
|
|
554
|
+
- \`api/db/mongo.js\` et \`api/stores/mongo.js\` preparent MongoDB.
|
|
555
|
+
- \`api/ai/providers.js\`, \`api/ai/tools.js\` et \`api/ai/agent.js\`
|
|
556
|
+
preparent la logique IA.
|
|
557
|
+
- \`api/modules/users.js\`, \`api/modules/settings.js\` et
|
|
558
|
+
\`api/modules/notifications.js\` isolent la logique metier de depart.
|
|
304
559
|
|
|
305
560
|
Comptes de test :
|
|
306
561
|
|
|
@@ -308,7 +563,8 @@ Comptes de test :
|
|
|
308
563
|
- \`member@example.test\` / \`password\`
|
|
309
564
|
|
|
310
565
|
Avant la production, remplace \`JWT_SECRET\`, branche de vrais stores et change
|
|
311
|
-
la verification de mot de passe.
|
|
566
|
+
la verification de mot de passe. Definis aussi \`JWT_ISSUER\` et
|
|
567
|
+
\`JWT_AUDIENCE\` quand l'API sort du developpement local.
|
|
312
568
|
`;
|
|
313
569
|
}
|
|
314
570
|
|
|
@@ -354,8 +610,22 @@ export function createProject({ targetDir, template = 'fullstack', force = false
|
|
|
354
610
|
|
|
355
611
|
writeFile(absoluteTarget, 'package.json', `${packageJson(projectName, template)}\n`);
|
|
356
612
|
writeFile(absoluteTarget, 'api/server.js', apiServer());
|
|
613
|
+
writeFile(absoluteTarget, 'api/config/env.js', envConfig());
|
|
614
|
+
writeFile(absoluteTarget, 'api/config/cors.js', corsConfig());
|
|
615
|
+
writeFile(absoluteTarget, 'api/security/auth.js', securityAuth());
|
|
616
|
+
writeFile(absoluteTarget, 'api/security/rateLimit.js', securityRateLimit());
|
|
617
|
+
writeFile(absoluteTarget, 'api/security/waf.js', securityWaf());
|
|
618
|
+
writeFile(absoluteTarget, 'api/stores/memory.js', memoryStores());
|
|
619
|
+
writeFile(absoluteTarget, 'api/stores/mongo.js', mongoStores());
|
|
620
|
+
writeFile(absoluteTarget, 'api/db/mongo.js', mongoDb());
|
|
621
|
+
writeFile(absoluteTarget, 'api/ai/providers.js', aiProviders());
|
|
622
|
+
writeFile(absoluteTarget, 'api/ai/tools.js', aiTools());
|
|
623
|
+
writeFile(absoluteTarget, 'api/ai/agent.js', aiAgent());
|
|
624
|
+
writeFile(absoluteTarget, 'api/modules/users.js', usersModule());
|
|
625
|
+
writeFile(absoluteTarget, 'api/modules/settings.js', settingsModule());
|
|
626
|
+
writeFile(absoluteTarget, 'api/modules/notifications.js', notificationsModule());
|
|
357
627
|
writeFile(absoluteTarget, '.gitignore', 'node_modules\n.env\n.astratra\n');
|
|
358
|
-
writeFile(absoluteTarget, '.env.example', 'PORT=\nHOST=127.0.0.1\nJWT_SECRET=change-me\nCORS_ORIGIN=\n');
|
|
628
|
+
writeFile(absoluteTarget, '.env.example', 'PORT=\nHOST=127.0.0.1\nJWT_SECRET=change-me\nLEGACY_JWT_SECRET=\nJWT_ISSUER=\nJWT_AUDIENCE=\nCORS_ORIGIN=\nMONGO_URI=\nREDIS_URL=\n');
|
|
359
629
|
writeFile(absoluteTarget, 'README.md', readme(projectName, template));
|
|
360
630
|
|
|
361
631
|
if (template === 'fullstack') {
|