create-nexgen 1.0.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 (240) hide show
  1. package/package.json +26 -0
  2. package/src/index.js +108 -0
  3. package/template/.dockerignore +14 -0
  4. package/template/.env +58 -0
  5. package/template/.env.example +59 -0
  6. package/template/.prettierignore +5 -0
  7. package/template/.prettierrc +8 -0
  8. package/template/README.md +447 -0
  9. package/template/drizzle.config.ts +29 -0
  10. package/template/eslint.config.js +52 -0
  11. package/template/gitignore-stub +24 -0
  12. package/template/package.json +96 -0
  13. package/template/public/assets/AuthLayout-CbswhpjJ.js +1 -0
  14. package/template/public/assets/Button-_7aQ7gHL.js +1 -0
  15. package/template/public/assets/Input-CLNJXmKc.css +1 -0
  16. package/template/public/assets/Input-z8GI8Aqo.js +1 -0
  17. package/template/public/assets/InputPasswordToggle-BxlzVGp3.js +1 -0
  18. package/template/public/assets/InputPasswordToggle-C77FI9Eg.css +1 -0
  19. package/template/public/assets/Layout-DotR1sQC.js +1 -0
  20. package/template/public/assets/Refresh-BdqsPPBC.js +1 -0
  21. package/template/public/assets/admin-ui-CU34rLdN.js +1 -0
  22. package/template/public/assets/bootstrap-icons-BeopsB42.woff +0 -0
  23. package/template/public/assets/bootstrap-icons-mSm7cUeB.woff2 +0 -0
  24. package/template/public/assets/dashboard-CwybEyLc.js +1 -0
  25. package/template/public/assets/dashboard-Dc4d-Pi7.css +1 -0
  26. package/template/public/assets/forgetPassword-CKEJaXsq.js +1 -0
  27. package/template/public/assets/index-Bleyx5dm.js +64 -0
  28. package/template/public/assets/index-DUw8E6Yg.css +1 -0
  29. package/template/public/assets/login-DC7PTlQF.js +1 -0
  30. package/template/public/assets/realtime-test-BPQdrFym.css +1 -0
  31. package/template/public/assets/realtime-test-tQZ0rBEJ.js +1 -0
  32. package/template/public/assets/register-3O7Qs28C.js +1 -0
  33. package/template/public/assets/resetPassword-A5AzMWKs.js +1 -0
  34. package/template/public/assets/verifyEmail-DDBEQHOv.js +1 -0
  35. package/template/public/index.html +17 -0
  36. package/template/src/database/migrations/mysql/0000_init.sql +73 -0
  37. package/template/src/database/migrations/mysql/meta/0000_snapshot.json +484 -0
  38. package/template/src/database/migrations/mysql/meta/_journal.json +13 -0
  39. package/template/src/database/schema.ts +4 -0
  40. package/template/src/env.ts +107 -0
  41. package/template/src/framework/cache/cache.ts +81 -0
  42. package/template/src/framework/database/connection.ts +168 -0
  43. package/template/src/framework/database/optional-db-drivers.d.ts +9 -0
  44. package/template/src/framework/database/paginate.ts +200 -0
  45. package/template/src/framework/database/schema.ts +26 -0
  46. package/template/src/framework/database/seed.ts +33 -0
  47. package/template/src/framework/events/dispatcher.ts +57 -0
  48. package/template/src/framework/facade.ts +27 -0
  49. package/template/src/framework/http/app.ts +61 -0
  50. package/template/src/framework/http/cors.ts +19 -0
  51. package/template/src/framework/http/logger.ts +85 -0
  52. package/template/src/framework/http/openapi.ts +34 -0
  53. package/template/src/framework/http/ratelimiter.ts +13 -0
  54. package/template/src/framework/http/router.ts +76 -0
  55. package/template/src/framework/http/static.ts +33 -0
  56. package/template/src/framework/http/validation.ts +24 -0
  57. package/template/src/framework/kernel.ts +40 -0
  58. package/template/src/framework/maker-cli/src/index.mjs +51 -0
  59. package/template/src/framework/maker-cli/src/levels/level-1/env-db.mjs +57 -0
  60. package/template/src/framework/maker-cli/src/levels/level-1/file-ops.mjs +30 -0
  61. package/template/src/framework/maker-cli/src/levels/level-1/flags.mjs +16 -0
  62. package/template/src/framework/maker-cli/src/levels/level-1/help.mjs +24 -0
  63. package/template/src/framework/maker-cli/src/levels/level-1/naming.mjs +13 -0
  64. package/template/src/framework/maker-cli/src/levels/level-1/process.mjs +47 -0
  65. package/template/src/framework/maker-cli/src/levels/level-2/db/core.mjs +299 -0
  66. package/template/src/framework/maker-cli/src/levels/level-2/db/index.mjs +177 -0
  67. package/template/src/framework/maker-cli/src/levels/level-2/deploy/core.mjs +635 -0
  68. package/template/src/framework/maker-cli/src/levels/level-2/deploy/index.mjs +145 -0
  69. package/template/src/framework/maker-cli/src/levels/level-2/module/core.mjs +707 -0
  70. package/template/src/framework/maker-cli/src/levels/level-2/module/index.mjs +116 -0
  71. package/template/src/framework/maker-cli/src/levels/level-2/runtime/build-frontend.mjs +16 -0
  72. package/template/src/framework/maker-cli/src/levels/level-2/runtime/core.mjs +311 -0
  73. package/template/src/framework/maker-cli/src/levels/level-2/runtime/index.mjs +71 -0
  74. package/template/src/framework/maker-cli/stubs/controller/openapi.ts.stub +55 -0
  75. package/template/src/framework/maker-cli/stubs/controller/openapi.with-model.ts.stub +56 -0
  76. package/template/src/framework/maker-cli/stubs/controller/plain.ts.stub +57 -0
  77. package/template/src/framework/maker-cli/stubs/controller/schema.plain.ts.stub +13 -0
  78. package/template/src/framework/maker-cli/stubs/controller/schema.ts.stub +32 -0
  79. package/template/src/framework/maker-cli/stubs/deploy/Dockerfile.bun.stub +49 -0
  80. package/template/src/framework/maker-cli/stubs/deploy/Dockerfile.pnpm.stub +53 -0
  81. package/template/src/framework/maker-cli/stubs/deploy/Dockerfile.stub +49 -0
  82. package/template/src/framework/maker-cli/stubs/deploy/Dockerfile.yarn.stub +53 -0
  83. package/template/src/framework/maker-cli/stubs/deploy/README.stub +55 -0
  84. package/template/src/framework/maker-cli/stubs/deploy/compose/mysql.server.stub +29 -0
  85. package/template/src/framework/maker-cli/stubs/deploy/compose/postgres.server.stub +29 -0
  86. package/template/src/framework/maker-cli/stubs/deploy/compose/sqlite.stub +29 -0
  87. package/template/src/framework/maker-cli/stubs/deploy/env/mysql.server.stub +73 -0
  88. package/template/src/framework/maker-cli/stubs/deploy/env/postgres.server.stub +73 -0
  89. package/template/src/framework/maker-cli/stubs/deploy/env/sqlite.stub +72 -0
  90. package/template/src/framework/maker-cli/stubs/deploy/scripts/auto-migrate.sh.stub +15 -0
  91. package/template/src/framework/maker-cli/stubs/deploy/server/README.stub +77 -0
  92. package/template/src/framework/maker-cli/stubs/deploy/server/compose/noredis.stub +118 -0
  93. package/template/src/framework/maker-cli/stubs/deploy/server/compose/redis.dev.stub +131 -0
  94. package/template/src/framework/maker-cli/stubs/deploy/server/compose/redis.stub +129 -0
  95. package/template/src/framework/maker-cli/stubs/deploy/server/env/local.example.stub +10 -0
  96. package/template/src/framework/maker-cli/stubs/deploy/server/env/noredis.stub +24 -0
  97. package/template/src/framework/maker-cli/stubs/deploy/server/env/redis.stub +24 -0
  98. package/template/src/framework/maker-cli/stubs/deploy/server/nginx-vhost/README.stub +15 -0
  99. package/template/src/framework/maker-cli/stubs/deploy/server/nginx-vhost/app.example.com.stub +12 -0
  100. package/template/src/framework/maker-cli/stubs/deploy/server/pgadmin/servers.stub +13 -0
  101. package/template/src/framework/maker-cli/stubs/deploy/server/redis/redis.conf.stub +6 -0
  102. package/template/src/framework/maker-cli/stubs/deploy/supervisor/noredis.stub +53 -0
  103. package/template/src/framework/maker-cli/stubs/deploy/supervisor/redis.stub +69 -0
  104. package/template/src/framework/maker-cli/stubs/deploy/workflow/local.json.stub +24 -0
  105. package/template/src/framework/maker-cli/stubs/deploy/workflow/remote.json.stub +20 -0
  106. package/template/src/framework/maker-cli/stubs/example/console.ts.stub +33 -0
  107. package/template/src/framework/maker-cli/stubs/example/controller.ts.stub +503 -0
  108. package/template/src/framework/maker-cli/stubs/example/job.ts.stub +74 -0
  109. package/template/src/framework/maker-cli/stubs/example/route.api.ts.stub +206 -0
  110. package/template/src/framework/maker-cli/stubs/example/schema.ts.stub +41 -0
  111. package/template/src/framework/maker-cli/stubs/job/name.ts.stub +24 -0
  112. package/template/src/framework/maker-cli/stubs/model/name.mysql.ts.stub +8 -0
  113. package/template/src/framework/maker-cli/stubs/model/name.postgresql.ts.stub +8 -0
  114. package/template/src/framework/maker-cli/stubs/model/name.sqlite.ts.stub +8 -0
  115. package/template/src/framework/maker-cli/stubs/notification/NotificationBell.vue.stub +218 -0
  116. package/template/src/framework/maker-cli/stubs/notification/controller.ts.stub +85 -0
  117. package/template/src/framework/maker-cli/stubs/notification/index.vue.stub +211 -0
  118. package/template/src/framework/maker-cli/stubs/notification/job.ts.stub +12 -0
  119. package/template/src/framework/maker-cli/stubs/notification/route.api.ts.stub +49 -0
  120. package/template/src/framework/maker-cli/stubs/notification/schema.ts.stub +25 -0
  121. package/template/src/framework/maker-cli/stubs/route/api.ts.stub +79 -0
  122. package/template/src/framework/maker-cli/stubs/route/plain.ts.stub +10 -0
  123. package/template/src/framework/maker-cli/stubs/schedule/name.ts.stub +35 -0
  124. package/template/src/framework/maker-cli/stubs/seeder/name.ts.stub +17 -0
  125. package/template/src/framework/modules/discover.ts +54 -0
  126. package/template/src/framework/modules/routes.ts +26 -0
  127. package/template/src/framework/notification/index.ts +109 -0
  128. package/template/src/framework/queue/clear.ts +20 -0
  129. package/template/src/framework/queue/queue.ts +213 -0
  130. package/template/src/framework/queue/ui.ts +104 -0
  131. package/template/src/framework/queue/worker.ts +33 -0
  132. package/template/src/framework/realtime/broadcast.ts +27 -0
  133. package/template/src/framework/realtime/index.ts +1 -0
  134. package/template/src/framework/realtime/socket-cookie.ts +65 -0
  135. package/template/src/framework/realtime/socket.ts +132 -0
  136. package/template/src/framework/realtime/types.ts +6 -0
  137. package/template/src/framework/realtime/ui.ts +16 -0
  138. package/template/src/framework/redis/client.ts +126 -0
  139. package/template/src/framework/scheduler/lock.ts +124 -0
  140. package/template/src/framework/scheduler/run.ts +26 -0
  141. package/template/src/framework/scheduler/scheduler.ts +82 -0
  142. package/template/src/framework/server.ts +147 -0
  143. package/template/src/framework/session/session.ts +116 -0
  144. package/template/src/framework/storage/storage.ts +743 -0
  145. package/template/src/framework/support/cookie.ts +78 -0
  146. package/template/src/framework/support/jwt.ts +45 -0
  147. package/template/src/framework/support/lifecycle.ts +35 -0
  148. package/template/src/framework/support/logger.ts +102 -0
  149. package/template/src/framework/support/mail.ts +43 -0
  150. package/template/src/framework/support/password.ts +23 -0
  151. package/template/src/framework/support/url.ts +25 -0
  152. package/template/src/middlewares/auth-middleware.ts +98 -0
  153. package/template/src/middlewares/role-middleware.ts +24 -0
  154. package/template/src/modules/auth/controllers/auth.controller.ts +445 -0
  155. package/template/src/modules/auth/controllers/auth.helpers.ts +110 -0
  156. package/template/src/modules/auth/controllers/auth.schema.ts +102 -0
  157. package/template/src/modules/auth/controllers/role.controller.ts +25 -0
  158. package/template/src/modules/auth/database/models/notifications.ts +22 -0
  159. package/template/src/modules/auth/database/models/role.ts +14 -0
  160. package/template/src/modules/auth/database/models/user.ts +46 -0
  161. package/template/src/modules/auth/database/seeders/role.ts +19 -0
  162. package/template/src/modules/auth/database/seeders/user.ts +33 -0
  163. package/template/src/modules/auth/jobs/forgetpass.ts +18 -0
  164. package/template/src/modules/auth/jobs/registeruser.ts +31 -0
  165. package/template/src/modules/auth/jobs/verifyemail.ts +18 -0
  166. package/template/src/modules/auth/routes/api.ts +151 -0
  167. package/template/src/modules/auth/routes/role.ts +39 -0
  168. package/template/src/modules/welcome/controllers/welcome.controller.ts +14 -0
  169. package/template/src/modules/welcome/controllers/welcome.schema.ts +6 -0
  170. package/template/src/modules/welcome/database/models/welcome.ts +6 -0
  171. package/template/src/modules/welcome/routes/api.ts +20 -0
  172. package/template/src/resources/index.html +16 -0
  173. package/template/src/resources/src/App.vue +5 -0
  174. package/template/src/resources/src/assets/css/styles.css +14934 -0
  175. package/template/src/resources/src/assets/css/styles.css.map +1 -0
  176. package/template/src/resources/src/assets/images/favicon/favicon.ico +0 -0
  177. package/template/src/resources/src/assets/images/favicon/favicon1.ico +0 -0
  178. package/template/src/resources/src/assets/images/logo-1.png +0 -0
  179. package/template/src/resources/src/assets/images/logo-dark-sm.png +0 -0
  180. package/template/src/resources/src/assets/images/logo-dark.png +0 -0
  181. package/template/src/resources/src/assets/images/logo-dark1.png +0 -0
  182. package/template/src/resources/src/assets/images/logo-sm.png +0 -0
  183. package/template/src/resources/src/assets/images/logo1.png +0 -0
  184. package/template/src/resources/src/assets/images/logo2.png +0 -0
  185. package/template/src/resources/src/assets/scss/custom.css +217 -0
  186. package/template/src/resources/src/assets/scss/custom.css.map +1 -0
  187. package/template/src/resources/src/assets/scss/custom.scss +1100 -0
  188. package/template/src/resources/src/components/Button.vue +35 -0
  189. package/template/src/resources/src/components/Checkbox.vue +29 -0
  190. package/template/src/resources/src/components/FloatButton.vue +36 -0
  191. package/template/src/resources/src/components/Href.vue +32 -0
  192. package/template/src/resources/src/components/Input.vue +227 -0
  193. package/template/src/resources/src/components/InputGroup.vue +153 -0
  194. package/template/src/resources/src/components/InputPasswordToggle.vue +226 -0
  195. package/template/src/resources/src/components/Modal.vue +102 -0
  196. package/template/src/resources/src/components/Pagebar.vue +28 -0
  197. package/template/src/resources/src/components/Refresh.vue +26 -0
  198. package/template/src/resources/src/components/Select.vue +390 -0
  199. package/template/src/resources/src/components/Spinner.vue +42 -0
  200. package/template/src/resources/src/components/Switch.vue +65 -0
  201. package/template/src/resources/src/components/TextArea.vue +121 -0
  202. package/template/src/resources/src/components/Toast.vue +56 -0
  203. package/template/src/resources/src/components/datatable/DataTableSkeleton.vue +99 -0
  204. package/template/src/resources/src/components/datatable/Pagination.vue +161 -0
  205. package/template/src/resources/src/components/datatable/SelectOpption.vue +54 -0
  206. package/template/src/resources/src/components/datatable/index.vue +237 -0
  207. package/template/src/resources/src/composables/useAuth.ts +52 -0
  208. package/template/src/resources/src/composables/useBrowserDetect.ts +5 -0
  209. package/template/src/resources/src/composables/useDialog.ts +5 -0
  210. package/template/src/resources/src/composables/useGum.ts +3 -0
  211. package/template/src/resources/src/composables/usePulse.ts +5 -0
  212. package/template/src/resources/src/env.d.ts +20 -0
  213. package/template/src/resources/src/helpers/nformatter.ts +10 -0
  214. package/template/src/resources/src/helpers/utils.ts +68 -0
  215. package/template/src/resources/src/layouts/AuthLayout.vue +20 -0
  216. package/template/src/resources/src/layouts/Layout/Footer.vue +23 -0
  217. package/template/src/resources/src/layouts/Layout/Header.vue +90 -0
  218. package/template/src/resources/src/layouts/Layout/Sidebar.vue +137 -0
  219. package/template/src/resources/src/layouts/Layout/index.vue +76 -0
  220. package/template/src/resources/src/main.ts +27 -0
  221. package/template/src/resources/src/pages/auth/forgetPassword.vue +76 -0
  222. package/template/src/resources/src/pages/auth/login.vue +93 -0
  223. package/template/src/resources/src/pages/auth/register.vue +130 -0
  224. package/template/src/resources/src/pages/auth/resetPassword.vue +119 -0
  225. package/template/src/resources/src/pages/auth/verifyEmail.vue +60 -0
  226. package/template/src/resources/src/pages/dashboard/index.vue +76 -0
  227. package/template/src/resources/src/plugins/axios.ts +33 -0
  228. package/template/src/resources/src/plugins/browserDetect.ts +55 -0
  229. package/template/src/resources/src/plugins/dialog.ts +167 -0
  230. package/template/src/resources/src/plugins/gum.ts +343 -0
  231. package/template/src/resources/src/plugins/pulse.ts +141 -0
  232. package/template/src/resources/src/plugins/routeProgress.ts +87 -0
  233. package/template/src/resources/src/router/index.ts +85 -0
  234. package/template/src/resources/src/stores/admin-ui.ts +148 -0
  235. package/template/src/resources/src/stores/auth.ts +151 -0
  236. package/template/src/resources/tsconfig.json +19 -0
  237. package/template/src/resources/vite.config.ts +43 -0
  238. package/template/src/storage/logs/app.log +20179 -0
  239. package/template/src/storage/logs/fatal.log +727 -0
  240. package/template/tsconfig.json +20 -0
