create-nexwire 4.0.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.
- package/README.md +233 -0
- package/express/.dockerignore +14 -0
- package/express/.env +44 -0
- package/express/.env.example +42 -0
- package/express/.vscode/settings.json +26 -0
- package/express/LICENSE +21 -0
- package/express/README.md +211 -0
- package/express/biome.json +66 -0
- package/express/drizzle.config.ts +25 -0
- package/express/gitignore-stub +24 -0
- package/express/package.json +108 -0
- package/express/public/.gitkeep +0 -0
- package/express/src/config/app.ts +41 -0
- package/express/src/config/auth.ts +12 -0
- package/express/src/config/cache.ts +16 -0
- package/express/src/config/cookie.ts +15 -0
- package/express/src/config/cors.ts +12 -0
- package/express/src/config/database.ts +29 -0
- package/express/src/config/index.ts +83 -0
- package/express/src/config/jwt.ts +19 -0
- package/express/src/config/logging.ts +13 -0
- package/express/src/config/mail.ts +24 -0
- package/express/src/config/openapi.ts +54 -0
- package/express/src/config/queue.ts +30 -0
- package/express/src/config/rateLimit.ts +17 -0
- package/express/src/config/realtime.ts +15 -0
- package/express/src/config/redis.ts +18 -0
- package/express/src/config/security.ts +44 -0
- package/express/src/config/session.ts +17 -0
- package/express/src/config/storage.ts +22 -0
- package/express/src/config/validate.ts +40 -0
- package/express/src/database/migrations/sqlite/0000_init.sql +61 -0
- package/express/src/database/migrations/sqlite/meta/0000_snapshot.json +412 -0
- package/express/src/database/migrations/sqlite/meta/_journal.json +13 -0
- package/express/src/database/schema.ts +3 -0
- package/express/src/env.ts +76 -0
- package/express/src/framework/cache/cache.ts +81 -0
- package/express/src/framework/circuit-breaker/cb.ts +60 -0
- package/express/src/framework/database/connection.ts +196 -0
- package/express/src/framework/database/migrate-hooks.ts +87 -0
- package/express/src/framework/database/paginate.ts +227 -0
- package/express/src/framework/database/schema.ts +20 -0
- package/express/src/framework/database/seed.ts +139 -0
- package/express/src/framework/events/dispatcher.ts +49 -0
- package/express/src/framework/facade.ts +48 -0
- package/express/src/framework/http/app.ts +107 -0
- package/express/src/framework/http/cors.ts +7 -0
- package/express/src/framework/http/logger.ts +69 -0
- package/express/src/framework/http/metrics.ts +22 -0
- package/express/src/framework/http/openapi.ts +54 -0
- package/express/src/framework/http/ratelimiter.ts +16 -0
- package/express/src/framework/http/router.ts +178 -0
- package/express/src/framework/http/security.ts +23 -0
- package/express/src/framework/http/static.ts +23 -0
- package/express/src/framework/http/validation.ts +18 -0
- package/express/src/framework/kernel.ts +52 -0
- package/express/src/framework/maker-cli/db/core.mjs +288 -0
- package/express/src/framework/maker-cli/db/index.mjs +204 -0
- package/express/src/framework/maker-cli/deploy/core.mjs +1047 -0
- package/express/src/framework/maker-cli/deploy/index.mjs +91 -0
- package/express/src/framework/maker-cli/index.mjs +53 -0
- package/express/src/framework/maker-cli/middleware/core.mjs +47 -0
- package/express/src/framework/maker-cli/middleware/index.mjs +17 -0
- package/express/src/framework/maker-cli/module/core.mjs +684 -0
- package/express/src/framework/maker-cli/module/index.mjs +140 -0
- package/express/src/framework/maker-cli/runtime/build-ui.mjs +16 -0
- package/express/src/framework/maker-cli/runtime/core.mjs +543 -0
- package/express/src/framework/maker-cli/runtime/index.mjs +104 -0
- package/express/src/framework/maker-cli/runtime/redis-commander-patch.cjs +20 -0
- package/express/src/framework/maker-cli/stubs/controller/openapi.ts.stub +47 -0
- package/express/src/framework/maker-cli/stubs/controller/openapi.with-model.ts.stub +48 -0
- package/express/src/framework/maker-cli/stubs/controller/plain.ts.stub +54 -0
- package/express/src/framework/maker-cli/stubs/controller/schema.plain.ts.stub +14 -0
- package/express/src/framework/maker-cli/stubs/controller/schema.ts.stub +33 -0
- package/express/src/framework/maker-cli/stubs/deploy/Dockerfile.bun.stub +52 -0
- package/express/src/framework/maker-cli/stubs/deploy/Dockerfile.pnpm.stub +55 -0
- package/express/src/framework/maker-cli/stubs/deploy/Dockerfile.stub +51 -0
- package/express/src/framework/maker-cli/stubs/deploy/Dockerfile.yarn.stub +55 -0
- package/express/src/framework/maker-cli/stubs/deploy/README.stub +59 -0
- package/express/src/framework/maker-cli/stubs/deploy/compose/mysql.server.stub +45 -0
- package/express/src/framework/maker-cli/stubs/deploy/compose/postgres.server.stub +45 -0
- package/express/src/framework/maker-cli/stubs/deploy/compose/sqlite.stub +45 -0
- package/express/src/framework/maker-cli/stubs/deploy/env/mysql.server.stub +68 -0
- package/express/src/framework/maker-cli/stubs/deploy/env/postgres.server.stub +68 -0
- package/express/src/framework/maker-cli/stubs/deploy/env/sqlite.stub +67 -0
- package/express/src/framework/maker-cli/stubs/deploy/scripts/auto-migrate.sh.stub +41 -0
- package/express/src/framework/maker-cli/stubs/deploy/server/README.stub +78 -0
- package/express/src/framework/maker-cli/stubs/deploy/server/compose/noredis.stub +120 -0
- package/express/src/framework/maker-cli/stubs/deploy/server/compose/redis.dev.stub +133 -0
- package/express/src/framework/maker-cli/stubs/deploy/server/compose/redis.stub +131 -0
- package/express/src/framework/maker-cli/stubs/deploy/server/env/local.example.stub +11 -0
- package/express/src/framework/maker-cli/stubs/deploy/server/env/noredis.stub +25 -0
- package/express/src/framework/maker-cli/stubs/deploy/server/env/redis.stub +25 -0
- package/express/src/framework/maker-cli/stubs/deploy/server/nginx-vhost/README.stub +16 -0
- package/express/src/framework/maker-cli/stubs/deploy/server/nginx-vhost/app.example.com.stub +13 -0
- package/express/src/framework/maker-cli/stubs/deploy/server/pgadmin/servers.stub +14 -0
- package/express/src/framework/maker-cli/stubs/deploy/server/redis/redis.conf.stub +7 -0
- package/express/src/framework/maker-cli/stubs/deploy/supervisor/noredis.stub +54 -0
- package/express/src/framework/maker-cli/stubs/deploy/supervisor/redis.stub +70 -0
- package/express/src/framework/maker-cli/stubs/deploy/workflow/local.json.stub +25 -0
- package/express/src/framework/maker-cli/stubs/deploy/workflow/remote.json.stub +24 -0
- package/express/src/framework/maker-cli/stubs/example/console.ts.stub +34 -0
- package/express/src/framework/maker-cli/stubs/example/controller.ts.stub +418 -0
- package/express/src/framework/maker-cli/stubs/example/job.ts.stub +75 -0
- package/express/src/framework/maker-cli/stubs/example/route.api.ts.stub +207 -0
- package/express/src/framework/maker-cli/stubs/example/route.plain.ts.stub +18 -0
- package/express/src/framework/maker-cli/stubs/example/schema.plain.ts.stub +42 -0
- package/express/src/framework/maker-cli/stubs/example/schema.ts.stub +42 -0
- package/express/src/framework/maker-cli/stubs/job/name.ts.stub +25 -0
- package/express/src/framework/maker-cli/stubs/middleware/name.ts.stub +14 -0
- package/express/src/framework/maker-cli/stubs/model/name.mysql.ts.stub +9 -0
- package/express/src/framework/maker-cli/stubs/model/name.postgresql.ts.stub +9 -0
- package/express/src/framework/maker-cli/stubs/model/name.sqlite.ts.stub +9 -0
- package/express/src/framework/maker-cli/stubs/notification/controller.ts.stub +77 -0
- package/express/src/framework/maker-cli/stubs/notification/job.ts.stub +13 -0
- package/express/src/framework/maker-cli/stubs/notification/route.api.ts.stub +50 -0
- package/express/src/framework/maker-cli/stubs/notification/route.plain.ts.stub +12 -0
- package/express/src/framework/maker-cli/stubs/notification/schema.plain.ts.stub +26 -0
- package/express/src/framework/maker-cli/stubs/notification/schema.ts.stub +26 -0
- package/express/src/framework/maker-cli/stubs/route/api.ts.stub +80 -0
- package/express/src/framework/maker-cli/stubs/route/plain.ts.stub +11 -0
- package/express/src/framework/maker-cli/stubs/schedule/name.ts.stub +36 -0
- package/express/src/framework/maker-cli/stubs/seeder/name.ts.stub +20 -0
- package/express/src/framework/maker-cli/stubs/test/unit.ts.stub +22 -0
- package/express/src/framework/maker-cli/utils/env-config.mjs +44 -0
- package/express/src/framework/maker-cli/utils/env-db.mjs +61 -0
- package/express/src/framework/maker-cli/utils/file-ops.mjs +30 -0
- package/express/src/framework/maker-cli/utils/flags.mjs +14 -0
- package/express/src/framework/maker-cli/utils/help.mjs +50 -0
- package/express/src/framework/maker-cli/utils/naming.mjs +13 -0
- package/express/src/framework/maker-cli/utils/process.mjs +52 -0
- package/express/src/framework/modules/discover.ts +54 -0
- package/express/src/framework/modules/routes.ts +21 -0
- package/express/src/framework/notification/index.ts +116 -0
- package/express/src/framework/queue/clear.ts +22 -0
- package/express/src/framework/queue/queue.ts +342 -0
- package/express/src/framework/queue/ui.ts +187 -0
- package/express/src/framework/queue/worker.ts +61 -0
- package/express/src/framework/realtime/broadcast.ts +46 -0
- package/express/src/framework/realtime/index.ts +2 -0
- package/express/src/framework/realtime/socket-cookie.ts +71 -0
- package/express/src/framework/realtime/socket.ts +119 -0
- package/express/src/framework/realtime/types.ts +6 -0
- package/express/src/framework/realtime/ui.ts +16 -0
- package/express/src/framework/redis/client.ts +151 -0
- package/express/src/framework/runtime/runtime.ts +23 -0
- package/express/src/framework/runtime/server-adapter.ts +34 -0
- package/express/src/framework/scheduler/lock.ts +116 -0
- package/express/src/framework/scheduler/run.ts +48 -0
- package/express/src/framework/scheduler/scheduler.ts +155 -0
- package/express/src/framework/server.ts +177 -0
- package/express/src/framework/session/session.ts +98 -0
- package/express/src/framework/storage/storage.ts +785 -0
- package/express/src/framework/support/cookie.ts +62 -0
- package/express/src/framework/support/jwt.ts +33 -0
- package/express/src/framework/support/lifecycle.ts +35 -0
- package/express/src/framework/support/logger.ts +148 -0
- package/express/src/framework/support/mail.ts +48 -0
- package/express/src/framework/support/password.ts +23 -0
- package/express/src/framework/support/upload.ts +160 -0
- package/express/src/framework/support/url.ts +41 -0
- package/express/src/middlewares/auth-middleware.ts +98 -0
- package/express/src/middlewares/role-middleware.ts +25 -0
- package/express/src/modules/auth/controllers/auth.controller.ts +358 -0
- package/express/src/modules/auth/controllers/auth.helpers.ts +104 -0
- package/express/src/modules/auth/controllers/auth.schema.ts +102 -0
- package/express/src/modules/auth/controllers/role.controller.ts +15 -0
- package/express/src/modules/auth/database/models/notifications.ts +24 -0
- package/express/src/modules/auth/database/models/role.ts +14 -0
- package/express/src/modules/auth/database/models/user.ts +46 -0
- package/express/src/modules/auth/database/seeders/role.ts +18 -0
- package/express/src/modules/auth/database/seeders/user.ts +35 -0
- package/express/src/modules/auth/jobs/forgetpass.ts +20 -0
- package/express/src/modules/auth/jobs/registeruser.ts +23 -0
- package/express/src/modules/auth/jobs/verifyemail.ts +18 -0
- package/express/src/modules/auth/routes/api.ts +150 -0
- package/express/src/modules/auth/routes/role.ts +33 -0
- package/express/src/resources/index.html +17 -0
- package/express/src/resources/src/App.vue +5 -0
- package/express/src/resources/src/assets/css/styles.css +14761 -0
- package/express/src/resources/src/assets/css/styles.css.map +1 -0
- package/express/src/resources/src/assets/fonts/public-sans/public-sans-latin-ext.woff2 +0 -0
- package/express/src/resources/src/assets/fonts/public-sans/public-sans-latin.woff2 +0 -0
- package/express/src/resources/src/assets/images/favicon/favicon.ico +0 -0
- package/express/src/resources/src/assets/images/logo.png +0 -0
- package/express/src/resources/src/assets/scss/custom.css +217 -0
- package/express/src/resources/src/assets/scss/custom.css.map +1 -0
- package/express/src/resources/src/assets/scss/custom.scss +1346 -0
- package/express/src/resources/src/components/Button.vue +32 -0
- package/express/src/resources/src/components/Checkbox.vue +29 -0
- package/express/src/resources/src/components/Datepicker.vue +106 -0
- package/express/src/resources/src/components/FeatureButton.vue +53 -0
- package/express/src/resources/src/components/FloatButton.vue +33 -0
- package/express/src/resources/src/components/Href.vue +32 -0
- package/express/src/resources/src/components/Input.vue +223 -0
- package/express/src/resources/src/components/InputGroup.vue +145 -0
- package/express/src/resources/src/components/InputPasswordToggle.vue +213 -0
- package/express/src/resources/src/components/Modal.vue +55 -0
- package/express/src/resources/src/components/Pagebar.vue +26 -0
- package/express/src/resources/src/components/Select.vue +384 -0
- package/express/src/resources/src/components/Spinner.vue +42 -0
- package/express/src/resources/src/components/Switch.vue +65 -0
- package/express/src/resources/src/components/TextArea.vue +117 -0
- package/express/src/resources/src/components/Toast.vue +56 -0
- package/express/src/resources/src/components/datatable/DataTableSkeleton.vue +98 -0
- package/express/src/resources/src/components/datatable/Pagination.vue +147 -0
- package/express/src/resources/src/components/datatable/SelectOpption.vue +64 -0
- package/express/src/resources/src/components/datatable/index.vue +199 -0
- package/express/src/resources/src/composables/useAuth.ts +52 -0
- package/express/src/resources/src/helpers/nformatter.ts +10 -0
- package/express/src/resources/src/helpers/utils.ts +75 -0
- package/express/src/resources/src/layouts/AuthLayout.vue +20 -0
- package/express/src/resources/src/layouts/Layout/Footer.vue +23 -0
- package/express/src/resources/src/layouts/Layout/Header.vue +105 -0
- package/express/src/resources/src/layouts/Layout/Sidebar.vue +137 -0
- package/express/src/resources/src/layouts/Layout/index.vue +87 -0
- package/express/src/resources/src/main.ts +26 -0
- package/express/src/resources/src/pages/auth/forgetPassword.vue +82 -0
- package/express/src/resources/src/pages/auth/login.vue +99 -0
- package/express/src/resources/src/pages/auth/register.vue +133 -0
- package/express/src/resources/src/pages/auth/resetPassword.vue +118 -0
- package/express/src/resources/src/pages/auth/verifyEmail.vue +68 -0
- package/express/src/resources/src/pages/dashboard/index.vue +66 -0
- package/express/src/resources/src/plugins/axios.ts +31 -0
- package/express/src/resources/src/plugins/browserDetect.ts +55 -0
- package/express/src/resources/src/plugins/dialog.ts +216 -0
- package/express/src/resources/src/plugins/gum.ts +367 -0
- package/express/src/resources/src/plugins/pulse.ts +147 -0
- package/express/src/resources/src/plugins/routeProgress.ts +87 -0
- package/express/src/resources/src/router/index.ts +85 -0
- package/express/src/resources/src/stores/admin-ui.ts +148 -0
- package/express/src/resources/src/stores/auth.ts +164 -0
- package/express/src/resources/tsconfig.json +19 -0
- package/express/src/resources/vite.config.ts +46 -0
- package/express/src/storage/app/private/.gitkeep +0 -0
- package/express/src/storage/app/public/.gitkeep +0 -0
- package/express/src/storage/app/tmp/generated/.gitkeep +0 -0
- package/express/src/storage/database/nexwire.sqlite +0 -0
- package/express/src/storage/logs/.gitkeep +0 -0
- package/express/src/storage/tmp/.gitkeep +0 -0
- package/express/src/storage/trash/modules/.gitkeep +0 -0
- package/express/src/types/global.d.ts +26 -0
- package/express/tsconfig.json +19 -0
- package/express/vitest.config.ts +23 -0
- package/hono/.dockerignore +14 -0
- package/hono/.env +44 -0
- package/hono/.env.example +42 -0
- package/hono/.vscode/settings.json +26 -0
- package/hono/LICENSE +21 -0
- package/hono/README.md +211 -0
- package/hono/biome.json +76 -0
- package/hono/drizzle.config.ts +25 -0
- package/hono/gitignore-stub +24 -0
- package/hono/package.json +99 -0
- package/hono/public/.gitkeep +0 -0
- package/hono/src/config/app.ts +41 -0
- package/hono/src/config/auth.ts +12 -0
- package/hono/src/config/cache.ts +16 -0
- package/hono/src/config/cookie.ts +15 -0
- package/hono/src/config/cors.ts +12 -0
- package/hono/src/config/database.ts +29 -0
- package/hono/src/config/index.ts +83 -0
- package/hono/src/config/jwt.ts +19 -0
- package/hono/src/config/logging.ts +13 -0
- package/hono/src/config/mail.ts +24 -0
- package/hono/src/config/openapi.ts +54 -0
- package/hono/src/config/queue.ts +30 -0
- package/hono/src/config/rateLimit.ts +17 -0
- package/hono/src/config/realtime.ts +15 -0
- package/hono/src/config/redis.ts +18 -0
- package/hono/src/config/security.ts +44 -0
- package/hono/src/config/session.ts +17 -0
- package/hono/src/config/storage.ts +22 -0
- package/hono/src/config/validate.ts +40 -0
- package/hono/src/database/migrations/sqlite/0000_init.sql +61 -0
- package/hono/src/database/migrations/sqlite/meta/0000_snapshot.json +412 -0
- package/hono/src/database/migrations/sqlite/meta/_journal.json +13 -0
- package/hono/src/database/schema.ts +3 -0
- package/hono/src/env.ts +76 -0
- package/hono/src/framework/cache/cache.ts +81 -0
- package/hono/src/framework/circuit-breaker/cb.ts +60 -0
- package/hono/src/framework/database/connection.ts +196 -0
- package/hono/src/framework/database/migrate-hooks.ts +87 -0
- package/hono/src/framework/database/paginate.ts +253 -0
- package/hono/src/framework/database/schema.ts +20 -0
- package/hono/src/framework/database/seed.ts +139 -0
- package/hono/src/framework/events/dispatcher.ts +49 -0
- package/hono/src/framework/facade.ts +29 -0
- package/hono/src/framework/http/app.ts +109 -0
- package/hono/src/framework/http/cors.ts +19 -0
- package/hono/src/framework/http/logger.ts +81 -0
- package/hono/src/framework/http/metrics.ts +22 -0
- package/hono/src/framework/http/openapi.ts +42 -0
- package/hono/src/framework/http/ratelimiter.ts +172 -0
- package/hono/src/framework/http/router.ts +76 -0
- package/hono/src/framework/http/security.ts +23 -0
- package/hono/src/framework/http/static.ts +70 -0
- package/hono/src/framework/http/validation.ts +21 -0
- package/hono/src/framework/kernel.ts +48 -0
- package/hono/src/framework/maker-cli/db/core.mjs +288 -0
- package/hono/src/framework/maker-cli/db/index.mjs +204 -0
- package/hono/src/framework/maker-cli/deploy/core.mjs +1038 -0
- package/hono/src/framework/maker-cli/deploy/index.mjs +91 -0
- package/hono/src/framework/maker-cli/index.mjs +53 -0
- package/hono/src/framework/maker-cli/middleware/core.mjs +47 -0
- package/hono/src/framework/maker-cli/middleware/index.mjs +12 -0
- package/hono/src/framework/maker-cli/module/core.mjs +684 -0
- package/hono/src/framework/maker-cli/module/index.mjs +140 -0
- package/hono/src/framework/maker-cli/runtime/build-ui.mjs +17 -0
- package/hono/src/framework/maker-cli/runtime/core.mjs +543 -0
- package/hono/src/framework/maker-cli/runtime/index.mjs +104 -0
- package/hono/src/framework/maker-cli/runtime/redis-commander-patch.cjs +20 -0
- package/hono/src/framework/maker-cli/stubs/controller/openapi.ts.stub +57 -0
- package/hono/src/framework/maker-cli/stubs/controller/openapi.with-model.ts.stub +58 -0
- package/hono/src/framework/maker-cli/stubs/controller/plain.ts.stub +59 -0
- package/hono/src/framework/maker-cli/stubs/controller/schema.plain.ts.stub +14 -0
- package/hono/src/framework/maker-cli/stubs/controller/schema.ts.stub +33 -0
- package/hono/src/framework/maker-cli/stubs/deploy/Dockerfile.bun.stub +52 -0
- package/hono/src/framework/maker-cli/stubs/deploy/Dockerfile.pnpm.stub +55 -0
- package/hono/src/framework/maker-cli/stubs/deploy/Dockerfile.stub +51 -0
- package/hono/src/framework/maker-cli/stubs/deploy/Dockerfile.yarn.stub +55 -0
- package/hono/src/framework/maker-cli/stubs/deploy/README.stub +59 -0
- package/hono/src/framework/maker-cli/stubs/deploy/compose/mysql.server.stub +45 -0
- package/hono/src/framework/maker-cli/stubs/deploy/compose/postgres.server.stub +45 -0
- package/hono/src/framework/maker-cli/stubs/deploy/compose/sqlite.stub +45 -0
- package/hono/src/framework/maker-cli/stubs/deploy/env/mysql.server.stub +68 -0
- package/hono/src/framework/maker-cli/stubs/deploy/env/postgres.server.stub +68 -0
- package/hono/src/framework/maker-cli/stubs/deploy/env/sqlite.stub +67 -0
- package/hono/src/framework/maker-cli/stubs/deploy/scripts/auto-migrate.sh.stub +41 -0
- package/hono/src/framework/maker-cli/stubs/deploy/server/README.stub +78 -0
- package/hono/src/framework/maker-cli/stubs/deploy/server/compose/noredis.stub +120 -0
- package/hono/src/framework/maker-cli/stubs/deploy/server/compose/redis.dev.stub +133 -0
- package/hono/src/framework/maker-cli/stubs/deploy/server/compose/redis.stub +131 -0
- package/hono/src/framework/maker-cli/stubs/deploy/server/env/local.example.stub +11 -0
- package/hono/src/framework/maker-cli/stubs/deploy/server/env/noredis.stub +25 -0
- package/hono/src/framework/maker-cli/stubs/deploy/server/env/redis.stub +25 -0
- package/hono/src/framework/maker-cli/stubs/deploy/server/nginx-vhost/README.stub +16 -0
- package/hono/src/framework/maker-cli/stubs/deploy/server/nginx-vhost/app.example.com.stub +13 -0
- package/hono/src/framework/maker-cli/stubs/deploy/server/pgadmin/servers.stub +14 -0
- package/hono/src/framework/maker-cli/stubs/deploy/server/redis/redis.conf.stub +7 -0
- package/hono/src/framework/maker-cli/stubs/deploy/supervisor/noredis.stub +54 -0
- package/hono/src/framework/maker-cli/stubs/deploy/supervisor/redis.stub +70 -0
- package/hono/src/framework/maker-cli/stubs/deploy/workflow/local.json.stub +25 -0
- package/hono/src/framework/maker-cli/stubs/deploy/workflow/remote.json.stub +24 -0
- package/hono/src/framework/maker-cli/stubs/example/console.ts.stub +34 -0
- package/hono/src/framework/maker-cli/stubs/example/controller.ts.stub +505 -0
- package/hono/src/framework/maker-cli/stubs/example/job.ts.stub +75 -0
- package/hono/src/framework/maker-cli/stubs/example/route.api.ts.stub +207 -0
- package/hono/src/framework/maker-cli/stubs/example/route.plain.ts.stub +18 -0
- package/hono/src/framework/maker-cli/stubs/example/schema.plain.ts.stub +42 -0
- package/hono/src/framework/maker-cli/stubs/example/schema.ts.stub +42 -0
- package/hono/src/framework/maker-cli/stubs/job/name.ts.stub +25 -0
- package/hono/src/framework/maker-cli/stubs/middleware/name.ts.stub +14 -0
- package/hono/src/framework/maker-cli/stubs/model/name.mysql.ts.stub +9 -0
- package/hono/src/framework/maker-cli/stubs/model/name.postgresql.ts.stub +9 -0
- package/hono/src/framework/maker-cli/stubs/model/name.sqlite.ts.stub +9 -0
- package/hono/src/framework/maker-cli/stubs/notification/controller.ts.stub +86 -0
- package/hono/src/framework/maker-cli/stubs/notification/job.ts.stub +13 -0
- package/hono/src/framework/maker-cli/stubs/notification/route.api.ts.stub +50 -0
- package/hono/src/framework/maker-cli/stubs/notification/route.plain.ts.stub +12 -0
- package/hono/src/framework/maker-cli/stubs/notification/schema.plain.ts.stub +26 -0
- package/hono/src/framework/maker-cli/stubs/notification/schema.ts.stub +26 -0
- package/hono/src/framework/maker-cli/stubs/route/api.ts.stub +80 -0
- package/hono/src/framework/maker-cli/stubs/route/plain.ts.stub +11 -0
- package/hono/src/framework/maker-cli/stubs/schedule/name.ts.stub +36 -0
- package/hono/src/framework/maker-cli/stubs/seeder/name.ts.stub +20 -0
- package/hono/src/framework/maker-cli/stubs/test/unit.ts.stub +22 -0
- package/hono/src/framework/maker-cli/utils/env-config.mjs +44 -0
- package/hono/src/framework/maker-cli/utils/env-db.mjs +61 -0
- package/hono/src/framework/maker-cli/utils/file-ops.mjs +30 -0
- package/hono/src/framework/maker-cli/utils/flags.mjs +14 -0
- package/hono/src/framework/maker-cli/utils/help.mjs +50 -0
- package/hono/src/framework/maker-cli/utils/naming.mjs +13 -0
- package/hono/src/framework/maker-cli/utils/process.mjs +52 -0
- package/hono/src/framework/modules/discover.ts +54 -0
- package/hono/src/framework/modules/routes.ts +24 -0
- package/hono/src/framework/notification/index.ts +116 -0
- package/hono/src/framework/queue/clear.ts +22 -0
- package/hono/src/framework/queue/queue.ts +342 -0
- package/hono/src/framework/queue/ui.ts +214 -0
- package/hono/src/framework/queue/worker.ts +61 -0
- package/hono/src/framework/realtime/broadcast.ts +46 -0
- package/hono/src/framework/realtime/index.ts +2 -0
- package/hono/src/framework/realtime/socket-cookie.ts +68 -0
- package/hono/src/framework/realtime/socket.ts +196 -0
- package/hono/src/framework/realtime/types.ts +6 -0
- package/hono/src/framework/realtime/ui.ts +16 -0
- package/hono/src/framework/redis/client.ts +151 -0
- package/hono/src/framework/runtime/runtime.ts +23 -0
- package/hono/src/framework/runtime/server-adapter.ts +94 -0
- package/hono/src/framework/scheduler/lock.ts +116 -0
- package/hono/src/framework/scheduler/run.ts +48 -0
- package/hono/src/framework/scheduler/scheduler.ts +155 -0
- package/hono/src/framework/server.ts +183 -0
- package/hono/src/framework/session/session.ts +116 -0
- package/hono/src/framework/storage/storage.ts +785 -0
- package/hono/src/framework/support/cookie.ts +99 -0
- package/hono/src/framework/support/jwt.ts +45 -0
- package/hono/src/framework/support/lifecycle.ts +35 -0
- package/hono/src/framework/support/logger.ts +148 -0
- package/hono/src/framework/support/mail.ts +48 -0
- package/hono/src/framework/support/password.ts +23 -0
- package/hono/src/framework/support/url.ts +41 -0
- package/hono/src/middlewares/auth-middleware.ts +98 -0
- package/hono/src/middlewares/role-middleware.ts +25 -0
- package/hono/src/modules/auth/controllers/auth.controller.ts +413 -0
- package/hono/src/modules/auth/controllers/auth.helpers.ts +128 -0
- package/hono/src/modules/auth/controllers/auth.schema.ts +102 -0
- package/hono/src/modules/auth/controllers/role.controller.ts +25 -0
- package/hono/src/modules/auth/database/models/notifications.ts +24 -0
- package/hono/src/modules/auth/database/models/role.ts +14 -0
- package/hono/src/modules/auth/database/models/user.ts +46 -0
- package/hono/src/modules/auth/database/seeders/role.ts +18 -0
- package/hono/src/modules/auth/database/seeders/user.ts +35 -0
- package/hono/src/modules/auth/jobs/forgetpass.ts +20 -0
- package/hono/src/modules/auth/jobs/registeruser.ts +23 -0
- package/hono/src/modules/auth/jobs/verifyemail.ts +18 -0
- package/hono/src/modules/auth/routes/api.ts +150 -0
- package/hono/src/modules/auth/routes/role.ts +33 -0
- package/hono/src/resources/index.html +17 -0
- package/hono/src/resources/src/App.vue +5 -0
- package/hono/src/resources/src/assets/css/styles.css +14913 -0
- package/hono/src/resources/src/assets/css/styles.css.map +1 -0
- package/hono/src/resources/src/assets/fonts/public-sans/public-sans-latin-ext.woff2 +0 -0
- package/hono/src/resources/src/assets/fonts/public-sans/public-sans-latin.woff2 +0 -0
- package/hono/src/resources/src/assets/images/favicon/favicon.ico +0 -0
- package/hono/src/resources/src/assets/images/logo.png +0 -0
- package/hono/src/resources/src/assets/scss/custom.css +217 -0
- package/hono/src/resources/src/assets/scss/custom.css.map +1 -0
- package/hono/src/resources/src/assets/scss/custom.scss +1346 -0
- package/hono/src/resources/src/components/Button.vue +32 -0
- package/hono/src/resources/src/components/Checkbox.vue +29 -0
- package/hono/src/resources/src/components/Datepicker.vue +106 -0
- package/hono/src/resources/src/components/FeatureButton.vue +53 -0
- package/hono/src/resources/src/components/FloatButton.vue +33 -0
- package/hono/src/resources/src/components/Href.vue +32 -0
- package/hono/src/resources/src/components/Input.vue +234 -0
- package/hono/src/resources/src/components/InputGroup.vue +149 -0
- package/hono/src/resources/src/components/InputPasswordToggle.vue +222 -0
- package/hono/src/resources/src/components/Modal.vue +55 -0
- package/hono/src/resources/src/components/Pagebar.vue +26 -0
- package/hono/src/resources/src/components/Select.vue +415 -0
- package/hono/src/resources/src/components/Spinner.vue +42 -0
- package/hono/src/resources/src/components/Switch.vue +65 -0
- package/hono/src/resources/src/components/TextArea.vue +121 -0
- package/hono/src/resources/src/components/Toast.vue +56 -0
- package/hono/src/resources/src/components/datatable/DataTableSkeleton.vue +98 -0
- package/hono/src/resources/src/components/datatable/Pagination.vue +147 -0
- package/hono/src/resources/src/components/datatable/SelectOpption.vue +64 -0
- package/hono/src/resources/src/components/datatable/index.vue +199 -0
- package/hono/src/resources/src/composables/useAuth.ts +52 -0
- package/hono/src/resources/src/helpers/nformatter.ts +10 -0
- package/hono/src/resources/src/helpers/utils.ts +75 -0
- package/hono/src/resources/src/layouts/AuthLayout.vue +20 -0
- package/hono/src/resources/src/layouts/Layout/Footer.vue +23 -0
- package/hono/src/resources/src/layouts/Layout/Header.vue +105 -0
- package/hono/src/resources/src/layouts/Layout/Sidebar.vue +137 -0
- package/hono/src/resources/src/layouts/Layout/index.vue +87 -0
- package/hono/src/resources/src/main.ts +26 -0
- package/hono/src/resources/src/pages/auth/forgetPassword.vue +82 -0
- package/hono/src/resources/src/pages/auth/login.vue +99 -0
- package/hono/src/resources/src/pages/auth/register.vue +133 -0
- package/hono/src/resources/src/pages/auth/resetPassword.vue +118 -0
- package/hono/src/resources/src/pages/auth/verifyEmail.vue +68 -0
- package/hono/src/resources/src/pages/dashboard/index.vue +66 -0
- package/hono/src/resources/src/plugins/axios.ts +31 -0
- package/hono/src/resources/src/plugins/browserDetect.ts +55 -0
- package/hono/src/resources/src/plugins/dialog.ts +216 -0
- package/hono/src/resources/src/plugins/gum.ts +367 -0
- package/hono/src/resources/src/plugins/pulse.ts +147 -0
- package/hono/src/resources/src/plugins/routeProgress.ts +87 -0
- package/hono/src/resources/src/router/index.ts +85 -0
- package/hono/src/resources/src/stores/admin-ui.ts +148 -0
- package/hono/src/resources/src/stores/auth.ts +164 -0
- package/hono/src/resources/tsconfig.json +19 -0
- package/hono/src/resources/vite.config.ts +46 -0
- package/hono/src/storage/app/private/.gitkeep +0 -0
- package/hono/src/storage/app/public/.gitkeep +0 -0
- package/hono/src/storage/app/tmp/generated/.gitkeep +0 -0
- package/hono/src/storage/database/nexwire.sqlite +0 -0
- package/hono/src/storage/logs/.gitkeep +0 -0
- package/hono/src/storage/tmp/.gitkeep +0 -0
- package/hono/src/storage/trash/modules/.gitkeep +0 -0
- package/hono/src/types/global.d.ts +26 -0
- package/hono/tsconfig.json +20 -0
- package/hono/vitest.config.ts +23 -0
- package/package.json +238 -0
- package/src/index.js +204 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { group } from "@/framework/facade.js";
|
|
2
|
+
import { downloadGenerated, downloadGeneratedExcel, downloadGeneratedPdf, fire, fireBroadcast, fireQueued, fireQueuedBroadcast, generateDownload, generateExcelDownload, generatePdfDownload, importExcel, queueCommand, upload } from "@/modules/{{module}}/controllers/{{module}}.controller.js";
|
|
3
|
+
|
|
4
|
+
export default group()
|
|
5
|
+
.post("/event", fire)
|
|
6
|
+
.post("/queue/command", queueCommand)
|
|
7
|
+
.post("/event/queued", fireQueued)
|
|
8
|
+
.post("/event/queued-broadcast", fireQueuedBroadcast)
|
|
9
|
+
.post("/event/broadcast", fireBroadcast)
|
|
10
|
+
.post("/upload", upload)
|
|
11
|
+
.post("/import/excel", importExcel)
|
|
12
|
+
.post("/download/generate", generateDownload)
|
|
13
|
+
.get("/download/:token", downloadGenerated)
|
|
14
|
+
.post("/download/excel/generate", generateExcelDownload)
|
|
15
|
+
.get("/download/excel/:token", downloadGeneratedExcel)
|
|
16
|
+
.post("/download/pdf/generate", generatePdfDownload)
|
|
17
|
+
.get("/download/pdf/:requestId", downloadGeneratedPdf);
|
|
18
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "@/framework/facade.js";
|
|
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
|
+
});
|
|
42
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
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
|
+
});
|
|
42
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DateTime } from "luxon";
|
|
2
|
+
import { dispatchEvent, shouldQueue } 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
|
+
});
|
|
25
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NextFunction, Request, Response } from "express";
|
|
2
|
+
import { db } from "@/framework/facade.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Why: Runs before route handlers to enforce cross-cutting rules for {{name}}.
|
|
6
|
+
* When: Attach to a route group or a specific route.
|
|
7
|
+
* Where: Add it to a group: group({{camel}}Middleware), or per route:
|
|
8
|
+
* .api(route, [{{camel}}Middleware], handler)
|
|
9
|
+
* How: res.locals.auth is populated when authMiddleware ran first; db gives
|
|
10
|
+
* typed access to your module models. Call next() to continue.
|
|
11
|
+
*/
|
|
12
|
+
export function {{camel}}Middleware(req: Request, res: Response, next: NextFunction) {
|
|
13
|
+
return next();
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
});
|
|
9
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
});
|
|
9
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
});
|
|
9
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { and, count, desc, eq, sql } from "drizzle-orm";
|
|
2
|
+
import type { Request, Response } from "express";
|
|
3
|
+
import { db } from "@/framework/facade.js";
|
|
4
|
+
import { notifications } from "@/modules/auth/database/models/notifications.js";
|
|
5
|
+
|
|
6
|
+
type AuthRequest = Request & { auth: { id: number } };
|
|
7
|
+
|
|
8
|
+
export const list = async (req: AuthRequest, res: Response) => {
|
|
9
|
+
const userId = req.auth.id;
|
|
10
|
+
const page = Math.max(1, Number(req.query.page) || 1);
|
|
11
|
+
const perPage = Math.min(50, Math.max(1, Number(req.query.perPage) || 20));
|
|
12
|
+
|
|
13
|
+
const unread = await db.select({ count: count() }).from(notifications)
|
|
14
|
+
.where(and(eq(notifications.userId, userId), sql`${notifications.readAt} IS NULL`));
|
|
15
|
+
const total = await db.select({ count: count() }).from(notifications)
|
|
16
|
+
.where(eq(notifications.userId, userId));
|
|
17
|
+
const rows = await db.select().from(notifications)
|
|
18
|
+
.where(eq(notifications.userId, userId))
|
|
19
|
+
.orderBy(desc(notifications.createdAt))
|
|
20
|
+
.limit(perPage)
|
|
21
|
+
.offset((page - 1) * perPage);
|
|
22
|
+
|
|
23
|
+
res.json({
|
|
24
|
+
data: rows.map(normalize),
|
|
25
|
+
total: total[0].count,
|
|
26
|
+
unread: unread[0].count,
|
|
27
|
+
page,
|
|
28
|
+
perPage
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const unreadCount = async (req: AuthRequest, res: Response) => {
|
|
33
|
+
const userId = req.auth.id;
|
|
34
|
+
const rows = await db.select({ count: count() }).from(notifications)
|
|
35
|
+
.where(and(eq(notifications.userId, userId), sql`${notifications.readAt} IS NULL`));
|
|
36
|
+
res.json({ count: rows[0].count });
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const markRead = async (req: AuthRequest, res: Response) => {
|
|
40
|
+
const id = Number(req.params.id);
|
|
41
|
+
await db.update(notifications)
|
|
42
|
+
.set({ readAt: sql`now()` })
|
|
43
|
+
.where(and(eq(notifications.id, id), eq(notifications.userId, req.auth.id)));
|
|
44
|
+
res.json({ ok: true });
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const markAllRead = async (req: AuthRequest, res: Response) => {
|
|
48
|
+
await db.update(notifications)
|
|
49
|
+
.set({ readAt: sql`now()` })
|
|
50
|
+
.where(and(eq(notifications.userId, req.auth.id), sql`${notifications.readAt} IS NULL`));
|
|
51
|
+
res.json({ ok: true });
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const remove = async (req: AuthRequest, res: Response) => {
|
|
55
|
+
const id = Number(req.params.id);
|
|
56
|
+
await db.delete(notifications)
|
|
57
|
+
.where(and(eq(notifications.id, id), eq(notifications.userId, req.auth.id)));
|
|
58
|
+
res.json({ ok: true });
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
function normalize(row: typeof notifications.$inferSelect) {
|
|
62
|
+
let parsed: unknown = null;
|
|
63
|
+
if (row.data) {
|
|
64
|
+
try { parsed = JSON.parse(row.data); } catch {}
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
id: row.id,
|
|
68
|
+
userId: row.userId,
|
|
69
|
+
type: row.type,
|
|
70
|
+
title: row.title,
|
|
71
|
+
body: row.body,
|
|
72
|
+
data: parsed,
|
|
73
|
+
link: row.link,
|
|
74
|
+
readAt: row.readAt?.toISOString() || null,
|
|
75
|
+
createdAt: row.createdAt.toISOString(),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { shouldQueue } from "@/framework/queue/queue.js";
|
|
2
|
+
import { logger } from "@/framework/support/logger.js";
|
|
3
|
+
import { mail } from "@/framework/support/mail.js";
|
|
4
|
+
|
|
5
|
+
shouldQueue("{{module}}:mail", "mail", async (job) => {
|
|
6
|
+
const { to, subject, html } = job.data;
|
|
7
|
+
|
|
8
|
+
await mail.sendMail({ to, subject, html });
|
|
9
|
+
logger.info("Notification mail sent", { to, subject });
|
|
10
|
+
|
|
11
|
+
return { ok: true };
|
|
12
|
+
});
|
|
13
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createRoute, createRouter, HttpStatusCodes, jsonContent, z } from "@/framework/facade.js";
|
|
2
|
+
import { authMiddleware } from "@/middlewares/auth-middleware.js";
|
|
3
|
+
import { list, markAllRead, markRead, remove, unreadCount } from "../controllers/{{module}}.controller.js";
|
|
4
|
+
import { PaginatedNotificationsSchema, UnreadCountSchema } from "../controllers/{{module}}.schema.js";
|
|
5
|
+
|
|
6
|
+
const listRoute = createRoute({
|
|
7
|
+
path: "/",
|
|
8
|
+
method: "get",
|
|
9
|
+
tags: ["Notifications"],
|
|
10
|
+
responses: { [HttpStatusCodes.OK]: jsonContent(PaginatedNotificationsSchema, "Paginated notifications") },
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const unreadCountRoute = createRoute({
|
|
14
|
+
path: "/unread-count",
|
|
15
|
+
method: "get",
|
|
16
|
+
tags: ["Notifications"],
|
|
17
|
+
responses: { [HttpStatusCodes.OK]: jsonContent(UnreadCountSchema, "Unread count") },
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const markReadRoute = createRoute({
|
|
21
|
+
path: "/{id}/read",
|
|
22
|
+
method: "patch",
|
|
23
|
+
tags: ["Notifications"],
|
|
24
|
+
request: { params: z.object({ id: z.coerce.number() }) },
|
|
25
|
+
responses: { [HttpStatusCodes.OK]: jsonContent(z.object({ ok: z.boolean() }), "Marked as read") },
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const markAllReadRoute = createRoute({
|
|
29
|
+
path: "/read-all",
|
|
30
|
+
method: "patch",
|
|
31
|
+
tags: ["Notifications"],
|
|
32
|
+
responses: { [HttpStatusCodes.OK]: jsonContent(z.object({ ok: z.boolean() }), "All marked as read") },
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const deleteRoute = createRoute({
|
|
36
|
+
path: "/{id}",
|
|
37
|
+
method: "delete",
|
|
38
|
+
tags: ["Notifications"],
|
|
39
|
+
request: { params: z.object({ id: z.coerce.number() }) },
|
|
40
|
+
responses: { [HttpStatusCodes.OK]: jsonContent(z.object({ ok: z.boolean() }), "Deleted") },
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export default createRouter()
|
|
44
|
+
.group(authMiddleware)
|
|
45
|
+
.api(listRoute, list)
|
|
46
|
+
.api(unreadCountRoute, unreadCount)
|
|
47
|
+
.api(markReadRoute, markRead)
|
|
48
|
+
.api(markAllReadRoute, markAllRead)
|
|
49
|
+
.api(deleteRoute, remove);
|
|
50
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { group } from "@/framework/facade.js";
|
|
2
|
+
import { authMiddleware } from "@/middlewares/auth-middleware.js";
|
|
3
|
+
import { list, unreadCount, markRead, markAllRead, remove } from "../controllers/{{module}}.controller.js";
|
|
4
|
+
|
|
5
|
+
export default group()
|
|
6
|
+
.use(authMiddleware)
|
|
7
|
+
.get("/", list)
|
|
8
|
+
.get("/unread-count", unreadCount)
|
|
9
|
+
.patch("/:id/read", markRead)
|
|
10
|
+
.patch("/read-all", markAllRead)
|
|
11
|
+
.delete("/:id", remove);
|
|
12
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from "@/framework/facade.js";
|
|
2
|
+
|
|
3
|
+
export const NotificationSchema = z.object({
|
|
4
|
+
id: z.number(),
|
|
5
|
+
userId: z.number(),
|
|
6
|
+
type: z.string(),
|
|
7
|
+
title: z.string(),
|
|
8
|
+
body: z.string().nullable(),
|
|
9
|
+
data: z.any().nullable(),
|
|
10
|
+
link: z.string().nullable(),
|
|
11
|
+
readAt: z.string().nullable(),
|
|
12
|
+
createdAt: z.string(),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const UnreadCountSchema = z.object({
|
|
16
|
+
count: z.number(),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const PaginatedNotificationsSchema = z.object({
|
|
20
|
+
data: z.array(NotificationSchema),
|
|
21
|
+
total: z.number(),
|
|
22
|
+
unread: z.number(),
|
|
23
|
+
page: z.number(),
|
|
24
|
+
perPage: z.number(),
|
|
25
|
+
});
|
|
26
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const NotificationSchema = z.object({
|
|
4
|
+
id: z.number(),
|
|
5
|
+
userId: z.number(),
|
|
6
|
+
type: z.string(),
|
|
7
|
+
title: z.string(),
|
|
8
|
+
body: z.string().nullable(),
|
|
9
|
+
data: z.any().nullable(),
|
|
10
|
+
link: z.string().nullable(),
|
|
11
|
+
readAt: z.string().nullable(),
|
|
12
|
+
createdAt: z.string(),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const UnreadCountSchema = z.object({
|
|
16
|
+
count: z.number(),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const PaginatedNotificationsSchema = z.object({
|
|
20
|
+
data: z.array(NotificationSchema),
|
|
21
|
+
total: z.number(),
|
|
22
|
+
unread: z.number(),
|
|
23
|
+
page: z.number(),
|
|
24
|
+
perPage: z.number(),
|
|
25
|
+
});
|
|
26
|
+
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { createRoute, group, HttpStatusCodes, jsonContent } from "@/framework/facade.js";
|
|
2
|
+
import { requireRole } from "@/middlewares/role-middleware.js";
|
|
3
|
+
import { destroy, index, show, store, update } from "@/modules/{{module}}/controllers/{{controller}}.controller.js";
|
|
4
|
+
import {
|
|
5
|
+
Create{{ClassName}}Schema,
|
|
6
|
+
{{ClassName}}IdParamsSchema,
|
|
7
|
+
{{ClassName}}ListResponseSchema,
|
|
8
|
+
{{ClassName}}MessageSchema,
|
|
9
|
+
{{ClassName}}ResponseSchema,
|
|
10
|
+
Update{{ClassName}}Schema
|
|
11
|
+
} from "@/modules/{{module}}/controllers/{{controller}}.schema.js";
|
|
12
|
+
|
|
13
|
+
const indexRoute = createRoute({
|
|
14
|
+
path: "/",
|
|
15
|
+
method: "get",
|
|
16
|
+
tags: ["{{ModuleClass}}"],
|
|
17
|
+
responses: {
|
|
18
|
+
[HttpStatusCodes.OK]: jsonContent({{ClassName}}ListResponseSchema, "{{module}} list")
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const showRoute = createRoute({
|
|
23
|
+
path: "/{id}",
|
|
24
|
+
method: "get",
|
|
25
|
+
tags: ["{{ModuleClass}}"],
|
|
26
|
+
request: {
|
|
27
|
+
params: {{ClassName}}IdParamsSchema
|
|
28
|
+
},
|
|
29
|
+
responses: {
|
|
30
|
+
[HttpStatusCodes.OK]: jsonContent({{ClassName}}ResponseSchema, "{{module}} item"),
|
|
31
|
+
[HttpStatusCodes.NOT_FOUND]: jsonContent({{ClassName}}MessageSchema, "Not found")
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const storeRoute = createRoute({
|
|
36
|
+
path: "/",
|
|
37
|
+
method: "post",
|
|
38
|
+
tags: ["{{ModuleClass}}"],
|
|
39
|
+
request: {
|
|
40
|
+
body: jsonContent(Create{{ClassName}}Schema, "Create {{module}} payload")
|
|
41
|
+
},
|
|
42
|
+
responses: {
|
|
43
|
+
[HttpStatusCodes.CREATED]: jsonContent({{ClassName}}MessageSchema, "Created")
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const updateRoute = createRoute({
|
|
48
|
+
path: "/{id}",
|
|
49
|
+
method: "put",
|
|
50
|
+
tags: ["{{ModuleClass}}"],
|
|
51
|
+
request: {
|
|
52
|
+
params: {{ClassName}}IdParamsSchema,
|
|
53
|
+
body: jsonContent(Update{{ClassName}}Schema, "Update {{module}} payload")
|
|
54
|
+
},
|
|
55
|
+
responses: {
|
|
56
|
+
[HttpStatusCodes.OK]: jsonContent({{ClassName}}MessageSchema, "Updated"),
|
|
57
|
+
[HttpStatusCodes.NOT_FOUND]: jsonContent({{ClassName}}MessageSchema, "Not found")
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const destroyRoute = createRoute({
|
|
62
|
+
path: "/{id}",
|
|
63
|
+
method: "delete",
|
|
64
|
+
tags: ["{{ModuleClass}}"],
|
|
65
|
+
request: {
|
|
66
|
+
params: {{ClassName}}IdParamsSchema
|
|
67
|
+
},
|
|
68
|
+
responses: {
|
|
69
|
+
[HttpStatusCodes.OK]: jsonContent({{ClassName}}MessageSchema, "Deleted"),
|
|
70
|
+
[HttpStatusCodes.NOT_FOUND]: jsonContent({{ClassName}}MessageSchema, "Not found")
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export default group()
|
|
75
|
+
.api(indexRoute, index)
|
|
76
|
+
.api(showRoute, show)
|
|
77
|
+
.api(storeRoute, store)
|
|
78
|
+
.api(updateRoute, update)
|
|
79
|
+
.api(destroyRoute, destroy);
|
|
80
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { group } from "@/framework/facade.js";
|
|
2
|
+
import { requireRole } from "@/middlewares/role-middleware.js";
|
|
3
|
+
import { index, show, store, update, destroy } from "@/modules/{{module}}/controllers/{{controller}}.controller.js";
|
|
4
|
+
|
|
5
|
+
export default group()
|
|
6
|
+
.get("/", index)
|
|
7
|
+
.get("/:id", show)
|
|
8
|
+
.post("/", store)
|
|
9
|
+
.put("/:id", update)
|
|
10
|
+
.delete("/:id", destroy);
|
|
11
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DateTime } from "luxon";
|
|
2
|
+
import { defineSchedule, dispatchEvent } from "@/framework/facade.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* name: Unique schedule id used as the distributed lock key.
|
|
6
|
+
* expression: Cron expression that controls when the task runs.
|
|
7
|
+
* timezone: IANA timezone for cron evaluation (example: "UTC").
|
|
8
|
+
* runOnInit: Runs once immediately when scheduler starts.
|
|
9
|
+
* enabled: Enables or disables this schedule without deleting code.
|
|
10
|
+
* ttlMs: Lock TTL in milliseconds to avoid duplicate execution.
|
|
11
|
+
*/
|
|
12
|
+
defineSchedule({
|
|
13
|
+
name: "{{module}}:{{name}}",
|
|
14
|
+
expression: "0 * * * * *",
|
|
15
|
+
// timezone: "UTC",
|
|
16
|
+
// runOnInit: false,
|
|
17
|
+
// enabled: true,
|
|
18
|
+
// ttlMs: 120000,
|
|
19
|
+
handler: async () => {
|
|
20
|
+
/**
|
|
21
|
+
* dispatchEvent name: Event id to publish to listeners.
|
|
22
|
+
* payload: Data sent to queue/broadcast consumers.
|
|
23
|
+
* queue: Optional queue target for async event consumers.
|
|
24
|
+
* broadcast: Optional realtime fanout (all/users/roles/rooms).
|
|
25
|
+
*/
|
|
26
|
+
// await dispatchEvent("{{module}}.{{name}}", {
|
|
27
|
+
// origin: "scheduler",
|
|
28
|
+
// createdAt: DateTime.now()
|
|
29
|
+
// }, {
|
|
30
|
+
// queue: "default"
|
|
31
|
+
// });
|
|
32
|
+
|
|
33
|
+
DateTime.now().toISO();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { db } from "@/framework/facade.js";
|
|
2
|
+
import { {{tableVariable}} } from "@/modules/{{module}}/database/models/{{name}}.js";
|
|
3
|
+
|
|
4
|
+
export const table = {{tableVariable}};
|
|
5
|
+
|
|
6
|
+
export default async function {{ClassName}}Seeder() {
|
|
7
|
+
const rows = [
|
|
8
|
+
// Add your seed data here
|
|
9
|
+
// Example:
|
|
10
|
+
// { name: "{{ClassName}} 1", description: "This is the first {{name}}" },
|
|
11
|
+
// { name: "{{ClassName}} 2", description: "This is the second {{name}}" }
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
for (const row of rows) {
|
|
15
|
+
await db.insert({{tableVariable}}).values(row);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
console.log("{{ClassName}} seeder completed");
|
|
19
|
+
}
|
|
20
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
describe("{{module}}.{{name}}", () => {
|
|
4
|
+
it("should return true for basic assertion", () => {
|
|
5
|
+
expect(true).toBe(true);
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it("should handle string operations", () => {
|
|
9
|
+
const name = "{{module}}";
|
|
10
|
+
expect(name).toBe("{{module}}");
|
|
11
|
+
expect(name.length).toBeGreaterThan(0);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("should handle array operations", () => {
|
|
15
|
+
const items = ["item1", "item2", "item3"];
|
|
16
|
+
expect(items).toHaveLength(3);
|
|
17
|
+
expect(items).toContain("item1");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Add your test cases below
|
|
21
|
+
});
|
|
22
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
/** Read CLI-relevant values from the TS config via a one-shot tsx eval.
|
|
4
|
+
* Keeps the dev runner's defaults (queues, maildev ports, redis-view port)
|
|
5
|
+
* driven by src/config instead of hardcoded/duplicated values. Falls back to
|
|
6
|
+
* the previous defaults when the config cannot be loaded. */
|
|
7
|
+
export function readCliConfig() {
|
|
8
|
+
const script = [
|
|
9
|
+
"import { queueConfig, mailConfig, redisConfig } from './src/config/index.ts';",
|
|
10
|
+
"process.stdout.write(JSON.stringify({",
|
|
11
|
+
" queues: queueConfig.queues,",
|
|
12
|
+
" maildev: mailConfig.maildev,",
|
|
13
|
+
" commanderPort: redisConfig.commanderPort,",
|
|
14
|
+
" redisEnabled: redisConfig.enabled",
|
|
15
|
+
"}));"
|
|
16
|
+
].join("");
|
|
17
|
+
const result = spawnSync(process.execPath, ["--import", "tsx", "--input-type=module", "--eval", script], {
|
|
18
|
+
cwd: process.cwd(),
|
|
19
|
+
encoding: "utf8",
|
|
20
|
+
timeout: 30000,
|
|
21
|
+
windowsHide: true,
|
|
22
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (result.status !== 0 || !result.stdout) {
|
|
26
|
+
return {
|
|
27
|
+
queues: ["default", "mail", "maintenance"],
|
|
28
|
+
maildev: { smtpPort: 1089, webPort: 1080 },
|
|
29
|
+
commanderPort: 1369,
|
|
30
|
+
redisEnabled: true
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
return JSON.parse(result.stdout);
|
|
36
|
+
} catch {
|
|
37
|
+
return {
|
|
38
|
+
queues: ["default", "mail", "maintenance"],
|
|
39
|
+
maildev: { smtpPort: 1089, webPort: 1080 },
|
|
40
|
+
commanderPort: 1369,
|
|
41
|
+
redisEnabled: true
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const DEFAULT_DATABASE_URL = "sqlite:./src/storage/database/nexwire.sqlite";
|
|
2
|
+
|
|
3
|
+
/** Detect current DB dialect from DATABASE_URL (sqlite/mysql/postgresql). Falls back to sqlite. */
|
|
4
|
+
export function detectDialect() {
|
|
5
|
+
const url = String(process.env.DATABASE_URL || DEFAULT_DATABASE_URL).toLowerCase();
|
|
6
|
+
if (url.startsWith("mysql") || url.startsWith("mariadb")) return "mysql";
|
|
7
|
+
if (url.startsWith("postgres") || url.startsWith("postgresql")) return "postgresql";
|
|
8
|
+
return "sqlite";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Return the raw DATABASE_URL string or the default sqlite fallback. */
|
|
12
|
+
export function databaseUrl() {
|
|
13
|
+
return String(process.env.DATABASE_URL || DEFAULT_DATABASE_URL);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Parse DATABASE_URL into a URL object. Returns null if invalid. */
|
|
17
|
+
export function parsedDatabaseUrl() {
|
|
18
|
+
try {
|
|
19
|
+
return new URL(databaseUrl());
|
|
20
|
+
} catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Extract the database name from the pathname of a parsed DATABASE_URL. */
|
|
26
|
+
export function databaseNameFromUrl(url) {
|
|
27
|
+
const pathname = String(url?.pathname || "").replace(/^\/+/, "");
|
|
28
|
+
return pathname ? decodeURIComponent(pathname) : "";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Check if OPEN_API env is enabled (defaults to true). */
|
|
32
|
+
export function openApiEnabled() {
|
|
33
|
+
const value = String(process.env.OPEN_API ?? "true")
|
|
34
|
+
.trim()
|
|
35
|
+
.toLowerCase();
|
|
36
|
+
return value !== "false" && value !== "0" && value !== "no";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Check if REDIS env is enabled (defaults to false). Matches Zod transform in env.ts. */
|
|
40
|
+
export function redisEnabled() {
|
|
41
|
+
const value = String(process.env.REDIS ?? "false")
|
|
42
|
+
.trim()
|
|
43
|
+
.toLowerCase();
|
|
44
|
+
return value !== "false" && value !== "0";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Detect DB dialect for deploy context (uses raw DATABASE_URL or explicit URL). */
|
|
48
|
+
export function detectDeployDatabase(urlOverride) {
|
|
49
|
+
const url = String(urlOverride || process.env.DATABASE_URL || "").toLowerCase();
|
|
50
|
+
if (url.startsWith("mysql") || url.startsWith("mariadb")) return "mysql";
|
|
51
|
+
if (url.startsWith("postgres") || url.startsWith("postgresql")) return "postgres";
|
|
52
|
+
return "sqlite";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Convert a sqlite:// URL to a filesystem path. */
|
|
56
|
+
export function sqlitePathFromUrl(url) {
|
|
57
|
+
if (url.startsWith("sqlite:///")) return url.replace("sqlite:///", "/");
|
|
58
|
+
if (url.startsWith("sqlite://")) return url.replace("sqlite://", "");
|
|
59
|
+
if (url.startsWith("sqlite:")) return url.replace("sqlite:", "");
|
|
60
|
+
return url;
|
|
61
|
+
}
|