create-velox-app 0.4.3 → 0.4.4

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.
Files changed (174) hide show
  1. package/dist/cli.js +0 -0
  2. package/dist/index.js +21 -14
  3. package/dist/index.js.map +1 -1
  4. package/dist/templates/auth.d.ts +6 -3
  5. package/dist/templates/auth.d.ts.map +1 -1
  6. package/dist/templates/auth.js +56 -1112
  7. package/dist/templates/auth.js.map +1 -1
  8. package/dist/templates/compiler.d.ts +68 -0
  9. package/dist/templates/compiler.d.ts.map +1 -0
  10. package/dist/templates/compiler.js +149 -0
  11. package/dist/templates/compiler.js.map +1 -0
  12. package/dist/templates/default.d.ts +5 -2
  13. package/dist/templates/default.d.ts.map +1 -1
  14. package/dist/templates/default.js +51 -509
  15. package/dist/templates/default.js.map +1 -1
  16. package/dist/templates/index.d.ts.map +1 -1
  17. package/dist/templates/index.js +19 -10
  18. package/dist/templates/index.js.map +1 -1
  19. package/dist/templates/placeholders.d.ts +70 -0
  20. package/dist/templates/placeholders.d.ts.map +1 -0
  21. package/dist/templates/placeholders.js +145 -0
  22. package/dist/templates/placeholders.js.map +1 -0
  23. package/dist/templates/shared/index.d.ts +9 -0
  24. package/dist/templates/shared/index.d.ts.map +1 -0
  25. package/dist/templates/shared/index.js +9 -0
  26. package/dist/templates/shared/index.js.map +1 -0
  27. package/dist/templates/shared/root.d.ts +14 -0
  28. package/dist/templates/shared/root.d.ts.map +1 -0
  29. package/dist/templates/shared/root.js +43 -0
  30. package/dist/templates/shared/root.js.map +1 -0
  31. package/dist/templates/shared/web-base.d.ts +18 -0
  32. package/dist/templates/shared/web-base.d.ts.map +1 -0
  33. package/dist/templates/shared/web-base.js +63 -0
  34. package/dist/templates/shared/web-base.js.map +1 -0
  35. package/dist/templates/shared/web-styles.d.ts +10 -0
  36. package/dist/templates/shared/web-styles.d.ts.map +1 -0
  37. package/dist/templates/shared/web-styles.js +26 -0
  38. package/dist/templates/shared/web-styles.js.map +1 -0
  39. package/dist/templates/shared.d.ts +2 -13
  40. package/dist/templates/shared.d.ts.map +1 -1
  41. package/dist/templates/shared.js +2 -289
  42. package/dist/templates/shared.js.map +1 -1
  43. package/dist/templates/source/api/config/app.d.ts +13 -0
  44. package/dist/templates/source/api/config/app.d.ts.map +1 -0
  45. package/dist/templates/source/api/config/app.js +14 -0
  46. package/dist/templates/source/api/config/app.js.map +1 -0
  47. package/dist/templates/source/api/config/auth.d.ts +34 -0
  48. package/dist/templates/source/api/config/auth.d.ts.map +1 -0
  49. package/dist/templates/source/api/config/auth.js +165 -0
  50. package/dist/templates/source/api/config/auth.js.map +1 -0
  51. package/dist/templates/source/api/config/index.auth.d.ts +6 -0
  52. package/dist/templates/source/api/config/index.auth.d.ts.map +1 -0
  53. package/dist/templates/source/api/config/index.auth.js +6 -0
  54. package/dist/templates/source/api/config/index.auth.js.map +1 -0
  55. package/dist/templates/source/api/config/index.default.d.ts +5 -0
  56. package/dist/templates/source/api/config/index.default.d.ts.map +1 -0
  57. package/dist/templates/source/api/config/index.default.js +5 -0
  58. package/dist/templates/source/api/config/index.default.js.map +1 -0
  59. package/dist/templates/source/api/database/index.d.ts +9 -0
  60. package/dist/templates/source/api/database/index.d.ts.map +1 -0
  61. package/dist/templates/source/api/database/index.js +18 -0
  62. package/dist/templates/source/api/database/index.js.map +1 -0
  63. package/dist/templates/source/api/index.auth.d.ts +5 -0
  64. package/dist/templates/source/api/index.auth.d.ts.map +1 -0
  65. package/dist/templates/source/api/index.auth.js +59 -0
  66. package/dist/templates/source/api/index.auth.js.map +1 -0
  67. package/dist/templates/source/api/index.default.d.ts +5 -0
  68. package/dist/templates/source/api/index.default.d.ts.map +1 -0
  69. package/dist/templates/source/api/index.default.js +56 -0
  70. package/dist/templates/source/api/index.default.js.map +1 -0
  71. package/dist/templates/source/api/prisma.config.d.ts +9 -0
  72. package/dist/templates/source/api/prisma.config.d.ts.map +1 -0
  73. package/dist/templates/source/api/prisma.config.js +15 -0
  74. package/dist/templates/source/api/prisma.config.js.map +1 -0
  75. package/dist/templates/source/api/procedures/auth.d.ts +14 -0
  76. package/dist/templates/source/api/procedures/auth.d.ts.map +1 -0
  77. package/dist/templates/source/api/procedures/auth.js +221 -0
  78. package/dist/templates/source/api/procedures/auth.js.map +1 -0
  79. package/dist/templates/source/api/procedures/health.d.ts +5 -0
  80. package/dist/templates/source/api/procedures/health.d.ts.map +1 -0
  81. package/dist/templates/source/api/procedures/health.js +21 -0
  82. package/dist/templates/source/api/procedures/health.js.map +1 -0
  83. package/dist/templates/source/api/procedures/index.auth.d.ts +7 -0
  84. package/dist/templates/source/api/procedures/index.auth.d.ts.map +1 -0
  85. package/dist/templates/source/api/procedures/index.auth.js +7 -0
  86. package/dist/templates/source/api/procedures/index.auth.js.map +1 -0
  87. package/dist/templates/source/api/procedures/index.default.d.ts +6 -0
  88. package/dist/templates/source/api/procedures/index.default.d.ts.map +1 -0
  89. package/dist/templates/source/api/procedures/index.default.js +6 -0
  90. package/dist/templates/source/api/procedures/index.default.js.map +1 -0
  91. package/dist/templates/source/api/procedures/users.auth.d.ts +7 -0
  92. package/dist/templates/source/api/procedures/users.auth.d.ts.map +1 -0
  93. package/dist/templates/source/api/procedures/users.auth.js +111 -0
  94. package/dist/templates/source/api/procedures/users.auth.js.map +1 -0
  95. package/dist/templates/source/api/procedures/users.default.d.ts +5 -0
  96. package/dist/templates/source/api/procedures/users.default.d.ts.map +1 -0
  97. package/dist/templates/source/api/procedures/users.default.js +86 -0
  98. package/dist/templates/source/api/procedures/users.default.js.map +1 -0
  99. package/dist/templates/source/api/schemas/index.d.ts +5 -0
  100. package/dist/templates/source/api/schemas/index.d.ts.map +1 -0
  101. package/dist/templates/source/api/schemas/index.js +5 -0
  102. package/dist/templates/source/api/schemas/index.js.map +1 -0
  103. package/dist/templates/source/api/schemas/user.d.ts +11 -0
  104. package/dist/templates/source/api/schemas/user.d.ts.map +1 -0
  105. package/dist/templates/source/api/schemas/user.js +20 -0
  106. package/dist/templates/source/api/schemas/user.js.map +1 -0
  107. package/dist/templates/source/api/tsup.config.d.ts +3 -0
  108. package/dist/templates/source/api/tsup.config.d.ts.map +1 -0
  109. package/dist/templates/source/api/tsup.config.js +10 -0
  110. package/dist/templates/source/api/tsup.config.js.map +1 -0
  111. package/dist/templates/source/web/main.d.ts +9 -0
  112. package/dist/templates/source/web/main.d.ts.map +1 -0
  113. package/dist/templates/source/web/main.js +27 -0
  114. package/dist/templates/source/web/main.js.map +1 -0
  115. package/dist/templates/source/web/routes/__root.d.ts +2 -0
  116. package/dist/templates/source/web/routes/__root.d.ts.map +1 -0
  117. package/dist/templates/source/web/routes/__root.js +28 -0
  118. package/dist/templates/source/web/routes/__root.js.map +1 -0
  119. package/dist/templates/source/web/routes/about.d.ts +2 -0
  120. package/dist/templates/source/web/routes/about.d.ts.map +1 -0
  121. package/dist/templates/source/web/routes/about.js +33 -0
  122. package/dist/templates/source/web/routes/about.js.map +1 -0
  123. package/dist/templates/source/web/routes/index.auth.d.ts +2 -0
  124. package/dist/templates/source/web/routes/index.auth.d.ts.map +1 -0
  125. package/dist/templates/source/web/routes/index.auth.js +159 -0
  126. package/dist/templates/source/web/routes/index.auth.js.map +1 -0
  127. package/dist/templates/source/web/routes/index.default.d.ts +2 -0
  128. package/dist/templates/source/web/routes/index.default.d.ts.map +1 -0
  129. package/dist/templates/source/web/routes/index.default.js +60 -0
  130. package/dist/templates/source/web/routes/index.default.js.map +1 -0
  131. package/dist/templates/source/web/vite.config.d.ts +3 -0
  132. package/dist/templates/source/web/vite.config.d.ts.map +1 -0
  133. package/dist/templates/source/web/vite.config.js +22 -0
  134. package/dist/templates/source/web/vite.config.js.map +1 -0
  135. package/package.json +11 -9
  136. package/src/templates/source/api/config/app.ts +13 -0
  137. package/src/templates/source/api/config/auth.ts +202 -0
  138. package/src/templates/source/api/config/database.ts +22 -0
  139. package/src/templates/source/api/env.auth +22 -0
  140. package/src/templates/source/api/env.default +13 -0
  141. package/src/templates/source/api/index.auth.ts +30 -0
  142. package/src/templates/source/api/index.default.ts +27 -0
  143. package/src/templates/source/api/package.auth.json +40 -0
  144. package/src/templates/source/api/package.default.json +38 -0
  145. package/src/templates/source/api/prisma/schema.auth.prisma +30 -0
  146. package/src/templates/source/api/prisma/schema.default.prisma +28 -0
  147. package/src/templates/source/api/prisma.config.ts +15 -0
  148. package/src/templates/source/api/procedures/auth.ts +285 -0
  149. package/src/templates/source/api/procedures/health.ts +24 -0
  150. package/src/templates/source/api/procedures/users.auth.ts +170 -0
  151. package/src/templates/source/api/procedures/users.default.ts +119 -0
  152. package/src/templates/source/api/schemas/user.ts +29 -0
  153. package/src/templates/source/api/tsconfig.json +12 -0
  154. package/src/templates/source/api/tsup.config.ts +10 -0
  155. package/src/templates/source/root/CLAUDE.auth.md +148 -0
  156. package/src/templates/source/root/CLAUDE.default.md +128 -0
  157. package/src/templates/source/root/README.md +72 -0
  158. package/src/templates/source/root/gitignore +37 -0
  159. package/src/templates/source/root/package.json +17 -0
  160. package/src/templates/source/root/pnpm-workspace.yaml +2 -0
  161. package/src/templates/source/root/tsconfig.json +19 -0
  162. package/src/templates/source/web/App.module.css +282 -0
  163. package/src/templates/source/web/favicon.svg +12 -0
  164. package/src/templates/source/web/index.html +13 -0
  165. package/src/templates/source/web/main.tsx +38 -0
  166. package/src/templates/source/web/package.json +26 -0
  167. package/src/templates/source/web/routes/__root.tsx +31 -0
  168. package/src/templates/source/web/routes/about.tsx +36 -0
  169. package/src/templates/source/web/routes/index.auth.tsx +230 -0
  170. package/src/templates/source/web/routes/index.default.tsx +79 -0
  171. package/src/templates/source/web/styles/global.css +90 -0
  172. package/src/templates/source/web/tsconfig.json +24 -0
  173. package/src/templates/source/web/vite.config.ts +22 -0
  174. package/LICENSE +0 -21
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Application Entry Point
3
+ */
4
+ import 'dotenv/config';
5
+ import { veloxApp, VELOX_VERSION, databasePlugin, authPlugin, rest, getRouteSummary, } from '@veloxts/velox';
6
+ import { authConfig, config } from './config/index.js';
7
+ import { prisma } from './database/index.js';
8
+ import { authProcedures } from './procedures/auth.js';
9
+ import { healthProcedures } from './procedures/health.js';
10
+ import { userProcedures } from './procedures/users.js';
11
+ // ============================================================================
12
+ // Application Bootstrap
13
+ // ============================================================================
14
+ async function createApp() {
15
+ const app = await veloxApp({
16
+ port: config.port,
17
+ host: config.host,
18
+ logger: config.logger,
19
+ });
20
+ // Register database plugin
21
+ await app.register(databasePlugin({ client: prisma }));
22
+ // Register auth plugin
23
+ await app.register(authPlugin(authConfig));
24
+ console.log('[Auth] JWT authentication enabled');
25
+ // Register all procedures
26
+ const collections = [healthProcedures, authProcedures, userProcedures];
27
+ app.routes(rest(collections, { prefix: config.apiPrefix }));
28
+ return { app, collections };
29
+ }
30
+ function printBanner(collections) {
31
+ const divider = '═'.repeat(50);
32
+ console.log(`\n${divider}`);
33
+ console.log(` VeloxTS API v${VELOX_VERSION}`);
34
+ console.log(` Environment: ${config.env}`);
35
+ console.log(divider);
36
+ const routes = getRouteSummary(collections);
37
+ console.log('\n📍 Registered Routes:\n');
38
+ for (const route of routes) {
39
+ const method = route.method.padEnd(6);
40
+ const path = route.path.padEnd(25);
41
+ console.log(` ${method} ${path} → ${route.namespace}.${route.procedure}`);
42
+ }
43
+ console.log(`\n${divider}`);
44
+ console.log(` API: http://localhost:${config.port}${config.apiPrefix}`);
45
+ console.log(`${divider}\n`);
46
+ }
47
+ async function main() {
48
+ try {
49
+ const { app, collections } = await createApp();
50
+ await app.start();
51
+ printBanner(collections);
52
+ }
53
+ catch (error) {
54
+ console.error('Failed to start application:', error);
55
+ process.exit(1);
56
+ }
57
+ }
58
+ main();
59
+ //# sourceMappingURL=index.auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.auth.js","sourceRoot":"","sources":["../../../../src/templates/source/api/index.auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,eAAe,CAAC;AAEvB,OAAO,EACL,QAAQ,EACR,aAA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AAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Application Entry Point
3
+ */
4
+ import 'dotenv/config';
5
+ //# sourceMappingURL=index.default.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.default.d.ts","sourceRoot":"","sources":["../../../../src/templates/source/api/index.default.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,eAAe,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Application Entry Point
3
+ */
4
+ import 'dotenv/config';
5
+ import { veloxApp, VELOX_VERSION, databasePlugin, rest, getRouteSummary, } from '@veloxts/velox';
6
+ import { config } from './config/index.js';
7
+ import { prisma } from './database/index.js';
8
+ import { healthProcedures } from './procedures/health.js';
9
+ import { userProcedures } from './procedures/users.js';
10
+ // ============================================================================
11
+ // Application Bootstrap
12
+ // ============================================================================
13
+ async function createApp() {
14
+ const app = await veloxApp({
15
+ port: config.port,
16
+ host: config.host,
17
+ logger: config.logger,
18
+ });
19
+ // Register database plugin
20
+ await app.register(databasePlugin({ client: prisma }));
21
+ // Register all procedures
22
+ const collections = [healthProcedures, userProcedures];
23
+ app.routes(rest(collections, { prefix: config.apiPrefix }));
24
+ return { app, collections };
25
+ }
26
+ function printBanner(collections) {
27
+ const divider = '═'.repeat(50);
28
+ console.log(`\n${divider}`);
29
+ console.log(` VeloxTS API v${VELOX_VERSION}`);
30
+ console.log(` Environment: ${config.env}`);
31
+ console.log(divider);
32
+ // Print registered routes
33
+ const routes = getRouteSummary(collections);
34
+ console.log('\n📍 Registered Routes:\n');
35
+ for (const route of routes) {
36
+ const method = route.method.padEnd(6);
37
+ const path = route.path.padEnd(25);
38
+ console.log(` ${method} ${path} → ${route.namespace}.${route.procedure}`);
39
+ }
40
+ console.log(`\n${divider}`);
41
+ console.log(` API: http://localhost:${config.port}${config.apiPrefix}`);
42
+ console.log(`${divider}\n`);
43
+ }
44
+ async function main() {
45
+ try {
46
+ const { app, collections } = await createApp();
47
+ await app.start();
48
+ printBanner(collections);
49
+ }
50
+ catch (error) {
51
+ console.error('Failed to start application:', error);
52
+ process.exit(1);
53
+ }
54
+ }
55
+ main();
56
+ //# sourceMappingURL=index.default.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.default.js","sourceRoot":"","sources":["../../../../src/templates/source/api/index.default.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,eAAe,CAAC;AAEvB,OAAO,EACL,QAAQ,EACR,aAAa,EACb,cAAc,EACd,IAAI,EACJ,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC;QACzB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC,CAAC;IAEH,2BAA2B;IAC3B,MAAM,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAEvD,0BAA0B;IAC1B,MAAM,WAAW,GAAG,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;IACvD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAE5D,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC;AAC9B,CAAC;AAED,SAAS,WAAW,CAAC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AO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;QACrD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Prisma Configuration (Prisma 7.x)
3
+ *
4
+ * Database URL is configured here instead of schema.prisma.
5
+ */
6
+ import 'dotenv/config';
7
+ declare const _default: any;
8
+ export default _default;
9
+ //# sourceMappingURL=prisma.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma.config.d.ts","sourceRoot":"","sources":["../../../../src/templates/source/api/prisma.config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,eAAe,CAAC;;AAGvB,wBAMG"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Prisma Configuration (Prisma 7.x)
3
+ *
4
+ * Database URL is configured here instead of schema.prisma.
5
+ */
6
+ import 'dotenv/config';
7
+ import { defineConfig } from 'prisma/config';
8
+ export default defineConfig({
9
+ earlyAccess: true,
10
+ schema: './prisma/schema.prisma',
11
+ datasource: {
12
+ url: process.env.DATABASE_URL,
13
+ },
14
+ });
15
+ //# sourceMappingURL=prisma.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma.config.js","sourceRoot":"","sources":["../../../../src/templates/source/api/prisma.config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAe,YAAY,CAAC;IAC1B,WAAW,EAAE,IAAI;IACjB,MAAM,EAAE,wBAAwB;IAChC,UAAU,EAAE;QACV,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,YAAa;KAC/B;CACF,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Auth Procedures
3
+ *
4
+ * Authentication procedures for user registration, login, and token management.
5
+ *
6
+ * REST Endpoints:
7
+ * - POST /auth/register - Create new account
8
+ * - POST /auth/login - Authenticate and get tokens
9
+ * - POST /auth/refresh - Refresh access token
10
+ * - POST /auth/logout - Revoke current token
11
+ * - GET /auth/me - Get current user (protected)
12
+ */
13
+ export declare const authProcedures: any;
14
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../../src/templates/source/api/procedures/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAqHH,eAAO,MAAM,cAAc,KA4JzB,CAAC"}
@@ -0,0 +1,221 @@
1
+ /**
2
+ * Auth Procedures
3
+ *
4
+ * Authentication procedures for user registration, login, and token management.
5
+ *
6
+ * REST Endpoints:
7
+ * - POST /auth/register - Create new account
8
+ * - POST /auth/login - Authenticate and get tokens
9
+ * - POST /auth/refresh - Refresh access token
10
+ * - POST /auth/logout - Revoke current token
11
+ * - GET /auth/me - Get current user (protected)
12
+ */
13
+ import { AuthError, authenticated, createAuthRateLimiter, hashPassword, jwtManager, verifyPassword, defineProcedures, procedure, z, } from '@veloxts/velox';
14
+ import { authConfig, parseUserRoles, tokenStore } from '../config/index.js';
15
+ import { prisma } from '../database/index.js';
16
+ // ============================================================================
17
+ // Rate Limiter
18
+ // ============================================================================
19
+ const rateLimiter = createAuthRateLimiter({
20
+ login: {
21
+ maxAttempts: 5,
22
+ windowMs: 15 * 60 * 1000,
23
+ lockoutDurationMs: 15 * 60 * 1000,
24
+ progressiveBackoff: true,
25
+ },
26
+ register: {
27
+ maxAttempts: 3,
28
+ windowMs: 60 * 60 * 1000,
29
+ lockoutDurationMs: 60 * 60 * 1000,
30
+ },
31
+ refresh: {
32
+ maxAttempts: 10,
33
+ windowMs: 60 * 1000,
34
+ lockoutDurationMs: 60 * 1000,
35
+ },
36
+ });
37
+ // ============================================================================
38
+ // Password Blacklist
39
+ // ============================================================================
40
+ const COMMON_PASSWORDS = new Set([
41
+ 'password', 'password123', '12345678', '123456789',
42
+ 'qwerty123', 'letmein', 'welcome', 'admin123',
43
+ ]);
44
+ // ============================================================================
45
+ // Schemas
46
+ // ============================================================================
47
+ const PasswordSchema = z
48
+ .string()
49
+ .min(12, 'Password must be at least 12 characters')
50
+ .max(128, 'Password must not exceed 128 characters')
51
+ .refine((pwd) => /[a-z]/.test(pwd), 'Password must contain at least one lowercase letter')
52
+ .refine((pwd) => /[A-Z]/.test(pwd), 'Password must contain at least one uppercase letter')
53
+ .refine((pwd) => /[0-9]/.test(pwd), 'Password must contain at least one number')
54
+ .refine((pwd) => !COMMON_PASSWORDS.has(pwd.toLowerCase()), 'Password is too common. Please choose a stronger password.');
55
+ const EmailSchema = z
56
+ .string()
57
+ .email('Invalid email address')
58
+ .transform((email) => email.toLowerCase().trim());
59
+ const RegisterInput = z.object({
60
+ name: z.string().min(2).max(100).trim(),
61
+ email: EmailSchema,
62
+ password: PasswordSchema,
63
+ });
64
+ const LoginInput = z.object({
65
+ email: EmailSchema,
66
+ password: z.string().min(1),
67
+ });
68
+ const RefreshInput = z.object({
69
+ refreshToken: z.string(),
70
+ });
71
+ const TokenResponse = z.object({
72
+ accessToken: z.string(),
73
+ refreshToken: z.string(),
74
+ expiresIn: z.number(),
75
+ tokenType: z.literal('Bearer'),
76
+ });
77
+ const UserResponse = z.object({
78
+ id: z.string(),
79
+ name: z.string(),
80
+ email: z.string(),
81
+ roles: z.array(z.string()),
82
+ });
83
+ const LogoutResponse = z.object({
84
+ success: z.boolean(),
85
+ message: z.string(),
86
+ });
87
+ // ============================================================================
88
+ // JWT Manager
89
+ // ============================================================================
90
+ const jwt = jwtManager(authConfig.jwt);
91
+ // Dummy hash for timing attack prevention
92
+ const DUMMY_HASH = '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.uy7dPSSXB5G6Uy';
93
+ // ============================================================================
94
+ // Auth Procedures
95
+ // ============================================================================
96
+ export const authProcedures = defineProcedures('auth', {
97
+ register: procedure()
98
+ .rest({ method: 'POST', path: '/auth/register' })
99
+ .use(rateLimiter.register())
100
+ .input(RegisterInput)
101
+ .output(TokenResponse)
102
+ .mutation(async ({ input }) => {
103
+ const normalizedEmail = input.email.toLowerCase().trim();
104
+ const existing = await prisma.user.findUnique({
105
+ where: { email: normalizedEmail },
106
+ });
107
+ if (existing) {
108
+ throw new AuthError('Registration failed. If this email is not already registered, please try again.', 400, 'REGISTRATION_FAILED');
109
+ }
110
+ const hashedPassword = await hashPassword(input.password);
111
+ const user = await prisma.user.create({
112
+ data: {
113
+ name: input.name.trim(),
114
+ email: normalizedEmail,
115
+ password: hashedPassword,
116
+ roles: JSON.stringify(['user']),
117
+ },
118
+ });
119
+ return jwt.createTokenPair({
120
+ id: user.id,
121
+ email: user.email,
122
+ roles: ['user'],
123
+ });
124
+ }),
125
+ login: procedure()
126
+ .rest({ method: 'POST', path: '/auth/login' })
127
+ .use(rateLimiter.login((ctx) => {
128
+ const input = ctx.input;
129
+ return input?.email?.toLowerCase() ?? '';
130
+ }))
131
+ .input(LoginInput)
132
+ .output(TokenResponse)
133
+ .mutation(async ({ input }) => {
134
+ const normalizedEmail = input.email.toLowerCase().trim();
135
+ const user = await prisma.user.findUnique({
136
+ where: { email: normalizedEmail },
137
+ });
138
+ const hashToVerify = user?.password || DUMMY_HASH;
139
+ const isValid = await verifyPassword(input.password, hashToVerify);
140
+ if (!user || !user.password || !isValid) {
141
+ throw new AuthError('Invalid email or password', 401, 'INVALID_CREDENTIALS');
142
+ }
143
+ const roles = parseUserRoles(user.roles);
144
+ return jwt.createTokenPair({
145
+ id: user.id,
146
+ email: user.email,
147
+ roles,
148
+ });
149
+ }),
150
+ refresh: procedure()
151
+ .rest({ method: 'POST', path: '/auth/refresh' })
152
+ .use(rateLimiter.refresh())
153
+ .input(RefreshInput)
154
+ .output(TokenResponse)
155
+ .mutation(async ({ input }) => {
156
+ try {
157
+ const payload = jwt.verifyToken(input.refreshToken);
158
+ if (payload.type !== 'refresh') {
159
+ throw new AuthError('Invalid token type', 401, 'INVALID_TOKEN_TYPE');
160
+ }
161
+ if (payload.jti && tokenStore.isRevoked(payload.jti)) {
162
+ throw new AuthError('Token has been revoked', 401, 'TOKEN_REVOKED');
163
+ }
164
+ if (payload.jti) {
165
+ const previousUserId = tokenStore.isRefreshTokenUsed(payload.jti);
166
+ if (previousUserId) {
167
+ tokenStore.revokeAllUserTokens(previousUserId);
168
+ throw new AuthError('Security alert: Refresh token reuse detected.', 401, 'TOKEN_REUSE_DETECTED');
169
+ }
170
+ tokenStore.markRefreshTokenUsed(payload.jti, payload.sub);
171
+ }
172
+ const user = await prisma.user.findUnique({
173
+ where: { id: payload.sub },
174
+ });
175
+ if (!user) {
176
+ throw new AuthError('User not found', 401, 'USER_NOT_FOUND');
177
+ }
178
+ return jwt.createTokenPair({
179
+ id: user.id,
180
+ email: user.email,
181
+ roles: parseUserRoles(user.roles),
182
+ });
183
+ }
184
+ catch (error) {
185
+ if (error instanceof AuthError)
186
+ throw error;
187
+ throw new AuthError('Invalid refresh token', 401, 'INVALID_REFRESH_TOKEN');
188
+ }
189
+ }),
190
+ logout: procedure()
191
+ .rest({ method: 'POST', path: '/auth/logout' })
192
+ .guard(authenticated)
193
+ .output(LogoutResponse)
194
+ .mutation(async ({ ctx }) => {
195
+ const tokenId = ctx.auth?.token?.jti;
196
+ if (tokenId) {
197
+ tokenStore.revoke(tokenId, 15 * 60 * 1000);
198
+ }
199
+ return {
200
+ success: true,
201
+ message: 'Successfully logged out',
202
+ };
203
+ }),
204
+ getMe: procedure()
205
+ .rest({ method: 'GET', path: '/auth/me' })
206
+ .guard(authenticated)
207
+ .output(UserResponse)
208
+ .query(async ({ ctx }) => {
209
+ const user = ctx.user;
210
+ if (!user) {
211
+ throw new AuthError('Not authenticated', 401, 'NOT_AUTHENTICATED');
212
+ }
213
+ return {
214
+ id: user.id,
215
+ name: user.name || '',
216
+ email: user.email,
217
+ roles: Array.isArray(user.roles) ? user.roles : ['user'],
218
+ };
219
+ }),
220
+ });
221
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../src/templates/source/api/procedures/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,SAAS,EACT,aAAa,EACb,qBAAqB,EACrB,YAAY,EACZ,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,CAAC,GACF,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E,MAAM,WAAW,GAAG,qBAAqB,CAAC;IACxC,KAAK,EAAE;QACL,WAAW,EAAE,CAAC;QACd,QAAQ,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;QACxB,iBAAiB,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;QACjC,kBAAkB,EAAE,IAAI;KACzB;IACD,QAAQ,EAAE;QACR,WAAW,EAAE,CAAC;QACd,QAAQ,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;QACxB,iBAAiB,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;KAClC;IACD,OAAO,EAAE;QACP,WAAW,EAAE,EAAE;QACf,QAAQ,EAAE,EAAE,GAAG,IAAI;QACnB,iBAAiB,EAAE,EAAE,GAAG,IAAI;KAC7B;CACF,CAAC,CAAC;AAEH,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC/B,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW;IAClD,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU;CAC9C,CAAC,CAAC;AAEH,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AA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;YACjB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;SACzD,CAAC;IACJ,CAAC,CAAC;CACL,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Health Check Procedures
3
+ */
4
+ export declare const healthProcedures: any;
5
+ //# sourceMappingURL=health.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../../../src/templates/source/api/procedures/health.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,eAAO,MAAM,gBAAgB,KAiB3B,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Health Check Procedures
3
+ */
4
+ import { VELOX_VERSION, defineProcedures, procedure, z } from '@veloxts/velox';
5
+ export const healthProcedures = defineProcedures('health', {
6
+ getHealth: procedure()
7
+ .rest({ method: 'GET', path: '/health' })
8
+ .output(z.object({
9
+ status: z.literal('ok'),
10
+ version: z.string(),
11
+ timestamp: z.string().datetime(),
12
+ uptime: z.number(),
13
+ }))
14
+ .query(async () => ({
15
+ status: 'ok',
16
+ version: VELOX_VERSION,
17
+ timestamp: new Date().toISOString(),
18
+ uptime: process.uptime(),
19
+ })),
20
+ });
21
+ //# sourceMappingURL=health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.js","sourceRoot":"","sources":["../../../../../src/templates/source/api/procedures/health.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,gBAAgB,CAAC;AAE/E,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,QAAQ,EAAE;IACzD,SAAS,EAAE,SAAS,EAAE;SACnB,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;SACxC,MAAM,CACL,CAAC,CAAC,MAAM,CAAC;QACP,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;QACvB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAChC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;KACnB,CAAC,CACH;SACA,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;QAClB,MAAM,EAAE,IAAa;QACrB,OAAO,EAAE,aAAa;QACtB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;KACzB,CAAC,CAAC;CACN,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Procedure Exports
3
+ */
4
+ export * from './auth.js';
5
+ export * from './health.js';
6
+ export * from './users.js';
7
+ //# sourceMappingURL=index.auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.auth.d.ts","sourceRoot":"","sources":["../../../../../src/templates/source/api/procedures/index.auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Procedure Exports
3
+ */
4
+ export * from './auth.js';
5
+ export * from './health.js';
6
+ export * from './users.js';
7
+ //# sourceMappingURL=index.auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.auth.js","sourceRoot":"","sources":["../../../../../src/templates/source/api/procedures/index.auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Procedure Exports
3
+ */
4
+ export * from './health.js';
5
+ export * from './users.js';
6
+ //# sourceMappingURL=index.default.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.default.d.ts","sourceRoot":"","sources":["../../../../../src/templates/source/api/procedures/index.default.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Procedure Exports
3
+ */
4
+ export * from './health.js';
5
+ export * from './users.js';
6
+ //# sourceMappingURL=index.default.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.default.js","sourceRoot":"","sources":["../../../../../src/templates/source/api/procedures/index.default.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * User Procedures
3
+ *
4
+ * CRUD procedures for user management with authentication guards.
5
+ */
6
+ export declare const userProcedures: any;
7
+ //# sourceMappingURL=users.auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.auth.d.ts","sourceRoot":"","sources":["../../../../../src/templates/source/api/procedures/users.auth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA6DH,eAAO,MAAM,cAAc,KAwGzB,CAAC"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * User Procedures
3
+ *
4
+ * CRUD procedures for user management with authentication guards.
5
+ */
6
+ import { AuthError, authenticated, hasRole, defineProcedures, GuardError, procedure, paginationInputSchema, z, } from '@veloxts/velox';
7
+ import { CreateUserInput, UpdateUserInput, UserSchema, } from '../schemas/user.js';
8
+ function getDb(ctx) {
9
+ return ctx.db;
10
+ }
11
+ function toUserResponse(dbUser) {
12
+ return {
13
+ id: dbUser.id,
14
+ name: dbUser.name,
15
+ email: dbUser.email,
16
+ createdAt: dbUser.createdAt instanceof Date ? dbUser.createdAt.toISOString() : dbUser.createdAt,
17
+ updatedAt: dbUser.updatedAt instanceof Date ? dbUser.updatedAt.toISOString() : dbUser.updatedAt,
18
+ };
19
+ }
20
+ // ============================================================================
21
+ // User Procedures
22
+ // ============================================================================
23
+ export const userProcedures = defineProcedures('users', {
24
+ getUser: procedure()
25
+ .input(z.object({ id: z.string().uuid() }))
26
+ .output(UserSchema.nullable())
27
+ .query(async ({ input, ctx }) => {
28
+ const db = getDb(ctx);
29
+ const user = await db.user.findUnique({ where: { id: input.id } });
30
+ return user ? toUserResponse(user) : null;
31
+ }),
32
+ listUsers: procedure()
33
+ .input(paginationInputSchema.optional())
34
+ .output(z.object({
35
+ data: z.array(UserSchema),
36
+ meta: z.object({
37
+ page: z.number(),
38
+ limit: z.number(),
39
+ total: z.number(),
40
+ }),
41
+ }))
42
+ .query(async ({ input, ctx }) => {
43
+ const db = getDb(ctx);
44
+ const page = input?.page ?? 1;
45
+ const limit = input?.limit ?? 10;
46
+ const skip = (page - 1) * limit;
47
+ const [dbUsers, total] = await Promise.all([
48
+ db.user.findMany({ skip, take: limit }),
49
+ db.user.count(),
50
+ ]);
51
+ return {
52
+ data: dbUsers.map(toUserResponse),
53
+ meta: { page, limit, total },
54
+ };
55
+ }),
56
+ createUser: procedure()
57
+ .guard(authenticated)
58
+ .input(CreateUserInput)
59
+ .output(UserSchema)
60
+ .mutation(async ({ input, ctx }) => {
61
+ const db = getDb(ctx);
62
+ const user = await db.user.create({ data: input });
63
+ return toUserResponse(user);
64
+ }),
65
+ updateUser: procedure()
66
+ .guard(authenticated)
67
+ .input(z.object({ id: z.string().uuid() }).merge(UpdateUserInput))
68
+ .output(UserSchema)
69
+ .mutation(async ({ input, ctx }) => {
70
+ const db = getDb(ctx);
71
+ const { id, ...data } = input;
72
+ if (!ctx.user) {
73
+ throw new AuthError('Authentication required', 401, 'NOT_AUTHENTICATED');
74
+ }
75
+ const isOwner = ctx.user.id === id;
76
+ const isAdmin = Array.isArray(ctx.user.roles) && ctx.user.roles.includes('admin');
77
+ if (!isOwner && !isAdmin) {
78
+ throw new GuardError('ownership', 'You can only update your own profile', 403);
79
+ }
80
+ const updated = await db.user.update({ where: { id }, data });
81
+ return toUserResponse(updated);
82
+ }),
83
+ patchUser: procedure()
84
+ .guard(authenticated)
85
+ .input(z.object({ id: z.string().uuid() }).merge(UpdateUserInput))
86
+ .output(UserSchema)
87
+ .mutation(async ({ input, ctx }) => {
88
+ const db = getDb(ctx);
89
+ const { id, ...data } = input;
90
+ if (!ctx.user) {
91
+ throw new AuthError('Authentication required', 401, 'NOT_AUTHENTICATED');
92
+ }
93
+ const isOwner = ctx.user.id === id;
94
+ const isAdmin = Array.isArray(ctx.user.roles) && ctx.user.roles.includes('admin');
95
+ if (!isOwner && !isAdmin) {
96
+ throw new GuardError('ownership', 'You can only update your own profile', 403);
97
+ }
98
+ const updated = await db.user.update({ where: { id }, data });
99
+ return toUserResponse(updated);
100
+ }),
101
+ deleteUser: procedure()
102
+ .guard(hasRole('admin'))
103
+ .input(z.object({ id: z.string().uuid() }))
104
+ .output(z.object({ success: z.boolean() }))
105
+ .mutation(async ({ input, ctx }) => {
106
+ const db = getDb(ctx);
107
+ await db.user.delete({ where: { id: input.id } });
108
+ return { success: true };
109
+ }),
110
+ });
111
+ //# sourceMappingURL=users.auth.js.map