wexts 3.0.2 → 4.1.0

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 (288) hide show
  1. package/README.md +49 -346
  2. package/bin/wexts.cjs +2 -0
  3. package/dist/chunk-2KAQYLVN.js +0 -0
  4. package/dist/chunk-2KAQYLVN.js.map +1 -1
  5. package/dist/{chunk-O42L6HOX.js → chunk-2LJVUMXW.js} +79 -93
  6. package/dist/chunk-2LJVUMXW.js.map +1 -0
  7. package/dist/chunk-342VRT25.mjs +504 -0
  8. package/dist/chunk-342VRT25.mjs.map +1 -0
  9. package/dist/chunk-7HNQWJWV.js +504 -0
  10. package/dist/chunk-7HNQWJWV.js.map +1 -0
  11. package/dist/chunk-7QKLIVRF.js +94 -0
  12. package/dist/chunk-7QKLIVRF.js.map +1 -0
  13. package/dist/chunk-7SSCNCTW.mjs +137 -0
  14. package/dist/chunk-7SSCNCTW.mjs.map +1 -0
  15. package/dist/chunk-7TLSPR65.mjs +95 -0
  16. package/dist/chunk-7TLSPR65.mjs.map +1 -0
  17. package/dist/{chunk-FCEZDH42.mjs → chunk-7WULUGLH.mjs} +5 -3
  18. package/dist/chunk-7WULUGLH.mjs.map +1 -0
  19. package/dist/chunk-AVMQJWYD.js +95 -0
  20. package/dist/chunk-AVMQJWYD.js.map +1 -0
  21. package/dist/{chunk-WF65EDRZ.js → chunk-BG56B4DE.js} +20 -2
  22. package/dist/chunk-BG56B4DE.js.map +1 -0
  23. package/dist/chunk-CLM5PNSG.mjs +496 -0
  24. package/dist/chunk-CLM5PNSG.mjs.map +1 -0
  25. package/dist/chunk-DNLGCKTT.js +31 -0
  26. package/dist/chunk-DNLGCKTT.js.map +1 -0
  27. package/dist/{chunk-VNNVLQLJ.mjs → chunk-JHOVXH3X.mjs} +2 -2
  28. package/dist/chunk-JHOVXH3X.mjs.map +1 -0
  29. package/dist/chunk-MXINIFPC.js +105 -0
  30. package/dist/chunk-MXINIFPC.js.map +1 -0
  31. package/dist/chunk-O4II6N34.js +137 -0
  32. package/dist/chunk-O4II6N34.js.map +1 -0
  33. package/dist/chunk-SE32ZPOZ.js +496 -0
  34. package/dist/chunk-SE32ZPOZ.js.map +1 -0
  35. package/dist/{chunk-STTOPUZ2.mjs → chunk-UAL54DVV.mjs} +21 -3
  36. package/dist/chunk-UAL54DVV.mjs.map +1 -0
  37. package/dist/{chunk-3OM7CHCA.js → chunk-WCKSKU3C.js} +1 -1
  38. package/dist/chunk-WCKSKU3C.js.map +1 -0
  39. package/dist/chunk-WU6FW77M.mjs +105 -0
  40. package/dist/chunk-WU6FW77M.mjs.map +1 -0
  41. package/dist/chunk-XE4OXN2W.js +0 -0
  42. package/dist/chunk-XE4OXN2W.js.map +1 -1
  43. package/dist/chunk-YBM3IJEA.mjs +94 -0
  44. package/dist/chunk-YBM3IJEA.mjs.map +1 -0
  45. package/dist/{chunk-KXYLEUSW.mjs → chunk-YN6WIWNQ.mjs} +69 -83
  46. package/dist/chunk-YN6WIWNQ.mjs.map +1 -0
  47. package/dist/chunk-YSLEF5C5.mjs +0 -0
  48. package/dist/chunk-YSLEF5C5.mjs.map +0 -0
  49. package/dist/chunk-ZX7QIN24.mjs +31 -0
  50. package/dist/chunk-ZX7QIN24.mjs.map +1 -0
  51. package/dist/cli/index.d.mts +22 -0
  52. package/dist/cli/index.d.ts +22 -0
  53. package/dist/cli/index.js +676 -292
  54. package/dist/cli/index.js.map +1 -1
  55. package/dist/cli/index.mjs +678 -293
  56. package/dist/cli/index.mjs.map +1 -1
  57. package/dist/client/index.d.mts +10 -1
  58. package/dist/client/index.d.ts +10 -1
  59. package/dist/client/index.js +5 -2
  60. package/dist/client/index.js.map +1 -1
  61. package/dist/client/index.mjs +7 -4
  62. package/dist/client/index.mjs.map +0 -0
  63. package/dist/codegen/index.d.mts +2 -1
  64. package/dist/codegen/index.d.ts +2 -1
  65. package/dist/codegen/index.js +6 -3
  66. package/dist/codegen/index.js.map +1 -1
  67. package/dist/codegen/index.mjs +8 -5
  68. package/dist/codegen/index.mjs.map +0 -0
  69. package/dist/decorators-BT1FFqN0.d.mts +29 -0
  70. package/dist/decorators-DvS58PqC.d.ts +29 -0
  71. package/dist/dev-server/index.d.mts +1 -1
  72. package/dist/dev-server/index.d.ts +1 -1
  73. package/dist/dev-server/index.js +3 -3
  74. package/dist/dev-server/index.js.map +1 -1
  75. package/dist/dev-server/index.mjs +3 -3
  76. package/dist/dev-server/index.mjs.map +0 -0
  77. package/dist/{index-SjUaHgFr.d.ts → index-7QeQEf37.d.ts} +27 -10
  78. package/dist/{index-tFGPFVfQ.d.mts → index-7RvU-jGE.d.mts} +0 -1
  79. package/dist/{index-tFGPFVfQ.d.ts → index-7RvU-jGE.d.ts} +0 -1
  80. package/dist/{index-SjUaHgFr.d.mts → index-8nzxy0NN.d.mts} +27 -10
  81. package/dist/index-Co5ZsLqq.d.ts +58 -0
  82. package/dist/index-D94W1__r.d.mts +58 -0
  83. package/dist/index-DQmyVp6F.d.mts +27 -0
  84. package/dist/index-KL_1BrQb.d.ts +27 -0
  85. package/dist/index.d.mts +54 -7
  86. package/dist/index.d.ts +54 -7
  87. package/dist/index.js +70 -29
  88. package/dist/index.js.map +1 -1
  89. package/dist/index.mjs +62 -21
  90. package/dist/index.mjs.map +1 -1
  91. package/dist/nest/index.d.mts +3 -1
  92. package/dist/nest/index.d.ts +3 -1
  93. package/dist/nest/index.js +20 -2
  94. package/dist/nest/index.js.map +1 -1
  95. package/dist/nest/index.mjs +21 -3
  96. package/dist/nest/index.mjs.map +0 -0
  97. package/dist/next/index.d.mts +7 -2
  98. package/dist/next/index.d.ts +7 -2
  99. package/dist/next/index.js +135 -5
  100. package/dist/next/index.js.map +1 -1
  101. package/dist/next/index.mjs +133 -4
  102. package/dist/next/index.mjs.map +1 -1
  103. package/dist/rpc/index.d.mts +2 -0
  104. package/dist/rpc/index.d.ts +2 -0
  105. package/dist/rpc/index.js +23 -0
  106. package/dist/rpc/index.js.map +1 -0
  107. package/dist/rpc/index.mjs +23 -0
  108. package/dist/{chunk-7NSRDJ5C.mjs.map → rpc/index.mjs.map} +0 -0
  109. package/dist/runtime/index.d.mts +55 -0
  110. package/dist/runtime/index.d.ts +55 -0
  111. package/dist/runtime/index.js +221 -0
  112. package/dist/runtime/index.js.map +1 -0
  113. package/dist/runtime/index.mjs +221 -0
  114. package/dist/runtime/index.mjs.map +1 -0
  115. package/dist/types/index.d.mts +0 -0
  116. package/dist/types/index.d.ts +0 -0
  117. package/dist/types/index.js +0 -0
  118. package/dist/types/index.js.map +1 -1
  119. package/dist/types/index.mjs +1 -1
  120. package/dist/types/index.mjs.map +0 -0
  121. package/dist/types-7d_fC-C3.d.mts +32 -0
  122. package/dist/types-7d_fC-C3.d.ts +32 -0
  123. package/dist/vercel-builder/index.d.mts +58 -0
  124. package/dist/vercel-builder/index.d.ts +58 -0
  125. package/dist/vercel-builder/index.js +330 -0
  126. package/dist/vercel-builder/index.js.map +1 -0
  127. package/dist/vercel-builder/index.mjs +330 -0
  128. package/dist/vercel-builder/index.mjs.map +1 -0
  129. package/package.json +37 -16
  130. package/templates/.dockerignore +43 -43
  131. package/templates/.env.example +0 -0
  132. package/templates/Dockerfile +60 -60
  133. package/templates/Procfile +1 -1
  134. package/templates/README.md +67 -58
  135. package/templates/api-sdk.ts +115 -115
  136. package/templates/docker-compose.yml +34 -34
  137. package/templates/nestjs-api/.env.example +0 -0
  138. package/templates/nestjs-api/README.md +87 -79
  139. package/templates/nestjs-api/nest-cli.json +6 -6
  140. package/templates/nestjs-api/package.json +40 -40
  141. package/templates/nestjs-api/prisma/dev.db +0 -0
  142. package/templates/nestjs-api/prisma/migrations/20251123205437_init/migration.sql +0 -0
  143. package/templates/nestjs-api/prisma/migrations/migration_lock.toml +0 -0
  144. package/templates/nestjs-api/prisma/schema.prisma +29 -29
  145. package/templates/nestjs-api/src/app.module.ts +17 -17
  146. package/templates/nestjs-api/src/auth/auth.controller.ts +27 -27
  147. package/templates/nestjs-api/src/auth/auth.module.ts +37 -29
  148. package/templates/nestjs-api/src/auth/auth.service.ts +86 -86
  149. package/templates/nestjs-api/src/auth/dto/auth.dto.ts +22 -22
  150. package/templates/nestjs-api/src/auth/guards/jwt-auth.guard.ts +5 -5
  151. package/templates/nestjs-api/src/auth/strategies/jwt.strategy.ts +27 -19
  152. package/templates/nestjs-api/src/main.ts +32 -32
  153. package/templates/nestjs-api/src/prisma/prisma.module.ts +9 -9
  154. package/templates/nestjs-api/src/prisma/prisma.service.ts +14 -14
  155. package/templates/nestjs-api/src/todos/dto/todo.dto.ts +24 -24
  156. package/templates/nestjs-api/src/todos/todos.controller.ts +39 -39
  157. package/templates/nestjs-api/src/todos/todos.module.ts +11 -11
  158. package/templates/nestjs-api/src/todos/todos.service.ts +53 -53
  159. package/templates/nestjs-api/src/users/users.controller.ts +14 -14
  160. package/templates/nestjs-api/src/users/users.module.ts +12 -12
  161. package/templates/nestjs-api/src/users/users.service.ts +19 -19
  162. package/templates/nestjs-api/tsconfig.json +39 -39
  163. package/templates/nextjs-web/README.md +76 -68
  164. package/templates/nextjs-web/app/actions/auth.ts +108 -108
  165. package/templates/nextjs-web/app/dashboard/error.tsx +39 -39
  166. package/templates/nextjs-web/app/dashboard/loading.tsx +14 -14
  167. package/templates/nextjs-web/app/dashboard/page.tsx +5 -5
  168. package/templates/nextjs-web/app/globals.css +93 -93
  169. package/templates/nextjs-web/app/layout.tsx +29 -29
  170. package/templates/nextjs-web/app/login/page.tsx +5 -5
  171. package/templates/nextjs-web/app/page.tsx +28 -28
  172. package/templates/nextjs-web/app/register/page.tsx +5 -5
  173. package/templates/nextjs-web/components/ui/button.tsx +56 -56
  174. package/templates/nextjs-web/components/ui/card.tsx +79 -79
  175. package/templates/nextjs-web/components/ui/input.tsx +25 -25
  176. package/templates/nextjs-web/components/ui/label.tsx +24 -24
  177. package/templates/nextjs-web/features/auth/LoginForm.tsx +140 -140
  178. package/templates/nextjs-web/features/auth/RegisterForm.tsx +159 -159
  179. package/templates/nextjs-web/features/auth/api.ts +35 -35
  180. package/templates/nextjs-web/features/auth/index.ts +3 -3
  181. package/templates/nextjs-web/features/dashboard/DashboardView.tsx +204 -204
  182. package/templates/nextjs-web/features/dashboard/api.ts +9 -9
  183. package/templates/nextjs-web/features/dashboard/components.tsx +74 -74
  184. package/templates/nextjs-web/features/dashboard/index.ts +3 -3
  185. package/templates/nextjs-web/hooks/index.ts +4 -4
  186. package/templates/nextjs-web/lib/api-client.ts +89 -89
  187. package/templates/nextjs-web/lib/api.ts +115 -115
  188. package/templates/nextjs-web/lib/axios-global-config.ts +17 -17
  189. package/templates/nextjs-web/lib/utils.ts +6 -6
  190. package/templates/nextjs-web/lib/wexts-client.ts +4 -4
  191. package/templates/nextjs-web/next-env.d.ts +6 -6
  192. package/templates/nextjs-web/next.config.ts +20 -20
  193. package/templates/nextjs-web/package.json +37 -37
  194. package/templates/nextjs-web/postcss.config.js +6 -6
  195. package/templates/nextjs-web/tailwind.config.ts +69 -69
  196. package/templates/nextjs-web/tsconfig.json +1 -1
  197. package/templates/nixpacks.toml +11 -11
  198. package/templates/root-package.json +31 -31
  199. package/templates/server.ts +66 -66
  200. package/templates/tsconfig.json +30 -30
  201. package/dist/chunk-2MCBBWEA.js +0 -1
  202. package/dist/chunk-2MCBBWEA.js.map +0 -1
  203. package/dist/chunk-3OM7CHCA.js.map +0 -1
  204. package/dist/chunk-63MTCWU2.mjs +0 -361
  205. package/dist/chunk-63MTCWU2.mjs.map +0 -1
  206. package/dist/chunk-667BQCEM.js +0 -375
  207. package/dist/chunk-667BQCEM.js.map +0 -1
  208. package/dist/chunk-67IJ6H4J.mjs +0 -44
  209. package/dist/chunk-67IJ6H4J.mjs.map +0 -1
  210. package/dist/chunk-6SVQEGEX.mjs +0 -44
  211. package/dist/chunk-6SVQEGEX.mjs.map +0 -1
  212. package/dist/chunk-7NSRDJ5C.mjs +0 -1
  213. package/dist/chunk-ASDXAK6G.js +0 -44
  214. package/dist/chunk-ASDXAK6G.js.map +0 -1
  215. package/dist/chunk-CKZ4VSCB.mjs +0 -18
  216. package/dist/chunk-CKZ4VSCB.mjs.map +0 -1
  217. package/dist/chunk-DW6GOKMF.js +0 -57
  218. package/dist/chunk-DW6GOKMF.js.map +0 -1
  219. package/dist/chunk-EFZPSZWO.mjs +0 -1
  220. package/dist/chunk-EFZPSZWO.mjs.map +0 -1
  221. package/dist/chunk-FCEZDH42.mjs.map +0 -1
  222. package/dist/chunk-FYGXL4V7.js +0 -361
  223. package/dist/chunk-FYGXL4V7.js.map +0 -1
  224. package/dist/chunk-GKVPGKAH.js +0 -66
  225. package/dist/chunk-GKVPGKAH.js.map +0 -1
  226. package/dist/chunk-GWP6PNSP.js +0 -225
  227. package/dist/chunk-GWP6PNSP.js.map +0 -1
  228. package/dist/chunk-HQKTXE7E.mjs +0 -225
  229. package/dist/chunk-HQKTXE7E.mjs.map +0 -1
  230. package/dist/chunk-HSFLZUJN.mjs +0 -57
  231. package/dist/chunk-HSFLZUJN.mjs.map +0 -1
  232. package/dist/chunk-HU63F22V.js +0 -361
  233. package/dist/chunk-HU63F22V.js.map +0 -1
  234. package/dist/chunk-J5LGTIGS.mjs +0 -10
  235. package/dist/chunk-J5LGTIGS.mjs.map +0 -1
  236. package/dist/chunk-JMBD6DOP.js +0 -225
  237. package/dist/chunk-JMBD6DOP.js.map +0 -1
  238. package/dist/chunk-K7EIJSYQ.js +0 -1
  239. package/dist/chunk-K7EIJSYQ.js.map +0 -1
  240. package/dist/chunk-KXYLEUSW.mjs.map +0 -1
  241. package/dist/chunk-MTHKZO55.js +0 -44
  242. package/dist/chunk-MTHKZO55.js.map +0 -1
  243. package/dist/chunk-NNQFLD7O.mjs +0 -361
  244. package/dist/chunk-NNQFLD7O.mjs.map +0 -1
  245. package/dist/chunk-NU2UB242.js +0 -82
  246. package/dist/chunk-NU2UB242.js.map +0 -1
  247. package/dist/chunk-NULGSZFE.mjs +0 -57
  248. package/dist/chunk-NULGSZFE.mjs.map +0 -1
  249. package/dist/chunk-O42L6HOX.js.map +0 -1
  250. package/dist/chunk-ONXNE2A6.mjs +0 -375
  251. package/dist/chunk-ONXNE2A6.mjs.map +0 -1
  252. package/dist/chunk-OTBYRUBE.mjs +0 -225
  253. package/dist/chunk-OTBYRUBE.mjs.map +0 -1
  254. package/dist/chunk-OTSAVKLY.mjs +0 -66
  255. package/dist/chunk-OTSAVKLY.mjs.map +0 -1
  256. package/dist/chunk-PZ5AY32C.js +0 -10
  257. package/dist/chunk-PZ5AY32C.js.map +0 -1
  258. package/dist/chunk-QP2TMRLG.js +0 -57
  259. package/dist/chunk-QP2TMRLG.js.map +0 -1
  260. package/dist/chunk-RS23R3ZQ.mjs +0 -82
  261. package/dist/chunk-RS23R3ZQ.mjs.map +0 -1
  262. package/dist/chunk-STTOPUZ2.mjs.map +0 -1
  263. package/dist/chunk-VMT3LALB.mjs +0 -51
  264. package/dist/chunk-VMT3LALB.mjs.map +0 -1
  265. package/dist/chunk-VNNVLQLJ.mjs.map +0 -1
  266. package/dist/chunk-W3YRVEFQ.js +0 -66
  267. package/dist/chunk-W3YRVEFQ.js.map +0 -1
  268. package/dist/chunk-WF65EDRZ.js.map +0 -1
  269. package/dist/chunk-WMHVXEYQ.mjs +0 -66
  270. package/dist/chunk-WMHVXEYQ.mjs.map +0 -1
  271. package/dist/chunk-XVKTIYHY.js +0 -51
  272. package/dist/chunk-XVKTIYHY.js.map +0 -1
  273. package/dist/codegen-MRZDLCYI.js +0 -13
  274. package/dist/codegen-MRZDLCYI.js.map +0 -1
  275. package/dist/codegen-UI5HTMXE.mjs +0 -13
  276. package/dist/codegen-UI5HTMXE.mjs.map +0 -1
  277. package/dist/dev-server-JKRVBWPY.mjs +0 -13
  278. package/dist/dev-server-JKRVBWPY.mjs.map +0 -1
  279. package/dist/dev-server-TLL7UQMR.js +0 -13
  280. package/dist/dev-server-TLL7UQMR.js.map +0 -1
  281. package/dist/index-BsNaOUtH.d.mts +0 -44
  282. package/dist/index-BsNaOUtH.d.ts +0 -44
  283. package/dist/index-CrbXnXsO.d.ts +0 -62
  284. package/dist/index-kEbGExWM.d.mts +0 -62
  285. package/templates/nestjs-api/.env +0 -4
  286. package/templates/nestjs-api/package-lock.json +0 -5623
  287. package/templates/nextjs-web/.env +0 -1
  288. package/templates/nextjs-web/package-lock.json +0 -3254
