create-velox-app 0.6.26 → 0.6.29
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/CHANGELOG.md +384 -0
- package/GUIDE.md +58 -0
- package/dist/cli.js +74 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/templates/auth.d.ts.map +1 -1
- package/dist/templates/auth.js +9 -8
- package/dist/templates/auth.js.map +1 -1
- package/dist/templates/compiler.js +1 -1
- package/dist/templates/compiler.js.map +1 -1
- package/dist/templates/placeholders.d.ts +25 -2
- package/dist/templates/placeholders.d.ts.map +1 -1
- package/dist/templates/placeholders.js +109 -3
- package/dist/templates/placeholders.js.map +1 -1
- package/dist/templates/rsc.d.ts.map +1 -1
- package/dist/templates/rsc.js +9 -8
- package/dist/templates/rsc.js.map +1 -1
- package/dist/templates/spa.d.ts.map +1 -1
- package/dist/templates/spa.js +9 -8
- package/dist/templates/spa.js.map +1 -1
- package/dist/templates/trpc.d.ts.map +1 -1
- package/dist/templates/trpc.js +9 -8
- package/dist/templates/trpc.js.map +1 -1
- package/dist/templates/types.d.ts.map +1 -1
- package/dist/templates/types.js +1 -2
- package/dist/templates/types.js.map +1 -1
- package/package.json +9 -3
- package/src/templates/source/api/config/database.ts +76 -0
- package/src/templates/source/api/env.auth +1 -4
- package/src/templates/source/api/env.default +1 -4
- package/src/templates/source/api/prisma/schema.auth.prisma +1 -2
- package/src/templates/source/api/prisma/schema.default.prisma +1 -2
- package/src/templates/source/api/procedures/auth.ts +2 -2
- package/src/templates/source/api/procedures/health.ts +2 -2
- package/src/templates/source/api/procedures/users.auth.ts +2 -2
- package/src/templates/source/api/procedures/users.default.ts +2 -8
- package/src/templates/source/root/.cursorrules +3 -3
- package/src/templates/source/root/CLAUDE.auth.md +2 -2
- package/src/templates/source/root/CLAUDE.default.md +2 -2
- package/src/templates/source/rsc/env.example +1 -1
- package/src/templates/source/rsc/prisma/schema.prisma +1 -1
- package/src/templates/source/rsc/src/api/database.ts +76 -0
- package/src/templates/source/rsc/src/api/procedures/health.ts +2 -2
- package/src/templates/source/rsc/src/api/procedures/posts.ts +2 -2
- package/src/templates/source/rsc/src/api/procedures/users.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trpc.d.ts","sourceRoot":"","sources":["../../src/templates/trpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"trpc.d.ts","sourceRoot":"","sources":["../../src/templates/trpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAoF/D,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,YAAY,EAAE,CAmC3E"}
|
package/dist/templates/trpc.js
CHANGED
|
@@ -11,14 +11,15 @@
|
|
|
11
11
|
* - End-to-end type safety without code generation
|
|
12
12
|
*/
|
|
13
13
|
import { compileTemplate } from './compiler.js';
|
|
14
|
-
import { DEFAULT_CONFIG, TRPC_CONFIG } from './placeholders.js';
|
|
14
|
+
import { applyDatabaseDependencies, DEFAULT_CONFIG, TRPC_CONFIG } from './placeholders.js';
|
|
15
15
|
import { generateRootFiles, generateWebBaseFiles, generateWebStyleFiles } from './shared/index.js';
|
|
16
16
|
// ============================================================================
|
|
17
17
|
// API Template Compilation
|
|
18
18
|
// ============================================================================
|
|
19
19
|
function generateApiPackageJson(config) {
|
|
20
20
|
// Reuse default package.json - @veloxts/velox already includes tRPC utilities
|
|
21
|
-
|
|
21
|
+
const content = compileTemplate('api/package.default.json', config);
|
|
22
|
+
return applyDatabaseDependencies(content, config);
|
|
22
23
|
}
|
|
23
24
|
function generateApiTsConfig() {
|
|
24
25
|
return compileTemplate('api/tsconfig.json', DEFAULT_CONFIG);
|
|
@@ -30,9 +31,9 @@ function generateEnvExample(config) {
|
|
|
30
31
|
// Reuse default env - same environment variables
|
|
31
32
|
return compileTemplate('api/env.default', config);
|
|
32
33
|
}
|
|
33
|
-
function generatePrismaSchema() {
|
|
34
|
+
function generatePrismaSchema(config) {
|
|
34
35
|
// Reuse default schema - same data model
|
|
35
|
-
return compileTemplate('api/prisma/schema.default.prisma',
|
|
36
|
+
return compileTemplate('api/prisma/schema.default.prisma', config);
|
|
36
37
|
}
|
|
37
38
|
function generatePrismaConfig() {
|
|
38
39
|
return compileTemplate('api/prisma.config.ts', DEFAULT_CONFIG);
|
|
@@ -50,8 +51,8 @@ function generateIndexTs() {
|
|
|
50
51
|
function generateConfigApp(config) {
|
|
51
52
|
return compileTemplate('api/config/app.ts', config);
|
|
52
53
|
}
|
|
53
|
-
function generateConfigDatabase() {
|
|
54
|
-
return compileTemplate('api/config/database.ts',
|
|
54
|
+
function generateConfigDatabase(config) {
|
|
55
|
+
return compileTemplate('api/config/database.ts', config);
|
|
55
56
|
}
|
|
56
57
|
function generateHealthProcedures() {
|
|
57
58
|
return compileTemplate('api/procedures/health.ts', DEFAULT_CONFIG);
|
|
@@ -85,13 +86,13 @@ export function generateTrpcTemplate(config) {
|
|
|
85
86
|
{ path: 'apps/api/.env.example', content: generateEnvExample(config) },
|
|
86
87
|
{ path: 'apps/api/.env', content: generateEnvExample(config) },
|
|
87
88
|
// Prisma
|
|
88
|
-
{ path: 'apps/api/prisma/schema.prisma', content: generatePrismaSchema() },
|
|
89
|
+
{ path: 'apps/api/prisma/schema.prisma', content: generatePrismaSchema(config) },
|
|
89
90
|
// API Source files
|
|
90
91
|
{ path: 'apps/api/src/router.ts', content: generateRouterTs() },
|
|
91
92
|
{ path: 'apps/api/src/router.types.ts', content: generateRouterTypesTs() },
|
|
92
93
|
{ path: 'apps/api/src/index.ts', content: generateIndexTs() },
|
|
93
94
|
{ path: 'apps/api/src/config/app.ts', content: generateConfigApp(config) },
|
|
94
|
-
{ path: 'apps/api/src/config/database.ts', content: generateConfigDatabase() },
|
|
95
|
+
{ path: 'apps/api/src/config/database.ts', content: generateConfigDatabase(config) },
|
|
95
96
|
{ path: 'apps/api/src/procedures/health.ts', content: generateHealthProcedures() },
|
|
96
97
|
{ path: 'apps/api/src/procedures/users.ts', content: generateUserProcedures() },
|
|
97
98
|
{ path: 'apps/api/src/schemas/user.ts', content: generateUserSchema() },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trpc.js","sourceRoot":"","sources":["../../src/templates/trpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"trpc.js","sourceRoot":"","sources":["../../src/templates/trpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAGnG,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAE/E,SAAS,sBAAsB,CAAC,MAAsB;IACpD,8EAA8E;IAC9E,MAAM,OAAO,GAAG,eAAe,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;IACpE,OAAO,yBAAyB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,mBAAmB;IAC1B,OAAO,eAAe,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,qBAAqB;IAC5B,OAAO,eAAe,CAAC,oBAAoB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AAW,gBAAgB;IAC/B,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;IACxC,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,YAAY,EAAE,CAAC;CACvD;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,YAAY,EAAE,gBAAgB,CAyBpE,CAAC;AAEF;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,gBAAgB,EAAE,CAE1D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,IAAI,YAAY,CAE1E"}
|
package/dist/templates/types.js
CHANGED
|
@@ -34,8 +34,7 @@ export const DATABASE_METADATA = {
|
|
|
34
34
|
postgresql: {
|
|
35
35
|
type: 'postgresql',
|
|
36
36
|
label: 'PostgreSQL',
|
|
37
|
-
hint: '
|
|
38
|
-
disabled: true,
|
|
37
|
+
hint: 'Production-ready, requires running PostgreSQL server',
|
|
39
38
|
},
|
|
40
39
|
mysql: {
|
|
41
40
|
type: 'mysql',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/templates/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgBH;;GAEG;AACH,MAAM,CA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M,CAAC,iBAAiB,CAAC,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,QAAQ,IAAI,iBAAiB,CAAC;AACvC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-velox-app",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.29",
|
|
4
4
|
"description": "Project scaffolder for VeloxTS framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"dist",
|
|
19
19
|
"src/templates/source",
|
|
20
|
-
"README.md"
|
|
20
|
+
"README.md",
|
|
21
|
+
"GUIDE.md",
|
|
22
|
+
"LICENSE",
|
|
23
|
+
"CHANGELOG.md"
|
|
21
24
|
],
|
|
22
25
|
"dependencies": {
|
|
23
26
|
"@clack/prompts": "0.11.0",
|
|
@@ -26,7 +29,8 @@
|
|
|
26
29
|
},
|
|
27
30
|
"devDependencies": {
|
|
28
31
|
"@types/node": "25.0.3",
|
|
29
|
-
"typescript": "5.9.3"
|
|
32
|
+
"typescript": "5.9.3",
|
|
33
|
+
"vitest": "4.0.15"
|
|
30
34
|
},
|
|
31
35
|
"keywords": [
|
|
32
36
|
"velox",
|
|
@@ -53,6 +57,8 @@
|
|
|
53
57
|
"type-check": "tsc --noEmit",
|
|
54
58
|
"check:templates": "tsc -p tsconfig.templates.json --noEmit || true",
|
|
55
59
|
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
60
|
+
"test": "vitest run",
|
|
61
|
+
"test:watch": "vitest",
|
|
56
62
|
"smoke-test": "./scripts/smoke-test.sh"
|
|
57
63
|
}
|
|
58
64
|
}
|
|
@@ -11,14 +11,31 @@
|
|
|
11
11
|
// Runtime imports using createRequire for Node.js v24+ CJS interop
|
|
12
12
|
import { createRequire } from 'node:module';
|
|
13
13
|
|
|
14
|
+
/* @if sqlite */
|
|
14
15
|
// Type imports (erased at runtime, safe for ESM)
|
|
15
16
|
import type { PrismaBetterSqlite3 as PrismaBetterSqlite3Type } from '@prisma/adapter-better-sqlite3';
|
|
17
|
+
/* @endif sqlite */
|
|
18
|
+
/* @if postgresql */
|
|
19
|
+
// Type imports (erased at runtime, safe for ESM)
|
|
20
|
+
import type { PrismaPg as PrismaPgType } from '@prisma/adapter-pg';
|
|
21
|
+
/* @endif postgresql */
|
|
16
22
|
import type { PrismaClient as PrismaClientType } from '@prisma/client';
|
|
23
|
+
import type { Pool as PoolType } from 'pg';
|
|
17
24
|
|
|
18
25
|
const require = createRequire(import.meta.url);
|
|
26
|
+
/* @if sqlite */
|
|
19
27
|
const { PrismaBetterSqlite3 } = require('@prisma/adapter-better-sqlite3') as {
|
|
20
28
|
PrismaBetterSqlite3: typeof PrismaBetterSqlite3Type;
|
|
21
29
|
};
|
|
30
|
+
/* @endif sqlite */
|
|
31
|
+
/* @if postgresql */
|
|
32
|
+
const { PrismaPg } = require('@prisma/adapter-pg') as {
|
|
33
|
+
PrismaPg: typeof PrismaPgType;
|
|
34
|
+
};
|
|
35
|
+
const { Pool } = require('pg') as {
|
|
36
|
+
Pool: typeof PoolType;
|
|
37
|
+
};
|
|
38
|
+
/* @endif postgresql */
|
|
22
39
|
const { PrismaClient } = require('@prisma/client') as {
|
|
23
40
|
PrismaClient: typeof PrismaClientType;
|
|
24
41
|
};
|
|
@@ -27,8 +44,13 @@ declare global {
|
|
|
27
44
|
// Allow global `var` declarations for hot reload in development
|
|
28
45
|
// eslint-disable-next-line no-var
|
|
29
46
|
var __db: PrismaClient | undefined;
|
|
47
|
+
/* @if postgresql */
|
|
48
|
+
// eslint-disable-next-line no-var
|
|
49
|
+
var __pool: InstanceType<typeof PoolType> | undefined;
|
|
50
|
+
/* @endif postgresql */
|
|
30
51
|
}
|
|
31
52
|
|
|
53
|
+
/* @if sqlite */
|
|
32
54
|
/**
|
|
33
55
|
* Create a Prisma client instance using the SQLite adapter.
|
|
34
56
|
* Validates that DATABASE_URL is set before creating the client.
|
|
@@ -47,10 +69,64 @@ function createPrismaClient(): PrismaClient {
|
|
|
47
69
|
const adapter = new PrismaBetterSqlite3({ url: databaseUrl });
|
|
48
70
|
return new PrismaClient({ adapter });
|
|
49
71
|
}
|
|
72
|
+
/* @endif sqlite */
|
|
73
|
+
/* @if postgresql */
|
|
74
|
+
/**
|
|
75
|
+
* Create a PostgreSQL connection pool.
|
|
76
|
+
* Uses connection pooling for better performance in production.
|
|
77
|
+
*/
|
|
78
|
+
function createPool(): InstanceType<typeof PoolType> {
|
|
79
|
+
const databaseUrl = process.env.DATABASE_URL;
|
|
50
80
|
|
|
81
|
+
if (!databaseUrl) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
'[VeloxTS] DATABASE_URL environment variable is not set. ' +
|
|
84
|
+
'Ensure .env file exists with DATABASE_URL defined.'
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return new Pool({
|
|
89
|
+
connectionString: databaseUrl,
|
|
90
|
+
max: 10, // Maximum connections in pool
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Create a Prisma client instance using the PostgreSQL adapter.
|
|
96
|
+
* Uses connection pooling for efficient database access.
|
|
97
|
+
*/
|
|
98
|
+
function createPrismaClient(pool: InstanceType<typeof PoolType>): PrismaClient {
|
|
99
|
+
// Prisma 7 requires driver adapters for direct connections
|
|
100
|
+
const adapter = new PrismaPg(pool);
|
|
101
|
+
return new PrismaClient({ adapter });
|
|
102
|
+
}
|
|
103
|
+
/* @endif postgresql */
|
|
104
|
+
|
|
105
|
+
/* @if sqlite */
|
|
51
106
|
// Use global singleton for hot reload in development
|
|
52
107
|
export const db = globalThis.__db ?? createPrismaClient();
|
|
53
108
|
|
|
54
109
|
if (process.env.NODE_ENV !== 'production') {
|
|
55
110
|
globalThis.__db = db;
|
|
56
111
|
}
|
|
112
|
+
/* @endif sqlite */
|
|
113
|
+
/* @if postgresql */
|
|
114
|
+
// Use global singletons for hot reload in development
|
|
115
|
+
const pool = globalThis.__pool ?? createPool();
|
|
116
|
+
export const db = globalThis.__db ?? createPrismaClient(pool);
|
|
117
|
+
|
|
118
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
119
|
+
globalThis.__pool = pool;
|
|
120
|
+
globalThis.__db = db;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Graceful shutdown - close pool on process exit
|
|
124
|
+
const shutdown = async () => {
|
|
125
|
+
await db.$disconnect();
|
|
126
|
+
await pool.end();
|
|
127
|
+
process.exit(0);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
process.on('SIGTERM', shutdown);
|
|
131
|
+
process.on('SIGINT', shutdown);
|
|
132
|
+
/* @endif postgresql */
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Prisma Schema
|
|
2
2
|
//
|
|
3
3
|
// This schema defines the database structure with authentication support.
|
|
4
|
-
// Using SQLite for simplicity - easily swap to PostgreSQL for production.
|
|
5
4
|
|
|
6
5
|
generator client {
|
|
7
6
|
provider = "prisma-client-js"
|
|
@@ -10,7 +9,7 @@ generator client {
|
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
datasource db {
|
|
13
|
-
provider = "
|
|
12
|
+
provider = "__DATABASE_PROVIDER__"
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
// ============================================================================
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Prisma Schema
|
|
2
2
|
//
|
|
3
3
|
// This schema defines the database structure.
|
|
4
|
-
// Using SQLite for simplicity - easily swap to PostgreSQL for production.
|
|
5
4
|
|
|
6
5
|
generator client {
|
|
7
6
|
provider = "prisma-client-js"
|
|
@@ -10,7 +9,7 @@ generator client {
|
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
datasource db {
|
|
13
|
-
provider = "
|
|
12
|
+
provider = "__DATABASE_PROVIDER__"
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
// ============================================================================
|
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
AuthError,
|
|
16
16
|
authenticated,
|
|
17
17
|
createAuthRateLimiter,
|
|
18
|
-
defineProcedures,
|
|
19
18
|
hashPassword,
|
|
20
19
|
jwtManager,
|
|
21
20
|
procedure,
|
|
21
|
+
procedures,
|
|
22
22
|
verifyPassword,
|
|
23
23
|
} from '@veloxts/velox';
|
|
24
24
|
|
|
@@ -104,7 +104,7 @@ const DUMMY_HASH = '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.uy7dPSSXB5G6Uy
|
|
|
104
104
|
// Auth Procedures
|
|
105
105
|
// ============================================================================
|
|
106
106
|
|
|
107
|
-
export const authProcedures =
|
|
107
|
+
export const authProcedures = procedures('auth', {
|
|
108
108
|
createAccount: procedure()
|
|
109
109
|
.rest({ method: 'POST', path: '/auth/register' })
|
|
110
110
|
.use(rateLimiter.register())
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Health Check Procedures
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { procedure, procedures, VELOX_VERSION } from '@veloxts/velox';
|
|
6
6
|
|
|
7
7
|
import { HealthResponse } from '../schemas/health.js';
|
|
8
8
|
|
|
9
|
-
export const healthProcedures =
|
|
9
|
+
export const healthProcedures = procedures('health', {
|
|
10
10
|
getHealth: procedure()
|
|
11
11
|
.rest({ method: 'GET', path: '/health' })
|
|
12
12
|
.output(HealthResponse)
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
import {
|
|
12
12
|
AuthError,
|
|
13
13
|
authenticated,
|
|
14
|
-
defineProcedures,
|
|
15
14
|
GuardError,
|
|
16
15
|
hasRole,
|
|
17
16
|
NotFoundError,
|
|
18
17
|
paginationInputSchema,
|
|
19
18
|
procedure,
|
|
19
|
+
procedures,
|
|
20
20
|
z,
|
|
21
21
|
} from '@veloxts/velox';
|
|
22
22
|
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
// User Procedures
|
|
32
32
|
// ============================================================================
|
|
33
33
|
|
|
34
|
-
export const userProcedures =
|
|
34
|
+
export const userProcedures = procedures('users', {
|
|
35
35
|
getUser: procedure()
|
|
36
36
|
.input(z.object({ id: z.string().uuid() }))
|
|
37
37
|
.output(UserSchema)
|
|
@@ -7,13 +7,7 @@
|
|
|
7
7
|
* - Output schema automatically serializes Date → string via withTimestamps()
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
defineProcedures,
|
|
12
|
-
NotFoundError,
|
|
13
|
-
paginationInputSchema,
|
|
14
|
-
procedure,
|
|
15
|
-
z,
|
|
16
|
-
} from '@veloxts/velox';
|
|
10
|
+
import { NotFoundError, paginationInputSchema, procedure, procedures, z } from '@veloxts/velox';
|
|
17
11
|
|
|
18
12
|
import {
|
|
19
13
|
CreateUserInput,
|
|
@@ -22,7 +16,7 @@ import {
|
|
|
22
16
|
UserSchema,
|
|
23
17
|
} from '../schemas/user.js';
|
|
24
18
|
|
|
25
|
-
export const userProcedures =
|
|
19
|
+
export const userProcedures = procedures('users', {
|
|
26
20
|
getUser: procedure()
|
|
27
21
|
.input(z.object({ id: z.string().uuid() }))
|
|
28
22
|
.output(UserSchema)
|
|
@@ -53,9 +53,9 @@ CRITICAL - Never violate these rules:
|
|
|
53
53
|
### Procedure Pattern
|
|
54
54
|
|
|
55
55
|
```typescript
|
|
56
|
-
import {
|
|
56
|
+
import { procedure, procedures, z } from '@veloxts/velox';
|
|
57
57
|
|
|
58
|
-
export const entityProcedures =
|
|
58
|
+
export const entityProcedures = procedures('entities', {
|
|
59
59
|
getEntity: procedure()
|
|
60
60
|
.input(z.object({ id: z.string().uuid() }))
|
|
61
61
|
.output(EntitySchema)
|
|
@@ -144,7 +144,7 @@ __RUN_CMD__ db:studio # Open Prisma Studio
|
|
|
144
144
|
|
|
145
145
|
```typescript
|
|
146
146
|
// VeloxTS imports (use umbrella package)
|
|
147
|
-
import {
|
|
147
|
+
import { procedure, procedures, z } from '@veloxts/velox';
|
|
148
148
|
/* @if auth */
|
|
149
149
|
import { authenticated, hasRole } from '@veloxts/auth';
|
|
150
150
|
/* @endif auth */
|
|
@@ -46,9 +46,9 @@ apps/
|
|
|
46
46
|
|
|
47
47
|
```typescript
|
|
48
48
|
// apps/api/src/procedures/posts.ts
|
|
49
|
-
import {
|
|
49
|
+
import { procedure, procedures, z } from '@veloxts/velox';
|
|
50
50
|
|
|
51
|
-
export const postProcedures =
|
|
51
|
+
export const postProcedures = procedures('posts', {
|
|
52
52
|
// GET /api/posts/:id
|
|
53
53
|
getPost: procedure()
|
|
54
54
|
.input(z.object({ id: z.string().uuid() }))
|
|
@@ -45,9 +45,9 @@ apps/
|
|
|
45
45
|
|
|
46
46
|
```typescript
|
|
47
47
|
// apps/api/src/procedures/posts.ts
|
|
48
|
-
import {
|
|
48
|
+
import { procedure, procedures, z } from '@veloxts/velox';
|
|
49
49
|
|
|
50
|
-
export const postProcedures =
|
|
50
|
+
export const postProcedures = procedures('posts', {
|
|
51
51
|
// GET /api/posts/:id
|
|
52
52
|
getPost: procedure()
|
|
53
53
|
.input(z.object({ id: z.string().uuid() }))
|
|
@@ -13,16 +13,33 @@ import { createRequire } from 'node:module';
|
|
|
13
13
|
import { dirname, resolve } from 'node:path';
|
|
14
14
|
import { fileURLToPath } from 'node:url';
|
|
15
15
|
|
|
16
|
+
/* @if sqlite */
|
|
16
17
|
// Type imports (erased at runtime, safe for ESM)
|
|
17
18
|
import type { PrismaBetterSqlite3 as PrismaBetterSqlite3Type } from '@prisma/adapter-better-sqlite3';
|
|
19
|
+
/* @endif sqlite */
|
|
20
|
+
/* @if postgresql */
|
|
21
|
+
// Type imports (erased at runtime, safe for ESM)
|
|
22
|
+
import type { PrismaPg as PrismaPgType } from '@prisma/adapter-pg';
|
|
23
|
+
/* @endif postgresql */
|
|
18
24
|
import type { PrismaClient as PrismaClientType } from '@prisma/client';
|
|
19
25
|
import dotenv from 'dotenv';
|
|
26
|
+
import type { Pool as PoolType } from 'pg';
|
|
20
27
|
|
|
21
28
|
// Runtime imports using createRequire for Node.js v24+ CJS interop
|
|
22
29
|
const require = createRequire(import.meta.url);
|
|
30
|
+
/* @if sqlite */
|
|
23
31
|
const { PrismaBetterSqlite3 } = require('@prisma/adapter-better-sqlite3') as {
|
|
24
32
|
PrismaBetterSqlite3: typeof PrismaBetterSqlite3Type;
|
|
25
33
|
};
|
|
34
|
+
/* @endif sqlite */
|
|
35
|
+
/* @if postgresql */
|
|
36
|
+
const { PrismaPg } = require('@prisma/adapter-pg') as {
|
|
37
|
+
PrismaPg: typeof PrismaPgType;
|
|
38
|
+
};
|
|
39
|
+
const { Pool } = require('pg') as {
|
|
40
|
+
Pool: typeof PoolType;
|
|
41
|
+
};
|
|
42
|
+
/* @endif postgresql */
|
|
26
43
|
const { PrismaClient } = require('@prisma/client') as {
|
|
27
44
|
PrismaClient: typeof PrismaClientType;
|
|
28
45
|
};
|
|
@@ -39,8 +56,13 @@ declare global {
|
|
|
39
56
|
// Allow global `var` declarations for hot reload in development
|
|
40
57
|
// eslint-disable-next-line no-var
|
|
41
58
|
var __db: PrismaClient | undefined;
|
|
59
|
+
/* @if postgresql */
|
|
60
|
+
// eslint-disable-next-line no-var
|
|
61
|
+
var __pool: InstanceType<typeof PoolType> | undefined;
|
|
62
|
+
/* @endif postgresql */
|
|
42
63
|
}
|
|
43
64
|
|
|
65
|
+
/* @if sqlite */
|
|
44
66
|
/**
|
|
45
67
|
* Create a Prisma client instance using the SQLite adapter.
|
|
46
68
|
*
|
|
@@ -63,10 +85,64 @@ function createPrismaClient(): PrismaClient {
|
|
|
63
85
|
const adapter = new PrismaBetterSqlite3({ url: databaseUrl });
|
|
64
86
|
return new PrismaClient({ adapter });
|
|
65
87
|
}
|
|
88
|
+
/* @endif sqlite */
|
|
89
|
+
/* @if postgresql */
|
|
90
|
+
/**
|
|
91
|
+
* Create a PostgreSQL connection pool.
|
|
92
|
+
* Uses connection pooling for better performance in production.
|
|
93
|
+
*/
|
|
94
|
+
function createPool(): InstanceType<typeof PoolType> {
|
|
95
|
+
const databaseUrl = process.env.DATABASE_URL;
|
|
66
96
|
|
|
97
|
+
if (!databaseUrl) {
|
|
98
|
+
throw new Error(
|
|
99
|
+
'[VeloxTS] DATABASE_URL environment variable is not set. ' +
|
|
100
|
+
'Ensure .env file exists in project root with DATABASE_URL defined.'
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return new Pool({
|
|
105
|
+
connectionString: databaseUrl,
|
|
106
|
+
max: 10, // Maximum connections in pool
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Create a Prisma client instance using the PostgreSQL adapter.
|
|
112
|
+
* Uses connection pooling for efficient database access.
|
|
113
|
+
*/
|
|
114
|
+
function createPrismaClient(pool: InstanceType<typeof PoolType>): PrismaClient {
|
|
115
|
+
// Prisma 7 requires driver adapters for direct connections
|
|
116
|
+
const adapter = new PrismaPg(pool);
|
|
117
|
+
return new PrismaClient({ adapter });
|
|
118
|
+
}
|
|
119
|
+
/* @endif postgresql */
|
|
120
|
+
|
|
121
|
+
/* @if sqlite */
|
|
67
122
|
// Use global singleton for hot reload in development
|
|
68
123
|
export const db = globalThis.__db ?? createPrismaClient();
|
|
69
124
|
|
|
70
125
|
if (process.env.NODE_ENV !== 'production') {
|
|
71
126
|
globalThis.__db = db;
|
|
72
127
|
}
|
|
128
|
+
/* @endif sqlite */
|
|
129
|
+
/* @if postgresql */
|
|
130
|
+
// Use global singletons for hot reload in development
|
|
131
|
+
const pool = globalThis.__pool ?? createPool();
|
|
132
|
+
export const db = globalThis.__db ?? createPrismaClient(pool);
|
|
133
|
+
|
|
134
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
135
|
+
globalThis.__pool = pool;
|
|
136
|
+
globalThis.__db = db;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Graceful shutdown - close pool on process exit
|
|
140
|
+
const shutdown = async () => {
|
|
141
|
+
await db.$disconnect();
|
|
142
|
+
await pool.end();
|
|
143
|
+
process.exit(0);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
process.on('SIGTERM', shutdown);
|
|
147
|
+
process.on('SIGINT', shutdown);
|
|
148
|
+
/* @endif postgresql */
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* API endpoints for application health monitoring.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { procedure, procedures } from '@veloxts/router';
|
|
8
8
|
|
|
9
9
|
import { db } from '../database.js';
|
|
10
10
|
|
|
11
|
-
export const healthProcedures =
|
|
11
|
+
export const healthProcedures = procedures('health', {
|
|
12
12
|
/**
|
|
13
13
|
* Basic health check
|
|
14
14
|
* GET /api/health
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Routes: /api/users/:userId/posts/*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { procedure, procedures } from '@veloxts/router';
|
|
10
10
|
import { z } from 'zod';
|
|
11
11
|
|
|
12
12
|
import { db } from '../database.js';
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
UpdatePostSchema,
|
|
18
18
|
} from '../schemas/post.js';
|
|
19
19
|
|
|
20
|
-
export const postProcedures =
|
|
20
|
+
export const postProcedures = procedures('posts', {
|
|
21
21
|
/**
|
|
22
22
|
* List all posts for a user
|
|
23
23
|
* GET /api/users/:userId/posts
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
* Uses direct db import for proper PrismaClient typing.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { procedure, procedures } from '@veloxts/router';
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
|
|
11
11
|
import { db } from '../database.js';
|
|
12
12
|
import { CreateUserSchema, UpdateUserSchema, UserSchema } from '../schemas/user.js';
|
|
13
13
|
|
|
14
|
-
export const userProcedures =
|
|
14
|
+
export const userProcedures = procedures('users', {
|
|
15
15
|
/**
|
|
16
16
|
* List all users
|
|
17
17
|
* GET /api/users
|