@@ -0,0 +1,206 @@
1
+ import { createRoute, createRouter, HttpStatusCodes, jsonContent, z } from "@/framework/facade.js";
2
+ import { env } from "@/env.js";
3
+ import { downloadGenerated, downloadGeneratedExcel, downloadGeneratedPdf, fire, fireBroadcast, fireQueued, fireQueuedBroadcast, generateDownload, generateExcelDownload, generatePdfDownload, importExcel, queueCommand, upload } from "@/modules/{{module}}/controllers/{{module}}.controller.js";
4
+ import { DownloadTokenSchema, ExcelDownloadRequestSchema, ExampleEventSchema, PdfGenerateAcceptedSchema, PdfGenerateRequestSchema, QueueCommandRequestSchema, UploadResponseSchema } from "@/modules/{{module}}/controllers/{{module}}.schema.js";
5
+
6
+ const eventRoute = createRoute({
7
+ path: "/event",
8
+ method: "post",
9
+ tags: ["Examples"],
10
+ request: {
11
+ body: jsonContent(ExampleEventSchema, "Examples event payload")
12
+ },
13
+ responses: {
14
+ [HttpStatusCodes.ACCEPTED]: jsonContent(z.object({ message: z.string(), data: ExampleEventSchema }), "Event accepted")
15
+ }
16
+ });
17
+
18
+ const queueCommandRoute = createRoute({
19
+ path: "/queue/command",
20
+ method: "post",
21
+ tags: ["Examples"],
22
+ request: {
23
+ body: jsonContent(QueueCommandRequestSchema, "Queue command payload")
24
+ },
25
+ responses: {
26
+ [HttpStatusCodes.ACCEPTED]: jsonContent(z.object({ message: z.string(), data: QueueCommandRequestSchema }), "Queue command dispatched")
27
+ }
28
+ });
29
+
30
+ const queuedEventRoute = createRoute({
31
+ path: "/event/queued",
32
+ method: "post",
33
+ tags: ["Examples"],
34
+ request: {
35
+ body: jsonContent(ExampleEventSchema, "Queued event payload")
36
+ },
37
+ responses: {
38
+ [HttpStatusCodes.ACCEPTED]: jsonContent(z.object({ message: z.string(), data: ExampleEventSchema }), "Queued event accepted")
39
+ }
40
+ });
41
+
42
+ const queuedBroadcastEventRoute = createRoute({
43
+ path: "/event/queued-broadcast",
44
+ method: "post",
45
+ tags: ["Examples"],
46
+ request: {
47
+ body: jsonContent(ExampleEventSchema, "Queued broadcast event payload")
48
+ },
49
+ responses: {
50
+ [HttpStatusCodes.ACCEPTED]: jsonContent(z.object({ message: z.string(), data: ExampleEventSchema }), "Queued broadcast event accepted")
51
+ }
52
+ });
53
+
54
+ const broadcastRoute = createRoute({
55
+ path: "/event/broadcast",
56
+ method: "post",
57
+ tags: ["Examples"],
58
+ responses: {
59
+ [HttpStatusCodes.OK]: jsonContent(z.object({
60
+ message: z.string(),
61
+ data: z.object({ message: z.string(), firedAt: z.string() })
62
+ }), "Broadcast event dispatched")
63
+ }
64
+ });
65
+
66
+ const uploadRoute = createRoute({
67
+ path: "/upload",
68
+ method: "post",
69
+ tags: ["Examples"],
70
+ request: {
71
+ body: {
72
+ content: {
73
+ "multipart/form-data": {
74
+ schema: z.object({ file: z.any().openapi({ type: "string", format: "binary" }) })
75
+ }
76
+ }
77
+ }
78
+ },
79
+ responses: {
80
+ [HttpStatusCodes.OK]: {
81
+ description: "File uploaded",
82
+ content: { "application/json": { schema: UploadResponseSchema } }
83
+ }
84
+ }
85
+ });
86
+
87
+ const importExcelRoute = createRoute({
88
+ path: "/import/excel",
89
+ method: "post",
90
+ tags: ["Examples"],
91
+ request: {
92
+ body: {
93
+ content: {
94
+ "multipart/form-data": {
95
+ schema: z.object({ file: z.any().openapi({ type: "string", format: "binary" }) })
96
+ }
97
+ }
98
+ }
99
+ },
100
+ responses: {
101
+ [HttpStatusCodes.OK]: jsonContent(z.object({
102
+ message: z.string(),
103
+ data: z.object({
104
+ sheetName: z.string(),
105
+ headers: z.array(z.string()),
106
+ totalRows: z.number(),
107
+ preview: z.array(z.record(z.string(), z.union([z.string(), z.number(), z.null()])))
108
+ })
109
+ }), "Excel import preview")
110
+ }
111
+ });
112
+
113
+ const generateDownloadRoute = createRoute({
114
+ path: "/download/generate",
115
+ method: "post",
116
+ tags: ["Examples"],
117
+ responses: {
118
+ [HttpStatusCodes.OK]: jsonContent(DownloadTokenSchema, "Temporary download token")
119
+ }
120
+ });
121
+
122
+ const downloadRoute = createRoute({
123
+ path: "/download/{token}",
124
+ method: "get",
125
+ tags: ["Examples"],
126
+ request: {
127
+ params: z.object({ token: z.string() })
128
+ },
129
+ responses: {
130
+ [HttpStatusCodes.OK]: { description: "Downloads generated file and deletes it" },
131
+ [HttpStatusCodes.NOT_FOUND]: jsonContent(z.object({ message: z.string() }), "Invalid token")
132
+ }
133
+ });
134
+
135
+ const generateExcelRoute = createRoute({
136
+ path: "/download/excel/generate",
137
+ method: "post",
138
+ tags: ["Examples"],
139
+ request: {
140
+ body: jsonContent(ExcelDownloadRequestSchema, "Excel generation payload")
141
+ },
142
+ responses: {
143
+ [HttpStatusCodes.OK]: jsonContent(DownloadTokenSchema, "Excel temporary download token")
144
+ }
145
+ });
146
+
147
+ const downloadExcelRoute = createRoute({
148
+ path: "/download/excel/{token}",
149
+ method: "get",
150
+ tags: ["Examples"],
151
+ request: {
152
+ params: z.object({ token: z.string() })
153
+ },
154
+ responses: {
155
+ [HttpStatusCodes.OK]: { description: "Downloads generated Excel file and deletes it" },
156
+ [HttpStatusCodes.NOT_FOUND]: jsonContent(z.object({ message: z.string() }), "Invalid token")
157
+ }
158
+ });
159
+
160
+ const generatePdfRoute = createRoute({
161
+ path: "/download/pdf/generate",
162
+ method: "post",
163
+ tags: ["Examples"],
164
+ request: {
165
+ body: jsonContent(PdfGenerateRequestSchema, "Hybrid PDF generation payload")
166
+ },
167
+ responses: {
168
+ [HttpStatusCodes.ACCEPTED]: jsonContent(PdfGenerateAcceptedSchema, "Queued or inline PDF response")
169
+ }
170
+ });
171
+
172
+ const downloadPdfRoute = createRoute({
173
+ path: "/download/pdf/{requestId}",
174
+ method: "get",
175
+ tags: ["Examples"],
176
+ request: {
177
+ params: z.object({ requestId: z.string() })
178
+ },
179
+ responses: {
180
+ [HttpStatusCodes.OK]: { description: "Downloads generated PDF" },
181
+ [HttpStatusCodes.ACCEPTED]: jsonContent(z.object({ message: z.string(), state: z.string() }), "Still generating"),
182
+ [HttpStatusCodes.NOT_FOUND]: jsonContent(z.object({ message: z.string() }), "Unknown request")
183
+ }
184
+ });
185
+
186
+ const enabled = env.ENABLE_EXAMPLES;
187
+ const router = createRouter();
188
+
189
+ if (enabled) {
190
+ router
191
+ .api(eventRoute, fire)
192
+ .api(queueCommandRoute, queueCommand)
193
+ .api(queuedEventRoute, fireQueued)
194
+ .api(queuedBroadcastEventRoute, fireQueuedBroadcast)
195
+ .api(broadcastRoute, fireBroadcast)
196
+ .api(uploadRoute, upload)
197
+ .api(importExcelRoute, importExcel)
198
+ .api(generateDownloadRoute, generateDownload)
199
+ .api(downloadRoute, downloadGenerated)
200
+ .api(generateExcelRoute, generateExcelDownload)
201
+ .api(downloadExcelRoute, downloadGeneratedExcel)
202
+ .api(generatePdfRoute, generatePdfDownload)
203
+ .api(downloadPdfRoute, downloadGeneratedPdf);
204
+ }
205
+
206
+ export default router;
@@ -0,0 +1,41 @@
1
+ import { z } from "@hono/zod-openapi";
2
+
3
+ export const ExampleEventSchema = z.object({
4
+ message: z.string(),
5
+ waitSeconds: z.number().optional()
6
+ });
7
+
8
+ export const UploadResponseSchema = z.object({
9
+ message: z.string(),
10
+ path: z.string(),
11
+ url: z.string()
12
+ });
13
+
14
+ export const DownloadTokenSchema = z.object({
15
+ message: z.string(),
16
+ token: z.string(),
17
+ downloadUrl: z.string()
18
+ });
19
+
20
+ export const ExcelDownloadRequestSchema = z.object({
21
+ title: z.string().min(2).max(100).default("Example Report")
22
+ });
23
+
24
+ export const QueueCommandRequestSchema = z.object({
25
+ message: z.string(),
26
+ waitSeconds: z.number().optional()
27
+ });
28
+
29
+ export const PdfGenerateRequestSchema = z.object({
30
+ title: z.string().min(2).max(100).default("Example PDF Report"),
31
+ rows: z.number().int().min(50).max(20000).default(1000),
32
+ chunkSize: z.number().int().min(50).max(1000).default(250)
33
+ });
34
+
35
+ export const PdfGenerateAcceptedSchema = z.object({
36
+ message: z.string(),
37
+ requestId: z.string(),
38
+ mode: z.enum(["queued", "inline"]),
39
+ statusUrl: z.string(),
40
+ downloadUrl: z.string()
41
+ });
@@ -0,0 +1,24 @@
1
+ import { DateTime } from "luxon";
2
+ import { shouldQueue, dispatchEvent } from "@/framework/facade.js";
3
+
4
+ /**
5
+ * event: Event name this worker listens to.
6
+ * queue: Queue name where jobs are consumed from.
7
+ * handler: Async processor that receives `job.data`.
8
+ */
9
+ shouldQueue("{{module}}.{{name}}", "default", async job => {
10
+ console.log("{{module}}.{{name}}", job.data);
11
+
12
+ /**
13
+ * dispatchEvent name: Event id to publish to listeners.
14
+ * payload: Data sent to queue/broadcast consumers.
15
+ * queue: Optional queue target for async event consumers.
16
+ * broadcast: Optional realtime fanout (all/users/roles/rooms).
17
+ */
18
+ // await dispatchEvent("{{module}}.{{name}}.finished", {
19
+ // ...job.data,
20
+ // processedAt: DateTime.now(),
21
+ // });
22
+
23
+ return { ok: true, processedAt: DateTime.now().toISO() };
24
+ });
@@ -0,0 +1,8 @@
1
+ import { relations } from "drizzle-orm";
2
+ import { int, mysqlTable, timestamp } from "drizzle-orm/mysql-core";
3
+
4
+ export const {{tableVariable}} = mysqlTable("{{tableName}}", {
5
+ id: int("id").autoincrement().primaryKey(),
6
+ createdAt: timestamp("created_at").defaultNow().notNull(),
7
+ updatedAt: timestamp("updated_at").defaultNow().notNull()
8
+ });
@@ -0,0 +1,8 @@
1
+ import { relations } from "drizzle-orm";
2
+ import { pgTable, serial, timestamp } from "drizzle-orm/pg-core";
3
+
4
+ export const {{tableVariable}} = pgTable("{{tableName}}", {
5
+ id: serial("id").primaryKey(),
6
+ createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
7
+ updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().notNull()
8
+ });
@@ -0,0 +1,8 @@
1
+ import { relations } from "drizzle-orm";
2
+ import { integer, sqliteTable } from "drizzle-orm/sqlite-core";
3
+
4
+ export const {{tableVariable}} = sqliteTable("{{tableName}}", {
5
+ id: integer("id").primaryKey({ autoIncrement: true }),
6
+ createdAt: integer("created_at", { mode: "timestamp" }).$defaultFn(() => new Date()).notNull(),
7
+ updatedAt: integer("updated_at", { mode: "timestamp" }).$defaultFn(() => new Date()).notNull()
8
+ });
@@ -0,0 +1,218 @@
1
+ <template>
2
+ <div class="btn-group order-3" ref="dropdownRef">
3
+ <button
4
+ type="button"
5
+ class="nav-btn position-relative"
6
+ data-bs-toggle="dropdown"
7
+ data-bs-display="static"
8
+ aria-expanded="false"
9
+ aria-label="notifications">
10
+ <i class="bi bi-bell"></i>
11
+ <span v-if="unread > 0" class="badge bg-danger notification-badge position-absolute" style="top:7.5%; right: 7.5%;">{{ unread > 99 ? '99+' : unread }}</span>
12
+ </button>
13
+ <div class="dropdown-menu notification-dropdown p-0">
14
+ <div class="dropdown-header d-flex align-items-center justify-content-between px-3 py-2">
15
+ <span class="fw-semibold">Notifications</span>
16
+ <button v-if="unread > 0" class="btn btn-sm btn-link p-0 text-decoration-none" @click="markAllRead">
17
+ Mark all read
18
+ </button>
19
+ </div>
20
+ <div class="notification-list">
21
+ <div v-if="items.length === 0" class="text-center text-secondary py-4 px-3">
22
+ No notifications
23
+ </div>
24
+ <div
25
+ v-for="item in items"
26
+ :key="item.id"
27
+ class="notification-item"
28
+ :class="{ unread: !item.readAt }"
29
+ @click="handleClick(item)">
30
+ <div class="d-flex align-items-start gap-2">
31
+ <i :class="iconClass(item.type)" class="mt-1"></i>
32
+ <div class="flex-grow-1 min-w-0">
33
+ <div class="notification-title">{{ item.title }}</div>
34
+ <div v-if="item.body" class="notification-body">{{ item.body }}</div>
35
+ <div class="notification-time">{{ timeAgo(item.createdAt) }}</div>
36
+ </div>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <router-link to="/notifications" class="dropdown-footer d-block text-center py-2 text-decoration-none">
41
+ View all notifications
42
+ </router-link>
43
+ </div>
44
+ </div>
45
+ </template>
46
+
47
+ <script setup lang="ts">
48
+ import { ref, onMounted, onUnmounted } from "vue";
49
+ import axios from "@/plugins/axios";
50
+ import { pulse } from "@/plugins/pulse";
51
+ import { useAuth } from "@/composables/useAuth";
52
+
53
+ const { user } = useAuth();
54
+
55
+ const unread = ref(0);
56
+ const items = ref<Array<{
57
+ id: number;
58
+ type: string;
59
+ title: string;
60
+ body: string | null;
61
+ link: string | null;
62
+ readAt: string | null;
63
+ createdAt: string;
64
+ }>>([]);
65
+
66
+ function iconClass(type: string) {
67
+ const map: Record<string, string> = {
68
+ info: "bi bi-info-circle text-primary",
69
+ success: "bi bi-check-circle text-success",
70
+ warning: "bi bi-exclamation-triangle text-warning",
71
+ error: "bi bi-x-circle text-danger",
72
+ };
73
+ return map[type] || "bi bi-bell text-secondary";
74
+ }
75
+
76
+ function timeAgo(dateStr: string) {
77
+ const diff = Date.now() - new Date(dateStr).getTime();
78
+ const mins = Math.floor(diff / 60000);
79
+ if (mins < 1) return "Just now";
80
+ if (mins < 60) return `${mins}m ago`;
81
+ const hours = Math.floor(mins / 60);
82
+ if (hours < 24) return `${hours}h ago`;
83
+ const days = Math.floor(hours / 24);
84
+ return `${days}d ago`;
85
+ }
86
+
87
+ async function fetchUnread() {
88
+ try {
89
+ const res = await axios.get("/api/{{module}}/unread-count");
90
+ unread.value = res.data.count;
91
+ } catch {}
92
+ }
93
+
94
+ async function fetchRecent() {
95
+ try {
96
+ const res = await axios.get("/api/{{module}}?perPage=5");
97
+ items.value = res.data.data;
98
+ unread.value = res.data.unread;
99
+ } catch {}
100
+ }
101
+
102
+ async function markAllRead() {
103
+ try {
104
+ await axios.patch("/api/{{module}}/read-all");
105
+ items.value.forEach((n) => (n.readAt = new Date().toISOString()));
106
+ unread.value = 0;
107
+ } catch {}
108
+ }
109
+
110
+ function handleClick(item: any) {
111
+ if (!item.readAt) {
112
+ axios.patch(`/api/{{module}}/${item.id}/read`).catch(() => {});
113
+ item.readAt = new Date().toISOString();
114
+ unread.value = Math.max(0, unread.value - 1);
115
+ }
116
+ }
117
+
118
+ let cleanup: (() => void) | null = null;
119
+
120
+ onMounted(async () => {
121
+ await fetchRecent();
122
+
123
+ if (user.value) {
124
+ const channel = pulse.channel(`user:${user.value.id}`);
125
+ channel.listen("notification.created", (payload: any) => {
126
+ items.value.unshift(payload);
127
+ unread.value++;
128
+ });
129
+ cleanup = () => channel.stopListening("notification.created");
130
+ }
131
+ });
132
+
133
+ onUnmounted(() => {
134
+ cleanup?.();
135
+ });
136
+ </script>
137
+
138
+ <style scoped>
139
+ .notification-badge {
140
+ font-size: 0.6rem;
141
+ padding: 0.15rem 0.35rem;
142
+ position: absolute;
143
+ top: 4px;
144
+ right: 2px;
145
+ min-width: 16px;
146
+ border-radius: 8px;
147
+ }
148
+
149
+ .notification-dropdown {
150
+ width: 360px;
151
+ max-height: 480px;
152
+ }
153
+
154
+ @media (max-width: 575.98px) {
155
+ .notification-dropdown {
156
+ position: fixed !important;
157
+ top: 56px;
158
+ left: 50% !important;
159
+ transform: translateX(-50%) !important;
160
+ width: calc(100vw - 32px);
161
+ max-width: 400px;
162
+ }
163
+ }
164
+
165
+ @media (min-width: 576px) {
166
+ .notification-dropdown {
167
+ left: auto !important;
168
+ right: 0 !important;
169
+ transform: none !important;
170
+ }
171
+ }
172
+
173
+ .notification-list {
174
+ max-height: 360px;
175
+ overflow-y: auto;
176
+ }
177
+
178
+ .notification-item {
179
+ padding: 0.75rem 1rem;
180
+ cursor: pointer;
181
+ border-bottom: 1px solid var(--app-border);
182
+ transition: background 0.15s;
183
+ }
184
+
185
+ .notification-item:hover {
186
+ background: var(--app-surface);
187
+ }
188
+
189
+ .notification-item.unread {
190
+ background: rgba(var(--bs-primary-rgb), 0.04);
191
+ }
192
+
193
+ .notification-title {
194
+ font-size: 0.85rem;
195
+ font-weight: 500;
196
+ line-height: 1.3;
197
+ }
198
+
199
+ .notification-body {
200
+ font-size: 0.8rem;
201
+ color: var(--bs-secondary-color);
202
+ margin-top: 0.15rem;
203
+ overflow: hidden;
204
+ text-overflow: ellipsis;
205
+ white-space: nowrap;
206
+ }
207
+
208
+ .notification-time {
209
+ font-size: 0.7rem;
210
+ color: var(--bs-secondary-color);
211
+ margin-top: 0.2rem;
212
+ }
213
+
214
+ .dropdown-footer {
215
+ font-size: 0.85rem;
216
+ border-top: 1px solid var(--app-border);
217
+ }
218
+ </style>
@@ -0,0 +1,85 @@
1
+ import type { Handler } from "hono";
2
+ import { and, count, desc, eq, sql } from "drizzle-orm";
3
+ import { db } from "@/framework/facade.js";
4
+ import { notifications } from "@/modules/auth/database/models/notifications.js";
5
+
6
+ export const list: Handler = async (c: any) => {
7
+ const userId = c.get("auth").id;
8
+ const page = Math.max(1, Number(c.req.query("page")) || 1);
9
+ const perPage = Math.min(50, Math.max(1, Number(c.req.query("perPage")) || 20));
10
+
11
+ const unread = await db.select({ count: count() }).from(notifications)
12
+ .where(and(eq(notifications.userId, userId), sql`${notifications.readAt} IS NULL`));
13
+
14
+ const total = await db.select({ count: count() }).from(notifications)
15
+ .where(eq(notifications.userId, userId));
16
+
17
+ const rows = await db.select().from(notifications)
18
+ .where(eq(notifications.userId, userId))
19
+ .orderBy(desc(notifications.createdAt))
20
+ .limit(perPage).offset((page - 1) * perPage);
21
+
22
+ return c.json({
23
+ data: rows.map(normalize),
24
+ total: total[0].count,
25
+ unread: unread[0].count,
26
+ page,
27
+ perPage,
28
+ });
29
+ };
30
+
31
+ export const unreadCount: Handler = async (c: any) => {
32
+ const userId = c.get("auth").id;
33
+ const rows = await db.select({ count: count() }).from(notifications)
34
+ .where(and(eq(notifications.userId, userId), sql`${notifications.readAt} IS NULL`));
35
+ return c.json({ count: rows[0].count });
36
+ };
37
+
38
+ export const markRead: Handler = async (c: any) => {
39
+ const userId = c.get("auth").id;
40
+ const id = Number(c.req.param("id"));
41
+
42
+ await db.update(notifications)
43
+ .set({ readAt: sql`now()` })
44
+ .where(and(eq(notifications.id, id), eq(notifications.userId, userId)));
45
+
46
+ return c.json({ ok: true });
47
+ };
48
+
49
+ export const markAllRead: Handler = async (c: any) => {
50
+ const userId = c.get("auth").id;
51
+
52
+ await db.update(notifications)
53
+ .set({ readAt: sql`now()` })
54
+ .where(and(eq(notifications.userId, userId), sql`${notifications.readAt} IS NULL`));
55
+
56
+ return c.json({ ok: true });
57
+ };
58
+
59
+ export const remove: Handler = async (c: any) => {
60
+ const userId = c.get("auth").id;
61
+ const id = Number(c.req.param("id"));
62
+
63
+ await db.delete(notifications)
64
+ .where(and(eq(notifications.id, id), eq(notifications.userId, userId)));
65
+
66
+ return c.json({ ok: true });
67
+ };
68
+
69
+ function normalize(row: typeof notifications.$inferSelect) {
70
+ let parsed: unknown = null;
71
+ if (row.data) {
72
+ try { parsed = JSON.parse(row.data); } catch {}
73
+ }
74
+ return {
75
+ id: row.id,
76
+ userId: row.userId,
77
+ type: row.type,
78
+ title: row.title,
79
+ body: row.body,
80
+ data: parsed,
81
+ link: row.link,
82
+ readAt: row.readAt?.toISOString() || null,
83
+ createdAt: row.createdAt.toISOString(),
84
+ };
85
+ }