create-projx 1.7.0 → 1.7.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/README.md +13 -35
- package/dist/{baseline-FHOZNS4D.js → baseline-FKCXQFRD.js} +2 -2
- package/dist/{chunk-IMZKHDIL.js → chunk-N4WD4VN3.js} +15 -18
- package/dist/{chunk-HAT7D4G2.js → chunk-OLPF7FAN.js} +1 -1
- package/dist/index.js +166 -385
- package/dist/{utils-BZGSJ7XZ.js → utils-4G3HNHES.js} +1 -1
- package/package.json +2 -3
- package/src/templates/README.md.ejs +1 -1
- package/src/addons/orms/drizzle/express/src/app.ts +0 -81
- package/src/addons/orms/drizzle/express/src/modules/_base/auto-routes.ts +0 -278
- package/src/addons/orms/drizzle/express/src/modules/_base/index.ts +0 -20
- package/src/addons/orms/drizzle/express/src/server.ts +0 -32
- package/src/addons/orms/drizzle/express/tests/app.test.ts +0 -24
- package/src/addons/orms/drizzle/express/vitest.config.ts +0 -20
- package/src/addons/orms/drizzle/fastify/src/app.ts +0 -90
- package/src/addons/orms/drizzle/fastify/src/modules/_base/auto-routes.ts +0 -268
- package/src/addons/orms/drizzle/fastify/src/modules/_base/index.ts +0 -20
- package/src/addons/orms/drizzle/fastify/tests/modules/app.test.ts +0 -20
- package/src/addons/orms/drizzle/fastify/vitest.config.ts +0 -31
- package/src/addons/orms/drizzle/gen-entity/express-router.ts +0 -21
- package/src/addons/orms/drizzle/gen-entity/express-test.ts +0 -61
- package/src/addons/orms/drizzle/gen-entity/fastify-router.ts +0 -19
- package/src/addons/orms/drizzle/gen-entity/fastify-test.ts +0 -87
- package/src/addons/orms/drizzle/manifest.json +0 -52
- package/src/addons/orms/drizzle/shared/drizzle.config.ts +0 -12
- package/src/addons/orms/drizzle/shared/src/db/client.ts +0 -17
- package/src/addons/orms/drizzle/shared/src/db/schema.ts +0 -14
- package/src/addons/orms/drizzle/shared/src/modules/_base/query-engine.ts +0 -115
- package/src/addons/orms/drizzle/shared/src/modules/_base/registry.ts +0 -15
- package/src/addons/orms/sequelize/express/src/app.ts +0 -82
- package/src/addons/orms/sequelize/express/src/modules/_base/auto-routes.ts +0 -226
- package/src/addons/orms/sequelize/express/src/modules/_base/index.ts +0 -20
- package/src/addons/orms/sequelize/express/src/server.ts +0 -32
- package/src/addons/orms/sequelize/express/tests/app.test.ts +0 -24
- package/src/addons/orms/sequelize/express/vitest.config.ts +0 -20
- package/src/addons/orms/sequelize/fastify/src/app.ts +0 -83
- package/src/addons/orms/sequelize/fastify/src/modules/_base/auto-routes.ts +0 -216
- package/src/addons/orms/sequelize/fastify/src/modules/_base/index.ts +0 -20
- package/src/addons/orms/sequelize/fastify/tests/modules/app.test.ts +0 -20
- package/src/addons/orms/sequelize/fastify/vitest.config.ts +0 -31
- package/src/addons/orms/sequelize/gen-entity/express-router.ts +0 -17
- package/src/addons/orms/sequelize/gen-entity/express-test.ts +0 -65
- package/src/addons/orms/sequelize/gen-entity/fastify-router.ts +0 -19
- package/src/addons/orms/sequelize/gen-entity/fastify-test.ts +0 -89
- package/src/addons/orms/sequelize/gen-entity/model.ts +0 -21
- package/src/addons/orms/sequelize/manifest.json +0 -53
- package/src/addons/orms/sequelize/shared/scripts/db-sync.ts +0 -14
- package/src/addons/orms/sequelize/shared/src/db/client.ts +0 -19
- package/src/addons/orms/sequelize/shared/src/models/index.ts +0 -9
- package/src/addons/orms/sequelize/shared/src/modules/_base/query-engine.ts +0 -101
- package/src/addons/orms/sequelize/shared/src/modules/_base/registry.ts +0 -15
- package/src/addons/orms/typeorm/express/src/app.ts +0 -82
- package/src/addons/orms/typeorm/express/src/modules/_base/auto-routes.ts +0 -249
- package/src/addons/orms/typeorm/express/src/modules/_base/index.ts +0 -19
- package/src/addons/orms/typeorm/express/src/server.ts +0 -43
- package/src/addons/orms/typeorm/express/tests/app.test.ts +0 -24
- package/src/addons/orms/typeorm/express/vitest.config.ts +0 -20
- package/src/addons/orms/typeorm/fastify/src/app.ts +0 -86
- package/src/addons/orms/typeorm/fastify/src/modules/_base/auto-routes.ts +0 -239
- package/src/addons/orms/typeorm/fastify/src/modules/_base/index.ts +0 -19
- package/src/addons/orms/typeorm/fastify/tests/modules/app.test.ts +0 -20
- package/src/addons/orms/typeorm/fastify/vitest.config.ts +0 -31
- package/src/addons/orms/typeorm/gen-entity/entity.ts +0 -21
- package/src/addons/orms/typeorm/gen-entity/express-router.ts +0 -17
- package/src/addons/orms/typeorm/gen-entity/express-test.ts +0 -66
- package/src/addons/orms/typeorm/gen-entity/fastify-router.ts +0 -19
- package/src/addons/orms/typeorm/gen-entity/fastify-test.ts +0 -89
- package/src/addons/orms/typeorm/manifest.json +0 -53
- package/src/addons/orms/typeorm/shared/scripts/db-sync.ts +0 -14
- package/src/addons/orms/typeorm/shared/src/db/data-source.ts +0 -21
- package/src/addons/orms/typeorm/shared/src/entities/index.ts +0 -8
- package/src/addons/orms/typeorm/shared/src/modules/_base/query-engine.ts +0 -94
- package/src/addons/orms/typeorm/shared/src/modules/_base/registry.ts +0 -15
- package/src/addons/orms/typeorm/shared/tsconfig.json +0 -16
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { ILike, type FindOptionsOrder, type FindOptionsWhere } from 'typeorm';
|
|
2
|
-
|
|
3
|
-
export interface ParsedQuery {
|
|
4
|
-
page: number;
|
|
5
|
-
page_size: number;
|
|
6
|
-
order_by?: string;
|
|
7
|
-
search?: string;
|
|
8
|
-
filters: Record<string, string>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const RESERVED = new Set(['page', 'page_size', 'order_by', 'search']);
|
|
12
|
-
|
|
13
|
-
export function parseRawQuery(rawQs: string): ParsedQuery {
|
|
14
|
-
const params = new URLSearchParams(rawQs);
|
|
15
|
-
const page = Math.max(1, Number(params.get('page')) || 1);
|
|
16
|
-
const page_size = Math.min(
|
|
17
|
-
100,
|
|
18
|
-
Math.max(1, Number(params.get('page_size')) || 10),
|
|
19
|
-
);
|
|
20
|
-
const filters: Record<string, string> = {};
|
|
21
|
-
for (const [key, value] of params.entries()) {
|
|
22
|
-
if (RESERVED.has(key)) continue;
|
|
23
|
-
filters[key] = value;
|
|
24
|
-
}
|
|
25
|
-
return {
|
|
26
|
-
page,
|
|
27
|
-
page_size,
|
|
28
|
-
order_by: params.get('order_by') ?? undefined,
|
|
29
|
-
search: params.get('search') ?? undefined,
|
|
30
|
-
filters,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function buildWhere<T>(
|
|
35
|
-
columns: Set<string>,
|
|
36
|
-
filters: Record<string, string>,
|
|
37
|
-
): FindOptionsWhere<T> {
|
|
38
|
-
const where: Record<string, unknown> = {};
|
|
39
|
-
for (const [key, value] of Object.entries(filters)) {
|
|
40
|
-
if (!columns.has(key)) continue;
|
|
41
|
-
where[key] = value;
|
|
42
|
-
}
|
|
43
|
-
return where as FindOptionsWhere<T>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function buildSearchWheres<T>(
|
|
47
|
-
searchableFields: string[],
|
|
48
|
-
term: string | undefined,
|
|
49
|
-
): FindOptionsWhere<T>[] {
|
|
50
|
-
if (!term) return [];
|
|
51
|
-
const trimmed = term.trim();
|
|
52
|
-
if (!trimmed || searchableFields.length === 0) return [];
|
|
53
|
-
const pattern = `%${trimmed}%`;
|
|
54
|
-
return searchableFields.map(
|
|
55
|
-
(field) => ({ [field]: ILike(pattern) }) as FindOptionsWhere<T>,
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function buildOrder<T>(
|
|
60
|
-
columns: Set<string>,
|
|
61
|
-
orderBy: string | undefined,
|
|
62
|
-
): FindOptionsOrder<T> {
|
|
63
|
-
if (!orderBy) return {} as FindOptionsOrder<T>;
|
|
64
|
-
const out: Record<string, 'ASC' | 'DESC'> = {};
|
|
65
|
-
for (const raw of orderBy.split(',')) {
|
|
66
|
-
const term = raw.trim();
|
|
67
|
-
if (!term) continue;
|
|
68
|
-
const descOrder = term.startsWith('-');
|
|
69
|
-
const fieldName = descOrder ? term.slice(1) : term;
|
|
70
|
-
if (!columns.has(fieldName)) continue;
|
|
71
|
-
out[fieldName] = descOrder ? 'DESC' : 'ASC';
|
|
72
|
-
}
|
|
73
|
-
return out as FindOptionsOrder<T>;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface PaginationMeta {
|
|
77
|
-
current_page: number;
|
|
78
|
-
page_size: number;
|
|
79
|
-
total_records: number;
|
|
80
|
-
total_pages: number;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function buildPagination(
|
|
84
|
-
page: number,
|
|
85
|
-
page_size: number,
|
|
86
|
-
total: number,
|
|
87
|
-
): PaginationMeta {
|
|
88
|
-
return {
|
|
89
|
-
current_page: page,
|
|
90
|
-
page_size,
|
|
91
|
-
total_records: total,
|
|
92
|
-
total_pages: Math.max(1, Math.ceil(total / page_size)),
|
|
93
|
-
};
|
|
94
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface RegisteredEntity {
|
|
2
|
-
name: string;
|
|
3
|
-
apiPrefix: string;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
const entityList: RegisteredEntity[] = [];
|
|
7
|
-
|
|
8
|
-
export function registerInRegistry(entry: RegisteredEntity): void {
|
|
9
|
-
if (entityList.some((existing) => existing.name === entry.name)) return;
|
|
10
|
-
entityList.push(entry);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function listEntities(): RegisteredEntity[] {
|
|
14
|
-
return [...entityList].sort((a, b) => a.name.localeCompare(b.name));
|
|
15
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"strict": true,
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
"outDir": "dist",
|
|
10
|
-
"declaration": false,
|
|
11
|
-
"experimentalDecorators": true,
|
|
12
|
-
"emitDecoratorMetadata": true,
|
|
13
|
-
"types": ["node"]
|
|
14
|
-
},
|
|
15
|
-
"include": ["src", "tests", "scripts"]
|
|
16
|
-
}
|