lapeh 2.4.12 → 2.6.2
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 +669 -942
- package/dist/generated/prisma/internal/prismaNamespace.d.ts +21 -16
- package/dist/generated/prisma/internal/prismaNamespace.d.ts.map +1 -1
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts +3 -3
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts.map +1 -1
- package/dist/lib/bootstrap.d.ts.map +1 -1
- package/dist/lib/bootstrap.js +34 -11
- package/dist/lib/core/database.d.ts.map +1 -1
- package/dist/lib/core/database.js +7 -1
- package/dist/lib/utils/response.d.ts +1 -1
- package/dist/lib/utils/response.d.ts.map +1 -1
- package/dist/src/config/app.d.ts +10 -0
- package/dist/src/config/app.d.ts.map +1 -0
- package/dist/src/config/app.js +12 -0
- package/dist/src/config/cors.d.ts +6 -0
- package/dist/src/config/cors.d.ts.map +1 -0
- package/dist/src/config/cors.js +8 -0
- package/dist/src/modules/Auth/auth.controller.d.ts +11 -0
- package/dist/src/modules/Auth/auth.controller.d.ts.map +1 -0
- package/dist/src/modules/Auth/auth.controller.js +414 -0
- package/dist/src/modules/Pets/pets.controller.d.ts +7 -0
- package/dist/src/modules/Pets/pets.controller.d.ts.map +1 -0
- package/dist/src/modules/Pets/pets.controller.js +163 -0
- package/dist/src/modules/Rbac/rbac.controller.d.ts +16 -0
- package/dist/src/modules/Rbac/rbac.controller.d.ts.map +1 -0
- package/dist/src/modules/Rbac/rbac.controller.js +437 -0
- package/dist/src/routes/auth.js +9 -9
- package/dist/src/routes/pets.js +1 -1
- package/dist/src/routes/rbac.js +15 -15
- package/lib/bootstrap.ts +34 -13
- package/lib/core/database.ts +7 -1
- package/lib/utils/response.ts +4 -4
- package/package.json +4 -5
- package/prisma/base.prisma.template +0 -1
- package/prisma/schema.prisma +0 -1
- package/prisma.config.ts +14 -0
- package/scripts/compile-schema.js +28 -10
- package/scripts/make-module.js +100 -158
- package/src/config/app.ts +9 -0
- package/src/config/cors.ts +5 -0
- package/src/routes/auth.ts +1 -1
- package/src/routes/pets.ts +1 -1
- package/src/routes/rbac.ts +1 -1
- package/storage/logs/.0337f5062fe676994d1dc340156e089444e3d6e0-audit.json +5 -0
- package/storage/logs/lapeh-2025-12-29.log +94 -0
- package/scripts/make-controller.js +0 -205
- package/scripts/make-model.js +0 -42
- /package/src/{controllers/authController.ts → modules/Auth/auth.controller.ts} +0 -0
- /package/src/{models/core.prisma → modules/Auth/auth.prisma} +0 -0
- /package/src/{controllers/petController.ts → modules/Pets/pets.controller.ts} +0 -0
- /package/src/{models → modules/Pets}/pets.prisma +0 -0
- /package/src/{controllers/rbacController.ts → modules/Rbac/rbac.controller.ts} +0 -0
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const args = process.argv.slice(2);
|
|
5
|
-
const controllerName = args[0];
|
|
6
|
-
const isResource = args.includes('-r') || args.includes('--resource');
|
|
7
|
-
|
|
8
|
-
if (!controllerName || controllerName.startsWith('-')) {
|
|
9
|
-
console.error('❌ Please specify the controller name.');
|
|
10
|
-
console.error(' Usage: npm run make:controller <ControllerName> [-r]');
|
|
11
|
-
console.error(' Example: npm run make:controller TestController -r');
|
|
12
|
-
process.exit(1);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const controllersDir = path.join(__dirname, '..', 'src', 'controllers');
|
|
16
|
-
|
|
17
|
-
// Ensure controllers directory exists
|
|
18
|
-
if (!fs.existsSync(controllersDir)) {
|
|
19
|
-
fs.mkdirSync(controllersDir, { recursive: true });
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let fileName = controllerName;
|
|
23
|
-
if (!fileName.endsWith('.ts')) {
|
|
24
|
-
fileName += '.ts';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Capitalize first letter if convention is needed, but usually users provide PascalCase
|
|
28
|
-
// We will just use what user provided but ensure .ts extension
|
|
29
|
-
const filePath = path.join(controllersDir, fileName);
|
|
30
|
-
|
|
31
|
-
if (fs.existsSync(filePath)) {
|
|
32
|
-
console.error(`❌ Controller ${fileName} already exists at ${filePath}`);
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let content = '';
|
|
37
|
-
|
|
38
|
-
if (isResource) {
|
|
39
|
-
content = `import { Request, Response } from "express";
|
|
40
|
-
import { prisma } from "../core/database";
|
|
41
|
-
import { sendSuccess, sendError } from "../utils/response";
|
|
42
|
-
import { getPagination, buildPaginationMeta } from "../utils/pagination";
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Display a listing of the resource.
|
|
46
|
-
*/
|
|
47
|
-
export async function index(req: Request, res: Response) {
|
|
48
|
-
const { page, perPage, skip, take } = getPagination(req.query);
|
|
49
|
-
|
|
50
|
-
// TODO: Add search logic
|
|
51
|
-
const where: any = {};
|
|
52
|
-
|
|
53
|
-
// TODO: Replace 'model' with your actual model name
|
|
54
|
-
/*
|
|
55
|
-
const [data, total] = await Promise.all([
|
|
56
|
-
prisma.model.findMany({
|
|
57
|
-
where,
|
|
58
|
-
skip,
|
|
59
|
-
take,
|
|
60
|
-
orderBy: { created_at: "desc" },
|
|
61
|
-
}),
|
|
62
|
-
prisma.model.count({ where }),
|
|
63
|
-
]);
|
|
64
|
-
|
|
65
|
-
const serialized = data.map((item: any) => ({
|
|
66
|
-
...item,
|
|
67
|
-
id: item.id.toString(),
|
|
68
|
-
}));
|
|
69
|
-
|
|
70
|
-
const meta = buildPaginationMeta(page, perPage, total);
|
|
71
|
-
|
|
72
|
-
sendSuccess(res, 200, "Data retrieved successfully", {
|
|
73
|
-
data: serialized,
|
|
74
|
-
meta,
|
|
75
|
-
});
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
sendSuccess(res, 200, "Index method", { message: "Implement me" });
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Display the specified resource.
|
|
83
|
-
*/
|
|
84
|
-
export async function show(req: Request, res: Response) {
|
|
85
|
-
const { id } = req.params;
|
|
86
|
-
|
|
87
|
-
// TODO: Replace 'model' with your actual model name
|
|
88
|
-
/*
|
|
89
|
-
const item = await prisma.model.findUnique({
|
|
90
|
-
where: { id: BigInt(id) },
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
if (!item) {
|
|
94
|
-
sendError(res, 404, "Data not found");
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
sendSuccess(res, 200, "Data retrieved successfully", {
|
|
99
|
-
...item,
|
|
100
|
-
id: item.id.toString(),
|
|
101
|
-
});
|
|
102
|
-
*/
|
|
103
|
-
sendSuccess(res, 200, "Show method", { id, message: "Implement me" });
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Store a newly created resource in storage.
|
|
108
|
-
*/
|
|
109
|
-
export async function store(req: Request, res: Response) {
|
|
110
|
-
// TODO: Add validation
|
|
111
|
-
// const parsed = createSchema.safeParse(req.body);
|
|
112
|
-
// if (!parsed.success) { ... }
|
|
113
|
-
|
|
114
|
-
// TODO: Replace 'model' with your actual model name
|
|
115
|
-
/*
|
|
116
|
-
const item = await prisma.model.create({
|
|
117
|
-
data: {
|
|
118
|
-
...req.body,
|
|
119
|
-
created_at: new Date(),
|
|
120
|
-
updated_at: new Date(),
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
sendSuccess(res, 201, "Data created successfully", {
|
|
125
|
-
...item,
|
|
126
|
-
id: item.id.toString(),
|
|
127
|
-
});
|
|
128
|
-
*/
|
|
129
|
-
sendSuccess(res, 201, "Store method", { message: "Implement me" });
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Update the specified resource in storage.
|
|
134
|
-
*/
|
|
135
|
-
export async function update(req: Request, res: Response) {
|
|
136
|
-
const { id } = req.params;
|
|
137
|
-
|
|
138
|
-
// TODO: Add validation
|
|
139
|
-
// const parsed = updateSchema.safeParse(req.body);
|
|
140
|
-
|
|
141
|
-
// TODO: Replace 'model' with your actual model name
|
|
142
|
-
/*
|
|
143
|
-
const existing = await prisma.model.findUnique({
|
|
144
|
-
where: { id: BigInt(id) },
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
if (!existing) {
|
|
148
|
-
sendError(res, 404, "Data not found");
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const updated = await prisma.model.update({
|
|
153
|
-
where: { id: BigInt(id) },
|
|
154
|
-
data: {
|
|
155
|
-
...req.body,
|
|
156
|
-
updated_at: new Date(),
|
|
157
|
-
},
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
sendSuccess(res, 200, "Data updated successfully", {
|
|
161
|
-
...updated,
|
|
162
|
-
id: updated.id.toString(),
|
|
163
|
-
});
|
|
164
|
-
*/
|
|
165
|
-
sendSuccess(res, 200, "Update method", { id, message: "Implement me" });
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Remove the specified resource from storage.
|
|
170
|
-
*/
|
|
171
|
-
export async function destroy(req: Request, res: Response) {
|
|
172
|
-
const { id } = req.params;
|
|
173
|
-
|
|
174
|
-
// TODO: Replace 'model' with your actual model name
|
|
175
|
-
/*
|
|
176
|
-
const existing = await prisma.model.findUnique({
|
|
177
|
-
where: { id: BigInt(id) },
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
if (!existing) {
|
|
181
|
-
sendError(res, 404, "Data not found");
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
await prisma.model.delete({
|
|
186
|
-
where: { id: BigInt(id) },
|
|
187
|
-
});
|
|
188
|
-
*/
|
|
189
|
-
|
|
190
|
-
sendSuccess(res, 200, "Data deleted successfully", null);
|
|
191
|
-
}
|
|
192
|
-
`;
|
|
193
|
-
} else {
|
|
194
|
-
content = `import { Request, Response } from "express";
|
|
195
|
-
import { sendSuccess, sendError } from "../utils/response";
|
|
196
|
-
|
|
197
|
-
export async function index(req: Request, res: Response) {
|
|
198
|
-
sendSuccess(res, 200, "Hello from ${controllerName}", null);
|
|
199
|
-
}
|
|
200
|
-
`;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
fs.writeFileSync(filePath, content);
|
|
204
|
-
|
|
205
|
-
console.log(`✅ Controller created: src/controllers/${fileName}`);
|
package/scripts/make-model.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const modelName = process.argv[2];
|
|
5
|
-
|
|
6
|
-
if (!modelName) {
|
|
7
|
-
console.error('❌ Please specify the model name.');
|
|
8
|
-
console.error(' Usage: npm run make:model <ModelName>');
|
|
9
|
-
console.error(' Example: npm run make:model Product');
|
|
10
|
-
process.exit(1);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const PascalCaseName = modelName.charAt(0).toUpperCase() + modelName.slice(1);
|
|
14
|
-
const tableName = modelName.toLowerCase() + 's'; // simple pluralization
|
|
15
|
-
|
|
16
|
-
const modelsDir = path.join(__dirname, '..', 'src', 'models');
|
|
17
|
-
const modelPath = path.join(modelsDir, `${PascalCaseName}.prisma`);
|
|
18
|
-
|
|
19
|
-
if (fs.existsSync(modelPath)) {
|
|
20
|
-
console.error(`❌ Model ${PascalCaseName} already exists at ${modelPath}`);
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Ensure models directory exists
|
|
25
|
-
if (!fs.existsSync(modelsDir)) {
|
|
26
|
-
fs.mkdirSync(modelsDir, { recursive: true });
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const content = `model ${tableName} {
|
|
30
|
-
id BigInt @id @default(autoincrement())
|
|
31
|
-
name String
|
|
32
|
-
createdAt DateTime? @default(now())
|
|
33
|
-
updatedAt DateTime? @updatedAt
|
|
34
|
-
}
|
|
35
|
-
`;
|
|
36
|
-
|
|
37
|
-
fs.writeFileSync(modelPath, content);
|
|
38
|
-
|
|
39
|
-
console.log(`✅ Model created: src/models/${PascalCaseName}.prisma`);
|
|
40
|
-
console.log(`\nNext steps:`);
|
|
41
|
-
console.log(`1. Edit the model file.`);
|
|
42
|
-
console.log(`2. Run 'npm run prisma:migrate' to update the database.`);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|