@@ -1,79 +1,87 @@
1
- # Fusion NestJS API
2
-
3
- Complete NestJS 10 backend with authentication, Prisma ORM, and CRUD operations.
4
-
5
- ## Features
6
-
7
- - ✅ JWT Authentication
8
- - ✅ Prisma ORM (SQLite for development)
9
- - User Management
10
- - ✅ Todo CRUD Operations
11
- - Fusion Decorators for Auto API Client Generation
12
- - ✅ Fastify Adapter
13
- - ✅ Input Validation
14
-
15
- ## Setup
16
-
17
- ```bash
18
- # Install dependencies
19
- npm install
20
-
21
- # Copy environment variables
22
- cp .env.example .env
23
-
24
- # Generate Prisma client
25
- npm run prisma:generate
26
-
27
- # Run migrations
28
- npm run prisma:migrate
29
-
30
- # Start development server
31
- npm run start:dev
32
- ```
33
-
34
- ## API Endpoints
35
-
36
- ### Authentication
37
- - `POST /auth/register` - Register new user
38
- - `POST /auth/login` - Login
39
- - `GET /auth/me` - Get current user (protected)
40
-
41
- ### Todos
42
- - `GET /todos` - Get all todos (protected)
43
- - `GET /todos/:id` - Get single todo (protected)
44
- - `POST /todos` - Create todo (protected)
45
- - `PUT /todos/:id` - Update todo (protected)
46
- - `DELETE /todos/:id` - Delete todo (protected)
47
-
48
- ### Users
49
- - `GET /users/me` - Get current user profile (protected)
50
-
51
- ## Environment Variables
52
-
53
- ```env
54
- DATABASE_URL="file:./dev.db"
55
- JWT_SECRET="your-secret-key"
56
- JWT_EXPIRES_IN="7d"
57
- PORT=5050
58
- ```
59
-
60
- ## Database
61
-
62
- Using Prisma with SQLite for development. To create a new migration:
63
-
64
- ```bash
65
- npm run prisma:migrate
66
- ```
67
-
68
- To view database in Prisma Studio:
69
-
70
- ```bash
71
- npm run prisma:studio
72
- ```
73
-
74
- ## Building for Production
75
-
76
- ```bash
77
- npm run build
78
- npm run start:prod
79
- ```
1
+ # Deprecated Legacy API Template
2
+
3
+ This template predates the verified `examples/hello-rpc` runtime/RPC/security model. It is retained for compatibility and should not be used as the production reference.
4
+
5
+ Use `examples/hello-rpc` for the canonical generated-RPC path.
6
+
7
+ ---
8
+
9
+ # Fusion NestJS API
10
+
11
+ Complete NestJS 10 backend with authentication, Prisma ORM, and CRUD operations.
12
+
13
+ ## Features
14
+
15
+ - ✅ JWT Authentication
16
+ - ✅ Prisma ORM (SQLite for development)
17
+ - ✅ User Management
18
+ - Todo CRUD Operations
19
+ - ⚠️ Legacy Fusion decorator notes; canonical RPC uses `@RpcService()` and `@RpcMethod()`
20
+ - ✅ Fastify Adapter
21
+ - Input Validation
22
+
23
+ ## Setup
24
+
25
+ ```bash
26
+ # Install dependencies
27
+ npm install
28
+
29
+ # Copy environment variables
30
+ cp .env.example .env
31
+
32
+ # Generate Prisma client
33
+ npm run prisma:generate
34
+
35
+ # Run migrations
36
+ npm run prisma:migrate
37
+
38
+ # Start development server
39
+ npm run start:dev
40
+ ```
41
+
42
+ ## API Endpoints
43
+
44
+ ### Authentication
45
+ - `POST /auth/register` - Register new user
46
+ - `POST /auth/login` - Login
47
+ - `GET /auth/me` - Get current user (protected)
48
+
49
+ ### Todos
50
+ - `GET /todos` - Get all todos (protected)
51
+ - `GET /todos/:id` - Get single todo (protected)
52
+ - `POST /todos` - Create todo (protected)
53
+ - `PUT /todos/:id` - Update todo (protected)
54
+ - `DELETE /todos/:id` - Delete todo (protected)
55
+
56
+ ### Users
57
+ - `GET /users/me` - Get current user profile (protected)
58
+
59
+ ## Environment Variables
60
+
61
+ ```env
62
+ DATABASE_URL="file:./dev.db"
63
+ JWT_SECRET="your-secret-key"
64
+ JWT_EXPIRES_IN="7d"
65
+ PORT=5050
66
+ ```
67
+
68
+ ## Database
69
+
70
+ Using Prisma with SQLite for development. To create a new migration:
71
+
72
+ ```bash
73
+ npm run prisma:migrate
74
+ ```
75
+
76
+ To view database in Prisma Studio:
77
+
78
+ ```bash
79
+ npm run prisma:studio
80
+ ```
81
+
82
+ ## Building for Production
83
+
84
+ ```bash
85
+ npm run build
86
+ npm run start:prod
87
+ ```
@@ -1,7 +1,7 @@
1
- {
2
- "collection": "@nestjs/schematics",
3
- "sourceRoot": "src",
4
- "compilerOptions": {
5
- "deleteOutDir": true
6
- }
1
+ {
2
+ "collection": "@nestjs/schematics",
3
+ "sourceRoot": "src",
4
+ "compilerOptions": {
5
+ "deleteOutDir": true
6
+ }
7
7
  }
@@ -1,41 +1,41 @@
1
- {
2
- "name": "wexts-api",
3
- "version": "1.0.0",
4
- "description": "wexts NestJS API",
5
- "scripts": {
6
- "build": "nest build",
7
- "dev": "nest start --watch",
8
- "start": "nest start",
9
- "start:dev": "nest start --watch",
10
- "start:prod": "node dist/main",
11
- "prisma:generate": "prisma generate",
12
- "prisma:migrate": "prisma migrate dev",
13
- "prisma:studio": "prisma studio"
14
- },
15
- "dependencies": {
16
- "@nestjs/common": "^11.0.0",
17
- "@nestjs/config": "^4.0.2",
18
- "@nestjs/core": "^11.0.0",
19
- "@nestjs/jwt": "^11.0.0",
20
- "@nestjs/passport": "^11.0.0",
21
- "@nestjs/platform-fastify": "^11.0.0",
22
- "@prisma/client": "^6.0.0",
23
- "bcrypt": "^5.1.1",
24
- "class-transformer": "^0.5.1",
25
- "class-validator": "^0.14.1",
26
- "passport": "^0.7.0",
27
- "passport-jwt": "^4.0.1",
28
- "reflect-metadata": "^0.2.2",
29
- "rxjs": "^7.8.1",
30
- "wexts": "^2.0.0"
31
- },
32
- "devDependencies": {
33
- "@nestjs/cli": "^11.0.0",
34
- "@nestjs/schematics": "^11.0.0",
35
- "@types/bcrypt": "^5.0.2",
36
- "@types/node": "^22.0.0",
37
- "@types/passport-jwt": "^4.0.1",
38
- "prisma": "^6.0.0",
39
- "typescript": "^5.9.3"
40
- }
1
+ {
2
+ "name": "wexts-api",
3
+ "version": "1.0.0",
4
+ "description": "wexts NestJS API",
5
+ "scripts": {
6
+ "build": "nest build",
7
+ "dev": "nest start --watch",
8
+ "start": "nest start",
9
+ "start:dev": "nest start --watch",
10
+ "start:prod": "node dist/main",
11
+ "prisma:generate": "prisma generate",
12
+ "prisma:migrate": "prisma migrate dev",
13
+ "prisma:studio": "prisma studio"
14
+ },
15
+ "dependencies": {
16
+ "@nestjs/common": "^11.0.0",
17
+ "@nestjs/config": "^4.0.2",
18
+ "@nestjs/core": "^11.0.0",
19
+ "@nestjs/jwt": "^11.0.0",
20
+ "@nestjs/passport": "^11.0.0",
21
+ "@nestjs/platform-fastify": "^11.0.0",
22
+ "@prisma/client": "^6.0.0",
23
+ "bcrypt": "^5.1.1",
24
+ "class-transformer": "^0.5.1",
25
+ "class-validator": "^0.14.1",
26
+ "passport": "^0.7.0",
27
+ "passport-jwt": "^4.0.1",
28
+ "reflect-metadata": "^0.2.2",
29
+ "rxjs": "^7.8.1",
30
+ "wexts": "^2.0.0"
31
+ },
32
+ "devDependencies": {
33
+ "@nestjs/cli": "^11.0.0",
34
+ "@nestjs/schematics": "^11.0.0",
35
+ "@types/bcrypt": "^5.0.2",
36
+ "@types/node": "^22.0.0",
37
+ "@types/passport-jwt": "^4.0.1",
38
+ "prisma": "^6.0.0",
39
+ "typescript": "^5.9.3"
40
+ }
41
41
  }
File without changes
@@ -1,29 +1,29 @@
1
- generator client {
2
- provider = "prisma-client-js"
3
- }
4
-
5
- datasource db {
6
- provider = "sqlite"
7
- url = env("DATABASE_URL")
8
- }
9
-
10
- model User {
11
- id String @id @default(uuid())
12
- email String @unique
13
- name String?
14
- password String
15
- createdAt DateTime @default(now())
16
- updatedAt DateTime @updatedAt
17
- todos Todo[]
18
- }
19
-
20
- model Todo {
21
- id String @id @default(uuid())
22
- title String
23
- description String?
24
- completed Boolean @default(false)
25
- userId String
26
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
27
- createdAt DateTime @default(now())
28
- updatedAt DateTime @updatedAt
29
- }
1
+ generator client {
2
+ provider = "prisma-client-js"
3
+ }
4
+
5
+ datasource db {
6
+ provider = "sqlite"
7
+ url = env("DATABASE_URL")
8
+ }
9
+
10
+ model User {
11
+ id String @id @default(uuid())
12
+ email String @unique
13
+ name String?
14
+ password String
15
+ createdAt DateTime @default(now())
16
+ updatedAt DateTime @updatedAt
17
+ todos Todo[]
18
+ }
19
+
20
+ model Todo {
21
+ id String @id @default(uuid())
22
+ title String
23
+ description String?
24
+ completed Boolean @default(false)
25
+ userId String
26
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
27
+ createdAt DateTime @default(now())
28
+ updatedAt DateTime @updatedAt
29
+ }
@@ -1,17 +1,17 @@
1
- import { Module } from '@nestjs/common';
2
- import { ConfigModule } from '@nestjs/config';
3
- import { PrismaModule } from './prisma/prisma.module';
4
- import { AuthModule } from './auth/auth.module';
5
- import { UsersModule } from './users/users.module';
6
- import { TodosModule } from './todos/todos.module';
7
-
8
- @Module({
9
- imports: [
10
- ConfigModule.forRoot({ isGlobal: true }),
11
- PrismaModule,
12
- AuthModule,
13
- UsersModule,
14
- TodosModule,
15
- ],
16
- })
17
- export class AppModule { }
1
+ import { Module } from '@nestjs/common';
2
+ import { ConfigModule } from '@nestjs/config';
3
+ import { PrismaModule } from './prisma/prisma.module';
4
+ import { AuthModule } from './auth/auth.module';
5
+ import { UsersModule } from './users/users.module';
6
+ import { TodosModule } from './todos/todos.module';
7
+
8
+ @Module({
9
+ imports: [
10
+ ConfigModule.forRoot({ isGlobal: true }),
11
+ PrismaModule,
12
+ AuthModule,
13
+ UsersModule,
14
+ TodosModule,
15
+ ],
16
+ })
17
+ export class AppModule { }
@@ -1,27 +1,27 @@
1
- import { Controller, Post, Get, Body, UseGuards, Request, Inject } from '@nestjs/common';
2
- import { AuthService } from './auth.service';
3
- import { JwtAuthGuard } from './guards/jwt-auth.guard';
4
- import { RegisterDto, LoginDto } from './dto/auth.dto';
5
-
6
- @Controller('auth')
7
- export class AuthController {
8
- constructor(
9
- @Inject(AuthService) private readonly authService: AuthService
10
- ) { }
11
-
12
- @Post('register')
13
- async register(@Body() dto: RegisterDto) {
14
- return this.authService.register(dto);
15
- }
16
-
17
- @Post('login')
18
- async login(@Body() dto: LoginDto) {
19
- return this.authService.login(dto);
20
- }
21
-
22
- @Get('me')
23
- @UseGuards(JwtAuthGuard)
24
- async getMe(@Request() req) {
25
- return this.authService.getMe(req.user.userId);
26
- }
27
- }
1
+ import { Controller, Post, Get, Body, UseGuards, Request, Inject } from '@nestjs/common';
2
+ import { AuthService } from './auth.service';
3
+ import { JwtAuthGuard } from './guards/jwt-auth.guard';
4
+ import { RegisterDto, LoginDto } from './dto/auth.dto';
5
+
6
+ @Controller('auth')
7
+ export class AuthController {
8
+ constructor(
9
+ @Inject(AuthService) private readonly authService: AuthService
10
+ ) { }
11
+
12
+ @Post('register')
13
+ async register(@Body() dto: RegisterDto) {
14
+ return this.authService.register(dto);
15
+ }
16
+
17
+ @Post('login')
18
+ async login(@Body() dto: LoginDto) {
19
+ return this.authService.login(dto);
20
+ }
21
+
22
+ @Get('me')
23
+ @UseGuards(JwtAuthGuard)
24
+ async getMe(@Request() req) {
25
+ return this.authService.getMe(req.user.userId);
26
+ }
27
+ }
@@ -1,29 +1,37 @@
1
- import { Module } from '@nestjs/common';
2
- import { JwtModule } from '@nestjs/jwt';
3
- import { PassportModule } from '@nestjs/passport';
4
- import { ConfigModule, ConfigService } from '@nestjs/config';
5
- import { AuthController } from './auth.controller';
6
- import { AuthService } from './auth.service';
7
- import { JwtStrategy } from './strategies/jwt.strategy';
8
- import { PrismaModule } from '../prisma/prisma.module';
9
-
10
- @Module({
11
- imports: [
12
- PrismaModule, // ✅ Important: Import PrismaModule
13
- ConfigModule,
14
- PassportModule,
15
- JwtModule.registerAsync({
16
- inject: [ConfigService],
17
- useFactory: (config: ConfigService) => ({
18
- secret: config.get('JWT_SECRET') || 'default-secret',
19
- signOptions: {
20
- expiresIn: config.get('JWT_EXPIRES_IN') || '7d',
21
- },
22
- }),
23
- }),
24
- ],
25
- controllers: [AuthController],
26
- providers: [AuthService, JwtStrategy],
27
- exports: [AuthService],
28
- })
29
- export class AuthModule { }
1
+ import { Module } from '@nestjs/common';
2
+ import { JwtModule } from '@nestjs/jwt';
3
+ import { PassportModule } from '@nestjs/passport';
4
+ import { ConfigModule, ConfigService } from '@nestjs/config';
5
+ import { AuthController } from './auth.controller';
6
+ import { AuthService } from './auth.service';
7
+ import { JwtStrategy } from './strategies/jwt.strategy';
8
+ import { PrismaModule } from '../prisma/prisma.module';
9
+
10
+ @Module({
11
+ imports: [
12
+ PrismaModule, // ✅ Important: Import PrismaModule
13
+ ConfigModule,
14
+ PassportModule,
15
+ JwtModule.registerAsync({
16
+ inject: [ConfigService],
17
+ useFactory: (config: ConfigService) => ({
18
+ secret: getJwtSecret(config),
19
+ signOptions: {
20
+ expiresIn: config.get('JWT_EXPIRES_IN') || '7d',
21
+ },
22
+ }),
23
+ }),
24
+ ],
25
+ controllers: [AuthController],
26
+ providers: [AuthService, JwtStrategy],
27
+ exports: [AuthService],
28
+ })
29
+ export class AuthModule { }
30
+
31
+ function getJwtSecret(config: ConfigService): string {
32
+ const secret = config.get<string>('JWT_SECRET');
33
+ if (!secret || secret.length < 32) {
34
+ throw new Error('JWT_SECRET must be set to at least 32 characters.');
35
+ }
36
+ return secret;
37
+ }
@@ -1,86 +1,86 @@
1
- import { Injectable, UnauthorizedException, Inject } from '@nestjs/common';
2
- import { JwtService } from '@nestjs/jwt';
3
- import { PrismaService } from '../prisma/prisma.service';
4
- import * as bcrypt from 'bcryptjs';
5
- import { RegisterDto, LoginDto } from './dto/auth.dto';
6
-
7
- @Injectable()
8
- export class AuthService {
9
- constructor(
10
- @Inject(PrismaService) private readonly prisma: PrismaService,
11
- @Inject(JwtService) private readonly jwtService: JwtService,
12
- ) { }
13
-
14
- async register(dto: RegisterDto) {
15
- const exists = await this.prisma.user.findUnique({
16
- where: { email: dto.email },
17
- });
18
-
19
- if (exists) {
20
- throw new UnauthorizedException('Email already registered');
21
- }
22
-
23
- const hashedPassword = await bcrypt.hash(dto.password, 10);
24
-
25
- const user = await this.prisma.user.create({
26
- data: {
27
- email: dto.email,
28
- name: dto.name,
29
- password: hashedPassword,
30
- },
31
- select: {
32
- id: true,
33
- email: true,
34
- name: true,
35
- createdAt: true,
36
- },
37
- });
38
-
39
- const access_token = this.generateToken(user.id, user.email);
40
-
41
- return { user, access_token };
42
- }
43
-
44
- async login(dto: LoginDto) {
45
- const user = await this.prisma.user.findUnique({
46
- where: { email: dto.email },
47
- });
48
-
49
- if (!user) {
50
- throw new UnauthorizedException('Invalid credentials');
51
- }
52
-
53
- const valid = await bcrypt.compare(dto.password, user.password);
54
-
55
- if (!valid) {
56
- throw new UnauthorizedException('Invalid credentials');
57
- }
58
-
59
- const access_token = this.generateToken(user.id, user.email);
60
-
61
- return {
62
- user: {
63
- id: user.id,
64
- email: user.email,
65
- name: user.name,
66
- },
67
- access_token,
68
- };
69
- }
70
-
71
- async getMe(userId: string) {
72
- return this.prisma.user.findUnique({
73
- where: { id: userId },
74
- select: {
75
- id: true,
76
- email: true,
77
- name: true,
78
- createdAt: true,
79
- },
80
- });
81
- }
82
-
83
- private generateToken(userId: string, email: string): string {
84
- return this.jwtService.sign({ sub: userId, email });
85
- }
86
- }
1
+ import { Injectable, UnauthorizedException, Inject } from '@nestjs/common';
2
+ import { JwtService } from '@nestjs/jwt';
3
+ import { PrismaService } from '../prisma/prisma.service';
4
+ import * as bcrypt from 'bcryptjs';
5
+ import { RegisterDto, LoginDto } from './dto/auth.dto';
6
+
7
+ @Injectable()
8
+ export class AuthService {
9
+ constructor(
10
+ @Inject(PrismaService) private readonly prisma: PrismaService,
11
+ @Inject(JwtService) private readonly jwtService: JwtService,
12
+ ) { }
13
+
14
+ async register(dto: RegisterDto) {
15
+ const exists = await this.prisma.user.findUnique({
16
+ where: { email: dto.email },
17
+ });
18
+
19
+ if (exists) {
20
+ throw new UnauthorizedException('Email already registered');
21
+ }
22
+
23
+ const hashedPassword = await bcrypt.hash(dto.password, 10);
24
+
25
+ const user = await this.prisma.user.create({
26
+ data: {
27
+ email: dto.email,
28
+ name: dto.name,
29
+ password: hashedPassword,
30
+ },
31
+ select: {
32
+ id: true,
33
+ email: true,
34
+ name: true,
35
+ createdAt: true,
36
+ },
37
+ });
38
+
39
+ const access_token = this.generateToken(user.id, user.email);
40
+
41
+ return { user, access_token };
42
+ }
43
+
44
+ async login(dto: LoginDto) {
45
+ const user = await this.prisma.user.findUnique({
46
+ where: { email: dto.email },
47
+ });
48
+
49
+ if (!user) {
50
+ throw new UnauthorizedException('Invalid credentials');
51
+ }
52
+
53
+ const valid = await bcrypt.compare(dto.password, user.password);
54
+
55
+ if (!valid) {
56
+ throw new UnauthorizedException('Invalid credentials');
57
+ }
58
+
59
+ const access_token = this.generateToken(user.id, user.email);
60
+
61
+ return {
62
+ user: {
63
+ id: user.id,
64
+ email: user.email,
65
+ name: user.name,
66
+ },
67
+ access_token,
68
+ };
69
+ }
70
+
71
+ async getMe(userId: string) {
72
+ return this.prisma.user.findUnique({
73
+ where: { id: userId },
74
+ select: {
75
+ id: true,
76
+ email: true,
77
+ name: true,
78
+ createdAt: true,
79
+ },
80
+ });
81
+ }
82
+
83
+ private generateToken(userId: string, email: string): string {
84
+ return this.jwtService.sign({ sub: userId, email });
85
+ }
86
+ }