@shakil-dev/shakil-stack 2.1.1 → 2.2.1
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/bin/index.js +17 -4
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -343,15 +343,17 @@ export const sanitizeRequest = (req: Request, res: Response, next: NextFunction)
|
|
|
343
343
|
};
|
|
344
344
|
`;
|
|
345
345
|
|
|
346
|
-
const
|
|
346
|
+
const basePrisma = `generator client {
|
|
347
347
|
provider = "prisma-client-js"
|
|
348
|
+
previewFeatures = ["prismaSchemaFolder"]
|
|
348
349
|
}
|
|
349
350
|
|
|
350
351
|
datasource db {
|
|
351
352
|
provider = "postgresql"
|
|
352
353
|
}
|
|
354
|
+
`;
|
|
353
355
|
|
|
354
|
-
model User {
|
|
356
|
+
const userPrisma = `model User {
|
|
355
357
|
id String @id @default(uuid())
|
|
356
358
|
email String @unique
|
|
357
359
|
name String
|
|
@@ -394,7 +396,7 @@ import { defineConfig } from "prisma/config";
|
|
|
394
396
|
import process from "process";
|
|
395
397
|
|
|
396
398
|
export default defineConfig({
|
|
397
|
-
schema: "prisma/schema
|
|
399
|
+
schema: "prisma/schema",
|
|
398
400
|
datasource: {
|
|
399
401
|
url: process.env.DATABASE_URL,
|
|
400
402
|
},
|
|
@@ -462,7 +464,8 @@ export default sendResponse;
|
|
|
462
464
|
await fs.outputFile(path.join(projectPath, 'backend', 'src', 'app', 'utils', 'sendResponse.ts'), sendResponseTs);
|
|
463
465
|
await fs.outputFile(path.join(projectPath, 'backend', 'src', 'app', 'utils', 'sanitizer.ts'), sanitizerTs);
|
|
464
466
|
await fs.outputFile(path.join(projectPath, 'backend', 'src', 'app', 'errorHelpers', 'ApiError.ts'), apiErrorTs);
|
|
465
|
-
await fs.outputFile(path.join(projectPath, 'backend', 'prisma', 'schema.prisma'),
|
|
467
|
+
await fs.outputFile(path.join(projectPath, 'backend', 'prisma', 'schema', 'base.prisma'), basePrisma);
|
|
468
|
+
await fs.outputFile(path.join(projectPath, 'backend', 'prisma', 'schema', 'user.prisma'), userPrisma);
|
|
466
469
|
await fs.outputFile(path.join(projectPath, 'backend', 'prisma.config.ts'), prismaConfigTs);
|
|
467
470
|
await fs.outputFile(path.join(projectPath, 'backend', 'tsconfig.json'), tsconfigTs);
|
|
468
471
|
await fs.outputFile(path.join(projectPath, 'backend', '.gitignore'), 'node_modules\ndist\n.env');
|
|
@@ -638,6 +641,16 @@ export const ${moduleName}Validations = {
|
|
|
638
641
|
`,
|
|
639
642
|
};
|
|
640
643
|
|
|
644
|
+
// Add Prisma schema for the module
|
|
645
|
+
const modulePrisma = `model ${moduleName} {
|
|
646
|
+
id String @id @default(uuid())
|
|
647
|
+
name String
|
|
648
|
+
createdAt DateTime @default(now())
|
|
649
|
+
updatedAt DateTime @updatedAt
|
|
650
|
+
}
|
|
651
|
+
`;
|
|
652
|
+
await fs.outputFile(path.join(backendRoot, 'prisma', 'schema', `${lowercaseName}.prisma`), modulePrisma);
|
|
653
|
+
|
|
641
654
|
for (const [ext, content] of Object.entries(files)) {
|
|
642
655
|
await fs.outputFile(path.join(moduleDir, `${lowercaseName}.${ext}`), content);
|
|
643
656
|
}
|