arkos 1.1.72-test → 1.1.74-test
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/dist/cjs/modules/base/base.service.js +1 -0
- package/dist/cjs/modules/base/base.service.js.map +1 -1
- package/dist/cjs/utils/cli/generate.js +21 -19
- package/dist/cjs/utils/cli/generate.js.map +1 -1
- package/dist/cjs/utils/cli/index.js +2 -2
- package/dist/cjs/utils/cli/index.js.map +1 -1
- package/dist/cjs/utils/cli/utils/{helpers.js → cli.helpers.js} +1 -5
- package/dist/cjs/utils/cli/utils/cli.helpers.js.map +1 -0
- package/dist/cjs/utils/cli/utils/template-generators.js +398 -0
- package/dist/cjs/utils/cli/utils/template-generators.js.map +1 -0
- package/dist/cjs/utils/helpers/fs.helpers.js.map +1 -1
- package/dist/es2020/modules/base/base.service.js +1 -0
- package/dist/es2020/modules/base/base.service.js.map +1 -1
- package/dist/es2020/utils/cli/generate.js +11 -9
- package/dist/es2020/utils/cli/generate.js.map +1 -1
- package/dist/es2020/utils/cli/index.js +2 -2
- package/dist/es2020/utils/cli/index.js.map +1 -1
- package/dist/es2020/utils/cli/utils/{helpers.js → cli.helpers.js} +1 -4
- package/dist/es2020/utils/cli/utils/cli.helpers.js.map +1 -0
- package/dist/es2020/utils/cli/utils/template-generators.js +395 -0
- package/dist/es2020/utils/cli/utils/template-generators.js.map +1 -0
- package/dist/es2020/utils/helpers/fs.helpers.js.map +1 -1
- package/dist/types/utils/cli/generate.d.ts +2 -2
- package/dist/types/utils/cli/utils/{helpers.d.ts → cli.helpers.d.ts} +0 -1
- package/package.json +2 -2
- package/dist/cjs/utils/cli/utils/generators.js +0 -200
- package/dist/cjs/utils/cli/utils/generators.js.map +0 -1
- package/dist/cjs/utils/cli/utils/helpers.js.map +0 -1
- package/dist/es2020/utils/cli/utils/generators.js +0 -197
- package/dist/es2020/utils/cli/utils/generators.js.map +0 -1
- package/dist/es2020/utils/cli/utils/helpers.js.map +0 -1
- /package/dist/types/utils/cli/utils/{generators.d.ts → template-generators.d.ts} +0 -0
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateTemplate = generateTemplate;
|
|
4
|
-
function generateTemplate(type, options = {}) {
|
|
5
|
-
switch (type) {
|
|
6
|
-
case "controller":
|
|
7
|
-
return generateControllerTemplate(options);
|
|
8
|
-
case "service":
|
|
9
|
-
return generateServiceTemplate(options);
|
|
10
|
-
case "router":
|
|
11
|
-
return generateRouterTemplate(options);
|
|
12
|
-
case "auth":
|
|
13
|
-
return generateAuthConfigTemplate();
|
|
14
|
-
case "query":
|
|
15
|
-
return generateQueryConfigTemplate(options);
|
|
16
|
-
case "middleware":
|
|
17
|
-
return generateMiddlewareTemplate(options);
|
|
18
|
-
default:
|
|
19
|
-
throw new Error(`Unknown template type: ${type}`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function generateControllerTemplate(options) {
|
|
23
|
-
const { modelName, imports } = options;
|
|
24
|
-
if (!modelName)
|
|
25
|
-
throw new Error("Model name is required for controller template");
|
|
26
|
-
return `import { BaseController } from "${imports?.baseController || "arkos/controllers"}";
|
|
27
|
-
|
|
28
|
-
class ${modelName.pascal}Controller extends BaseController {
|
|
29
|
-
constructor() {
|
|
30
|
-
super("${modelName.kebab}");
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const ${modelName.camel}Controller = new ${modelName.pascal}Controller();
|
|
35
|
-
|
|
36
|
-
export default ${modelName.camel}Controller;
|
|
37
|
-
`;
|
|
38
|
-
}
|
|
39
|
-
function generateServiceTemplate(options) {
|
|
40
|
-
const { modelName, imports } = options;
|
|
41
|
-
if (!modelName)
|
|
42
|
-
throw new Error("Model name is required for service template");
|
|
43
|
-
return `import { BaseService } from "${imports?.baseService || "arkos/services"}";
|
|
44
|
-
|
|
45
|
-
class ${modelName.pascal}Service extends BaseService {
|
|
46
|
-
constructor() {
|
|
47
|
-
super("${modelName.kebab}");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Add your custom service methods here
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const ${modelName.camel}Service = new ${modelName.pascal}Service();
|
|
54
|
-
|
|
55
|
-
export default ${modelName.camel}Service;
|
|
56
|
-
`;
|
|
57
|
-
}
|
|
58
|
-
function generateRouterTemplate(options) {
|
|
59
|
-
const { modelName, imports } = options;
|
|
60
|
-
if (!modelName)
|
|
61
|
-
throw new Error("Model name is required for router template");
|
|
62
|
-
return `import { Router } from "express";
|
|
63
|
-
import { createRoutes } from "${imports?.baseRouter || "arkos"}";
|
|
64
|
-
import ${modelName.camel}Controller from "${imports?.controller || `./${modelName.kebab}.controller`}";
|
|
65
|
-
|
|
66
|
-
const ${modelName.camel}Router = Router();
|
|
67
|
-
|
|
68
|
-
// Generate CRUD routes automatically
|
|
69
|
-
createRoutes(${modelName.camel}Router, ${modelName.camel}Controller);
|
|
70
|
-
|
|
71
|
-
// Add custom routes here
|
|
72
|
-
// ${modelName.camel}Router.get('/custom', ${modelName.camel}Controller.customMethod);
|
|
73
|
-
|
|
74
|
-
export default ${modelName.camel}Router;
|
|
75
|
-
`;
|
|
76
|
-
}
|
|
77
|
-
function generateAuthConfigTemplate() {
|
|
78
|
-
return `export const authConfig = {
|
|
79
|
-
jwt: {
|
|
80
|
-
secret: process.env.JWT_SECRET || 'your-secret-key',
|
|
81
|
-
expiresIn: process.env.JWT_EXPIRES_IN || '7d',
|
|
82
|
-
refreshExpiresIn: process.env.JWT_REFRESH_EXPIRES_IN || '30d',
|
|
83
|
-
},
|
|
84
|
-
bcrypt: {
|
|
85
|
-
saltRounds: parseInt(process.env.BCRYPT_SALT_ROUNDS || '12'),
|
|
86
|
-
},
|
|
87
|
-
cookie: {
|
|
88
|
-
name: process.env.COOKIE_NAME || 'arkos-token',
|
|
89
|
-
maxAge: parseInt(process.env.COOKIE_MAX_AGE || '604800000'), // 7 days
|
|
90
|
-
httpOnly: true,
|
|
91
|
-
secure: process.env.NODE_ENV === 'production',
|
|
92
|
-
sameSite: 'strict' as const,
|
|
93
|
-
},
|
|
94
|
-
rateLimit: {
|
|
95
|
-
windowMs: parseInt(process.env.RATE_LIMIT_WINDOW || '900000'), // 15 minutes
|
|
96
|
-
max: parseInt(process.env.RATE_LIMIT_MAX || '5'), // 5 attempts
|
|
97
|
-
},
|
|
98
|
-
email: {
|
|
99
|
-
verification: {
|
|
100
|
-
required: process.env.EMAIL_VERIFICATION_REQUIRED === 'true',
|
|
101
|
-
expiresIn: process.env.EMAIL_VERIFICATION_EXPIRES_IN || '24h',
|
|
102
|
-
},
|
|
103
|
-
passwordReset: {
|
|
104
|
-
expiresIn: process.env.PASSWORD_RESET_EXPIRES_IN || '1h',
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export default authConfig;
|
|
110
|
-
`;
|
|
111
|
-
}
|
|
112
|
-
function generateQueryConfigTemplate(options) {
|
|
113
|
-
const { modelName } = options;
|
|
114
|
-
if (!modelName)
|
|
115
|
-
throw new Error("Model name is required for query config template");
|
|
116
|
-
return `export const ${modelName.camel}QueryOptions = {
|
|
117
|
-
// Define searchable fields
|
|
118
|
-
searchFields: [
|
|
119
|
-
// 'name',
|
|
120
|
-
// 'email',
|
|
121
|
-
// 'description',
|
|
122
|
-
],
|
|
123
|
-
|
|
124
|
-
// Define filterable fields
|
|
125
|
-
filterFields: [
|
|
126
|
-
// 'status',
|
|
127
|
-
// 'type',
|
|
128
|
-
// 'createdAt',
|
|
129
|
-
],
|
|
130
|
-
|
|
131
|
-
// Define sortable fields
|
|
132
|
-
sortFields: [
|
|
133
|
-
'id',
|
|
134
|
-
'createdAt',
|
|
135
|
-
'updatedAt',
|
|
136
|
-
// Add other sortable fields
|
|
137
|
-
],
|
|
138
|
-
|
|
139
|
-
// Define relations to include
|
|
140
|
-
include: {
|
|
141
|
-
// relationName: true,
|
|
142
|
-
// relationName: {
|
|
143
|
-
// select: {
|
|
144
|
-
// id: true,
|
|
145
|
-
// name: true,
|
|
146
|
-
// }
|
|
147
|
-
// }
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
// Define fields to select (if not all)
|
|
151
|
-
select: {
|
|
152
|
-
// id: true,
|
|
153
|
-
// name: true,
|
|
154
|
-
// email: true,
|
|
155
|
-
// createdAt: true,
|
|
156
|
-
// updatedAt: true,
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
// Default pagination
|
|
160
|
-
pagination: {
|
|
161
|
-
defaultLimit: 10,
|
|
162
|
-
maxLimit: 100,
|
|
163
|
-
},
|
|
164
|
-
|
|
165
|
-
// Default sorting
|
|
166
|
-
defaultSort: {
|
|
167
|
-
field: 'createdAt',
|
|
168
|
-
order: 'desc' as const,
|
|
169
|
-
},
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
export default ${modelName.camel}QueryOptions;
|
|
173
|
-
`;
|
|
174
|
-
}
|
|
175
|
-
function generateMiddlewareTemplate(options) {
|
|
176
|
-
const { middlewareName } = options;
|
|
177
|
-
if (!middlewareName)
|
|
178
|
-
throw new Error("Middleware name is required for middleware template");
|
|
179
|
-
return `import { Request, Response, NextFunction } from 'express';
|
|
180
|
-
|
|
181
|
-
export const ${middlewareName.camel}Middleware = (
|
|
182
|
-
req: Request,
|
|
183
|
-
res: Response,
|
|
184
|
-
next: NextFunction
|
|
185
|
-
): void => {
|
|
186
|
-
try {
|
|
187
|
-
// Add your middleware logic here
|
|
188
|
-
console.log(\`${middlewareName.pascal} middleware executed for \${req.method} \${req.path}\`);
|
|
189
|
-
|
|
190
|
-
// Continue to next middleware
|
|
191
|
-
next();
|
|
192
|
-
} catch (error) {
|
|
193
|
-
next(error);
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
export default ${middlewareName.camel}Middleware;
|
|
198
|
-
`;
|
|
199
|
-
}
|
|
200
|
-
//# sourceMappingURL=gener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AAK,CAAC,qDAAqD,CAAC,CAAC;IAEzE,OAAO;;iBAEQ,cAAc,CAAC,KAAK;;;;;;;sBAOf,cAAc,CAAC,MAAM;;;;;;;;;mBASxB,cAAc,CAAC,KAAK;GACpC,CAAC;AACJ,CAAC","sourcesContent":["interface ModelName {\n pascal: string;\n camel: string;\n kebab: string;\n}\n\ninterface MiddlewareName {\n pascal: string;\n camel: string;\n kebab: string;\n}\n\ninterface TemplateOptions {\n modelName?: ModelName;\n middlewareName?: MiddlewareName;\n imports?: Record<string, string>;\n}\n\nexport function generateTemplate(\n type: string,\n options: TemplateOptions = {}\n): string {\n switch (type) {\n case \"controller\":\n return generateControllerTemplate(options);\n case \"service\":\n return generateServiceTemplate(options);\n case \"router\":\n return generateRouterTemplate(options);\n case \"auth\":\n return generateAuthConfigTemplate();\n case \"query\":\n return generateQueryConfigTemplate(options);\n case \"middleware\":\n return generateMiddlewareTemplate(options);\n default:\n throw new Error(`Unknown template type: ${type}`);\n }\n}\n\nfunction generateControllerTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName)\n throw new Error(\"Model name is required for controller template\");\n\n return `import { BaseController } from \"${\n imports?.baseController || \"arkos/controllers\"\n }\";\n \n class ${modelName.pascal}Controller extends BaseController {\n constructor() {\n super(\"${modelName.kebab}\");\n }\n }\n \n const ${modelName.camel}Controller = new ${modelName.pascal}Controller();\n \n export default ${modelName.camel}Controller;\n `;\n}\n\nfunction generateServiceTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName)\n throw new Error(\"Model name is required for service template\");\n\n return `import { BaseService } from \"${\n imports?.baseService || \"arkos/services\"\n }\";\n \n class ${modelName.pascal}Service extends BaseService {\n constructor() {\n super(\"${modelName.kebab}\");\n }\n \n // Add your custom service methods here\n }\n \n const ${modelName.camel}Service = new ${modelName.pascal}Service();\n \n export default ${modelName.camel}Service;\n `;\n}\n\nfunction generateRouterTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName) throw new Error(\"Model name is required for router template\");\n\n return `import { Router } from \"express\";\n import { createRoutes } from \"${imports?.baseRouter || \"arkos\"}\";\n import ${modelName.camel}Controller from \"${\n imports?.controller || `./${modelName.kebab}.controller`\n }\";\n \n const ${modelName.camel}Router = Router();\n \n // Generate CRUD routes automatically\n createRoutes(${modelName.camel}Router, ${modelName.camel}Controller);\n \n // Add custom routes here\n // ${modelName.camel}Router.get('/custom', ${\n modelName.camel\n }Controller.customMethod);\n \n export default ${modelName.camel}Router;\n `;\n}\n\nfunction generateAuthConfigTemplate(): string {\n return `export const authConfig = {\n jwt: {\n secret: process.env.JWT_SECRET || 'your-secret-key',\n expiresIn: process.env.JWT_EXPIRES_IN || '7d',\n refreshExpiresIn: process.env.JWT_REFRESH_EXPIRES_IN || '30d',\n },\n bcrypt: {\n saltRounds: parseInt(process.env.BCRYPT_SALT_ROUNDS || '12'),\n },\n cookie: {\n name: process.env.COOKIE_NAME || 'arkos-token',\n maxAge: parseInt(process.env.COOKIE_MAX_AGE || '604800000'), // 7 days\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'strict' as const,\n },\n rateLimit: {\n windowMs: parseInt(process.env.RATE_LIMIT_WINDOW || '900000'), // 15 minutes\n max: parseInt(process.env.RATE_LIMIT_MAX || '5'), // 5 attempts\n },\n email: {\n verification: {\n required: process.env.EMAIL_VERIFICATION_REQUIRED === 'true',\n expiresIn: process.env.EMAIL_VERIFICATION_EXPIRES_IN || '24h',\n },\n passwordReset: {\n expiresIn: process.env.PASSWORD_RESET_EXPIRES_IN || '1h',\n },\n },\n };\n \n export default authConfig;\n `;\n}\n\nfunction generateQueryConfigTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n\n if (!modelName)\n throw new Error(\"Model name is required for query config template\");\n\n return `export const ${modelName.camel}QueryOptions = {\n // Define searchable fields\n searchFields: [\n // 'name',\n // 'email',\n // 'description',\n ],\n \n // Define filterable fields\n filterFields: [\n // 'status',\n // 'type',\n // 'createdAt',\n ],\n \n // Define sortable fields\n sortFields: [\n 'id',\n 'createdAt',\n 'updatedAt',\n // Add other sortable fields\n ],\n \n // Define relations to include\n include: {\n // relationName: true,\n // relationName: {\n // select: {\n // id: true,\n // name: true,\n // }\n // }\n },\n \n // Define fields to select (if not all)\n select: {\n // id: true,\n // name: true,\n // email: true,\n // createdAt: true,\n // updatedAt: true,\n },\n \n // Default pagination\n pagination: {\n defaultLimit: 10,\n maxLimit: 100,\n },\n \n // Default sorting\n defaultSort: {\n field: 'createdAt',\n order: 'desc' as const,\n },\n };\n \n export default ${modelName.camel}QueryOptions;\n `;\n}\n\nfunction generateMiddlewareTemplate(options: TemplateOptions): string {\n const { middlewareName } = options;\n\n if (!middlewareName)\n throw new Error(\"Middleware name is required for middleware template\");\n\n return `import { Request, Response, NextFunction } from 'express';\n \n export const ${middlewareName.camel}Middleware = (\n req: Request,\n res: Response,\n next: NextFunction\n ): void => {\n try {\n // Add your middleware logic here\n console.log(\\`${middlewareName.pascal} middleware executed for \\${req.method} \\${req.path}\\`);\n \n // Continue to next middleware\n next();\n } catch (error) {\n next(error);\n }\n };\n \n export default ${middlewareName.camel}Middleware;\n `;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../src/utils/cli/utils/helpers.ts"],"names":[],"mappings":";;;;;AA4BA,sDAIC;AAED,gCAEC;AAnCD,4CAAoB;AA2BpB,SAAgB,qBAAqB,CAAC,OAAe;IACnD,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,YAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC;AAED,SAAgB,UAAU,CAAC,QAAgB;IACzC,OAAO,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// src/utils/cli/utils.ts\nimport fs from \"fs\";\nimport path from \"path\";\n\n// export function toPascalCase(str: string): string {\n// return str\n// .replace(/[\\W_]/g, \" \")\n// .replace(/\\s+/g, \" \")\n// .trim()\n// .split(\" \")\n// .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n// .join(\"\");\n// }\n\n// export function toCamelCase(str: string): string {\n// const pascal = toPascalCase(str);\n// return pascal.charAt(0).toLowerCase() + pascal.slice(1);\n// }\n\n// export function toKebabCase(str: string): string {\n// return str\n// .replace(/([a-z])([A-Z])/g, \"$1-$2\")\n// .replace(/[\\W_]/g, \"-\")\n// .replace(/-+/g, \"-\")\n// .replace(/^-|-$/g, \"\")\n// .toLowerCase();\n// }\n\nexport function ensureDirectoryExists(dirPath: string): void {\n if (!fs.existsSync(dirPath)) {\n fs.mkdirSync(dirPath, { recursive: true });\n }\n}\n\nexport function fileExists(filePath: string): boolean {\n return fs.existsSync(filePath);\n}\n\n// export function getProjectType(): \"typescript\" | \"javascript\" {\n// const tsConfigExists = fileExists(path.join(process.cwd(), \"tsconfig.json\"));\n// const packageJson = path.join(process.cwd(), \"package.json\");\n\n// if (tsConfigExists) return \"typescript\";\n\n// if (fileExists(packageJson)) {\n// try {\n// const pkg = JSON.parse(fs.readFileSync(packageJson, \"utf8\"));\n// if (pkg.devDependencies?.typescript || pkg.dependencies?.typescript) {\n// return \"typescript\";\n// }\n// } catch {\n// // ignore\n// }\n// }\n\n// return \"javascript\";\n// }\n"]}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
export function generateTemplate(type, options = {}) {
|
|
2
|
-
switch (type) {
|
|
3
|
-
case "controller":
|
|
4
|
-
return generateControllerTemplate(options);
|
|
5
|
-
case "service":
|
|
6
|
-
return generateServiceTemplate(options);
|
|
7
|
-
case "router":
|
|
8
|
-
return generateRouterTemplate(options);
|
|
9
|
-
case "auth":
|
|
10
|
-
return generateAuthConfigTemplate();
|
|
11
|
-
case "query":
|
|
12
|
-
return generateQueryConfigTemplate(options);
|
|
13
|
-
case "middleware":
|
|
14
|
-
return generateMiddlewareTemplate(options);
|
|
15
|
-
default:
|
|
16
|
-
throw new Error(`Unknown template type: ${type}`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function generateControllerTemplate(options) {
|
|
20
|
-
const { modelName, imports } = options;
|
|
21
|
-
if (!modelName)
|
|
22
|
-
throw new Error("Model name is required for controller template");
|
|
23
|
-
return `import { BaseController } from "${imports?.baseController || "arkos/controllers"}";
|
|
24
|
-
|
|
25
|
-
class ${modelName.pascal}Controller extends BaseController {
|
|
26
|
-
constructor() {
|
|
27
|
-
super("${modelName.kebab}");
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const ${modelName.camel}Controller = new ${modelName.pascal}Controller();
|
|
32
|
-
|
|
33
|
-
export default ${modelName.camel}Controller;
|
|
34
|
-
`;
|
|
35
|
-
}
|
|
36
|
-
function generateServiceTemplate(options) {
|
|
37
|
-
const { modelName, imports } = options;
|
|
38
|
-
if (!modelName)
|
|
39
|
-
throw new Error("Model name is required for service template");
|
|
40
|
-
return `import { BaseService } from "${imports?.baseService || "arkos/services"}";
|
|
41
|
-
|
|
42
|
-
class ${modelName.pascal}Service extends BaseService {
|
|
43
|
-
constructor() {
|
|
44
|
-
super("${modelName.kebab}");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Add your custom service methods here
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const ${modelName.camel}Service = new ${modelName.pascal}Service();
|
|
51
|
-
|
|
52
|
-
export default ${modelName.camel}Service;
|
|
53
|
-
`;
|
|
54
|
-
}
|
|
55
|
-
function generateRouterTemplate(options) {
|
|
56
|
-
const { modelName, imports } = options;
|
|
57
|
-
if (!modelName)
|
|
58
|
-
throw new Error("Model name is required for router template");
|
|
59
|
-
return `import { Router } from "express";
|
|
60
|
-
import { createRoutes } from "${imports?.baseRouter || "arkos"}";
|
|
61
|
-
import ${modelName.camel}Controller from "${imports?.controller || `./${modelName.kebab}.controller`}";
|
|
62
|
-
|
|
63
|
-
const ${modelName.camel}Router = Router();
|
|
64
|
-
|
|
65
|
-
// Generate CRUD routes automatically
|
|
66
|
-
createRoutes(${modelName.camel}Router, ${modelName.camel}Controller);
|
|
67
|
-
|
|
68
|
-
// Add custom routes here
|
|
69
|
-
// ${modelName.camel}Router.get('/custom', ${modelName.camel}Controller.customMethod);
|
|
70
|
-
|
|
71
|
-
export default ${modelName.camel}Router;
|
|
72
|
-
`;
|
|
73
|
-
}
|
|
74
|
-
function generateAuthConfigTemplate() {
|
|
75
|
-
return `export const authConfig = {
|
|
76
|
-
jwt: {
|
|
77
|
-
secret: process.env.JWT_SECRET || 'your-secret-key',
|
|
78
|
-
expiresIn: process.env.JWT_EXPIRES_IN || '7d',
|
|
79
|
-
refreshExpiresIn: process.env.JWT_REFRESH_EXPIRES_IN || '30d',
|
|
80
|
-
},
|
|
81
|
-
bcrypt: {
|
|
82
|
-
saltRounds: parseInt(process.env.BCRYPT_SALT_ROUNDS || '12'),
|
|
83
|
-
},
|
|
84
|
-
cookie: {
|
|
85
|
-
name: process.env.COOKIE_NAME || 'arkos-token',
|
|
86
|
-
maxAge: parseInt(process.env.COOKIE_MAX_AGE || '604800000'), // 7 days
|
|
87
|
-
httpOnly: true,
|
|
88
|
-
secure: process.env.NODE_ENV === 'production',
|
|
89
|
-
sameSite: 'strict' as const,
|
|
90
|
-
},
|
|
91
|
-
rateLimit: {
|
|
92
|
-
windowMs: parseInt(process.env.RATE_LIMIT_WINDOW || '900000'), // 15 minutes
|
|
93
|
-
max: parseInt(process.env.RATE_LIMIT_MAX || '5'), // 5 attempts
|
|
94
|
-
},
|
|
95
|
-
email: {
|
|
96
|
-
verification: {
|
|
97
|
-
required: process.env.EMAIL_VERIFICATION_REQUIRED === 'true',
|
|
98
|
-
expiresIn: process.env.EMAIL_VERIFICATION_EXPIRES_IN || '24h',
|
|
99
|
-
},
|
|
100
|
-
passwordReset: {
|
|
101
|
-
expiresIn: process.env.PASSWORD_RESET_EXPIRES_IN || '1h',
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export default authConfig;
|
|
107
|
-
`;
|
|
108
|
-
}
|
|
109
|
-
function generateQueryConfigTemplate(options) {
|
|
110
|
-
const { modelName } = options;
|
|
111
|
-
if (!modelName)
|
|
112
|
-
throw new Error("Model name is required for query config template");
|
|
113
|
-
return `export const ${modelName.camel}QueryOptions = {
|
|
114
|
-
// Define searchable fields
|
|
115
|
-
searchFields: [
|
|
116
|
-
// 'name',
|
|
117
|
-
// 'email',
|
|
118
|
-
// 'description',
|
|
119
|
-
],
|
|
120
|
-
|
|
121
|
-
// Define filterable fields
|
|
122
|
-
filterFields: [
|
|
123
|
-
// 'status',
|
|
124
|
-
// 'type',
|
|
125
|
-
// 'createdAt',
|
|
126
|
-
],
|
|
127
|
-
|
|
128
|
-
// Define sortable fields
|
|
129
|
-
sortFields: [
|
|
130
|
-
'id',
|
|
131
|
-
'createdAt',
|
|
132
|
-
'updatedAt',
|
|
133
|
-
// Add other sortable fields
|
|
134
|
-
],
|
|
135
|
-
|
|
136
|
-
// Define relations to include
|
|
137
|
-
include: {
|
|
138
|
-
// relationName: true,
|
|
139
|
-
// relationName: {
|
|
140
|
-
// select: {
|
|
141
|
-
// id: true,
|
|
142
|
-
// name: true,
|
|
143
|
-
// }
|
|
144
|
-
// }
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
-
// Define fields to select (if not all)
|
|
148
|
-
select: {
|
|
149
|
-
// id: true,
|
|
150
|
-
// name: true,
|
|
151
|
-
// email: true,
|
|
152
|
-
// createdAt: true,
|
|
153
|
-
// updatedAt: true,
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
// Default pagination
|
|
157
|
-
pagination: {
|
|
158
|
-
defaultLimit: 10,
|
|
159
|
-
maxLimit: 100,
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
// Default sorting
|
|
163
|
-
defaultSort: {
|
|
164
|
-
field: 'createdAt',
|
|
165
|
-
order: 'desc' as const,
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
export default ${modelName.camel}QueryOptions;
|
|
170
|
-
`;
|
|
171
|
-
}
|
|
172
|
-
function generateMiddlewareTemplate(options) {
|
|
173
|
-
const { middlewareName } = options;
|
|
174
|
-
if (!middlewareName)
|
|
175
|
-
throw new Error("Middleware name is required for middleware template");
|
|
176
|
-
return `import { Request, Response, NextFunction } from 'express';
|
|
177
|
-
|
|
178
|
-
export const ${middlewareName.camel}Middleware = (
|
|
179
|
-
req: Request,
|
|
180
|
-
res: Response,
|
|
181
|
-
next: NextFunction
|
|
182
|
-
): void => {
|
|
183
|
-
try {
|
|
184
|
-
// Add your middleware logic here
|
|
185
|
-
console.log(\`${middlewareName.pascal} middleware executed for \${req.method} \${req.path}\`);
|
|
186
|
-
|
|
187
|
-
// Continue to next middleware
|
|
188
|
-
next();
|
|
189
|
-
} catch (error) {
|
|
190
|
-
next(error);
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
export default ${middlewareName.camel}Middleware;
|
|
195
|
-
`;
|
|
196
|
-
}
|
|
197
|
-
//# sourceMappingURL=generators.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators.js","sourceRoot":"","sources":["../../../../../src/utils/cli/utils/generators.ts"],"names":[],"mappings":"AAkBA,MAAM,UAAU,gBAAgB,CAC9B,IAAY,EACZ,UAA2B,EAAE;IAE7B,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,YAAY;YACf,OAAO,0BAA0B,CAAC,OAAO,CAAC,CAAC;QAC7C,KAAK,SAAS;YACZ,OAAO,uBAAuB,CAAC,OAAO,CAAC,CAAC;QAC1C,KAAK,QAAQ;YACX,OAAO,sBAAsB,CAAC,OAAO,CAAC,CAAC;QACzC,KAAK,MAAM;YACT,OAAO,0BAA0B,EAAE,CAAC;QACtC,KAAK,OA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,IAAI,KAAK,SAAS,CAAC,KAAK,aAC7C;;UAEQ,SAAS,CAAC,KAAK;;;iBAGR,SAAS,CAAC,KAAK,WAAW,SAAS,CAAC,KAAK;;;OAGnD,SAAS,CAAC,KAAK,yBAClB,SAAS,CAAC,KACZ;;mBAEiB,SAAS,CAAC,KAAK;GAC/B,CAAC;AACJ,CAAC;AAED,SAAS,0BAA0B;IACjC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCN,CAAC;AACJ,CAAC;AAED,SAAS,2BAA2B,CAAC,OAAwB;IAC3D,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAE9B,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAEtE,OAAO,gBAAgB,SAAS,CAAC,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAwDrB,SAAS,CAAC,KAAK;GAC/B,CAAC;AACJ,CAAC;AAED,SAAS,0BAA0B,CAAC,OAAwB;IAC1D,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IAEnC,IAAI,CAAC,cAAc;QACjB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IAEzE,OAAO;;iBAEQ,cAAc,CAAC,KAAK;;;;;;;sBAOf,cAAc,CAAC,MAAM;;;;;;;;;mBASxB,cAAc,CAAC,KAAK;GACpC,CAAC;AACJ,CAAC","sourcesContent":["interface ModelName {\n pascal: string;\n camel: string;\n kebab: string;\n}\n\ninterface MiddlewareName {\n pascal: string;\n camel: string;\n kebab: string;\n}\n\ninterface TemplateOptions {\n modelName?: ModelName;\n middlewareName?: MiddlewareName;\n imports?: Record<string, string>;\n}\n\nexport function generateTemplate(\n type: string,\n options: TemplateOptions = {}\n): string {\n switch (type) {\n case \"controller\":\n return generateControllerTemplate(options);\n case \"service\":\n return generateServiceTemplate(options);\n case \"router\":\n return generateRouterTemplate(options);\n case \"auth\":\n return generateAuthConfigTemplate();\n case \"query\":\n return generateQueryConfigTemplate(options);\n case \"middleware\":\n return generateMiddlewareTemplate(options);\n default:\n throw new Error(`Unknown template type: ${type}`);\n }\n}\n\nfunction generateControllerTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName)\n throw new Error(\"Model name is required for controller template\");\n\n return `import { BaseController } from \"${\n imports?.baseController || \"arkos/controllers\"\n }\";\n \n class ${modelName.pascal}Controller extends BaseController {\n constructor() {\n super(\"${modelName.kebab}\");\n }\n }\n \n const ${modelName.camel}Controller = new ${modelName.pascal}Controller();\n \n export default ${modelName.camel}Controller;\n `;\n}\n\nfunction generateServiceTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName)\n throw new Error(\"Model name is required for service template\");\n\n return `import { BaseService } from \"${\n imports?.baseService || \"arkos/services\"\n }\";\n \n class ${modelName.pascal}Service extends BaseService {\n constructor() {\n super(\"${modelName.kebab}\");\n }\n \n // Add your custom service methods here\n }\n \n const ${modelName.camel}Service = new ${modelName.pascal}Service();\n \n export default ${modelName.camel}Service;\n `;\n}\n\nfunction generateRouterTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName) throw new Error(\"Model name is required for router template\");\n\n return `import { Router } from \"express\";\n import { createRoutes } from \"${imports?.baseRouter || \"arkos\"}\";\n import ${modelName.camel}Controller from \"${\n imports?.controller || `./${modelName.kebab}.controller`\n }\";\n \n const ${modelName.camel}Router = Router();\n \n // Generate CRUD routes automatically\n createRoutes(${modelName.camel}Router, ${modelName.camel}Controller);\n \n // Add custom routes here\n // ${modelName.camel}Router.get('/custom', ${\n modelName.camel\n }Controller.customMethod);\n \n export default ${modelName.camel}Router;\n `;\n}\n\nfunction generateAuthConfigTemplate(): string {\n return `export const authConfig = {\n jwt: {\n secret: process.env.JWT_SECRET || 'your-secret-key',\n expiresIn: process.env.JWT_EXPIRES_IN || '7d',\n refreshExpiresIn: process.env.JWT_REFRESH_EXPIRES_IN || '30d',\n },\n bcrypt: {\n saltRounds: parseInt(process.env.BCRYPT_SALT_ROUNDS || '12'),\n },\n cookie: {\n name: process.env.COOKIE_NAME || 'arkos-token',\n maxAge: parseInt(process.env.COOKIE_MAX_AGE || '604800000'), // 7 days\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'strict' as const,\n },\n rateLimit: {\n windowMs: parseInt(process.env.RATE_LIMIT_WINDOW || '900000'), // 15 minutes\n max: parseInt(process.env.RATE_LIMIT_MAX || '5'), // 5 attempts\n },\n email: {\n verification: {\n required: process.env.EMAIL_VERIFICATION_REQUIRED === 'true',\n expiresIn: process.env.EMAIL_VERIFICATION_EXPIRES_IN || '24h',\n },\n passwordReset: {\n expiresIn: process.env.PASSWORD_RESET_EXPIRES_IN || '1h',\n },\n },\n };\n \n export default authConfig;\n `;\n}\n\nfunction generateQueryConfigTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n\n if (!modelName)\n throw new Error(\"Model name is required for query config template\");\n\n return `export const ${modelName.camel}QueryOptions = {\n // Define searchable fields\n searchFields: [\n // 'name',\n // 'email',\n // 'description',\n ],\n \n // Define filterable fields\n filterFields: [\n // 'status',\n // 'type',\n // 'createdAt',\n ],\n \n // Define sortable fields\n sortFields: [\n 'id',\n 'createdAt',\n 'updatedAt',\n // Add other sortable fields\n ],\n \n // Define relations to include\n include: {\n // relationName: true,\n // relationName: {\n // select: {\n // id: true,\n // name: true,\n // }\n // }\n },\n \n // Define fields to select (if not all)\n select: {\n // id: true,\n // name: true,\n // email: true,\n // createdAt: true,\n // updatedAt: true,\n },\n \n // Default pagination\n pagination: {\n defaultLimit: 10,\n maxLimit: 100,\n },\n \n // Default sorting\n defaultSort: {\n field: 'createdAt',\n order: 'desc' as const,\n },\n };\n \n export default ${modelName.camel}QueryOptions;\n `;\n}\n\nfunction generateMiddlewareTemplate(options: TemplateOptions): string {\n const { middlewareName } = options;\n\n if (!middlewareName)\n throw new Error(\"Middleware name is required for middleware template\");\n\n return `import { Request, Response, NextFunction } from 'express';\n \n export const ${middlewareName.camel}Middleware = (\n req: Request,\n res: Response,\n next: NextFunction\n ): void => {\n try {\n // Add your middleware logic here\n console.log(\\`${middlewareName.pascal} middleware executed for \\${req.method} \\${req.path}\\`);\n \n // Continue to next middleware\n next();\n } catch (error) {\n next(error);\n }\n };\n \n export default ${middlewareName.camel}Middleware;\n `;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../src/utils/cli/utils/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,CAAC;AA2BpB,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACnD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,OAAO,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// src/utils/cli/utils.ts\nimport fs from \"fs\";\nimport path from \"path\";\n\n// export function toPascalCase(str: string): string {\n// return str\n// .replace(/[\\W_]/g, \" \")\n// .replace(/\\s+/g, \" \")\n// .trim()\n// .split(\" \")\n// .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n// .join(\"\");\n// }\n\n// export function toCamelCase(str: string): string {\n// const pascal = toPascalCase(str);\n// return pascal.charAt(0).toLowerCase() + pascal.slice(1);\n// }\n\n// export function toKebabCase(str: string): string {\n// return str\n// .replace(/([a-z])([A-Z])/g, \"$1-$2\")\n// .replace(/[\\W_]/g, \"-\")\n// .replace(/-+/g, \"-\")\n// .replace(/^-|-$/g, \"\")\n// .toLowerCase();\n// }\n\nexport function ensureDirectoryExists(dirPath: string): void {\n if (!fs.existsSync(dirPath)) {\n fs.mkdirSync(dirPath, { recursive: true });\n }\n}\n\nexport function fileExists(filePath: string): boolean {\n return fs.existsSync(filePath);\n}\n\n// export function getProjectType(): \"typescript\" | \"javascript\" {\n// const tsConfigExists = fileExists(path.join(process.cwd(), \"tsconfig.json\"));\n// const packageJson = path.join(process.cwd(), \"package.json\");\n\n// if (tsConfigExists) return \"typescript\";\n\n// if (fileExists(packageJson)) {\n// try {\n// const pkg = JSON.parse(fs.readFileSync(packageJson, \"utf8\"));\n// if (pkg.devDependencies?.typescript || pkg.dependencies?.typescript) {\n// return \"typescript\";\n// }\n// } catch {\n// // ignore\n// }\n// }\n\n// return \"javascript\";\n// }\n"]}
|
|
File without changes
|