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,40 @@
|
|
|
1
|
+
import { databaseConfig } from "./database.js";
|
|
2
|
+
import { mailConfig } from "./mail.js";
|
|
3
|
+
import { redisConfig } from "./redis.js";
|
|
4
|
+
import { storageConfig } from "./storage.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Why: Validates that resolved configs are internally consistent at startup.
|
|
8
|
+
* When: Called before any framework subsystem initializes.
|
|
9
|
+
* Where: kernel.ts, before storage.init() and initRedis().
|
|
10
|
+
* How: Checks cross-config dependencies and throws clear errors for inconsistencies.
|
|
11
|
+
*/
|
|
12
|
+
export function validateConfig(): void {
|
|
13
|
+
if (!databaseConfig.url) {
|
|
14
|
+
throw new Error("DATABASE_URL is required but is empty");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (storageConfig.driver === "s3") {
|
|
18
|
+
if (!storageConfig.bucket) {
|
|
19
|
+
throw new Error("STORAGE_BUCKET is required when storage driver is s3");
|
|
20
|
+
}
|
|
21
|
+
if (!storageConfig.accessKeyId || !storageConfig.secretAccessKey) {
|
|
22
|
+
throw new Error("STORAGE_ACCESS_KEY_ID and STORAGE_SECRET_ACCESS_KEY are required when storage driver is s3");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (redisConfig.enabled) {
|
|
27
|
+
try {
|
|
28
|
+
const url = new URL(redisConfig.url);
|
|
29
|
+
if (!url.hostname || url.port === "") {
|
|
30
|
+
throw new Error(`REDIS_URL is invalid: "${redisConfig.url}" — must include host and port`);
|
|
31
|
+
}
|
|
32
|
+
} catch (error) {
|
|
33
|
+
throw new Error(`REDIS_URL is invalid: "${redisConfig.url}" — ${error instanceof Error ? error.message : error}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!mailConfig.failSilent && !mailConfig.username) {
|
|
38
|
+
throw new Error("MAIL_USERNAME is required when MAIL_FAIL_SILENT is false");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
CREATE TABLE `notifications` (
|
|
2
|
+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
3
|
+
`user_id` integer NOT NULL,
|
|
4
|
+
`type` text NOT NULL,
|
|
5
|
+
`title` text NOT NULL,
|
|
6
|
+
`body` text,
|
|
7
|
+
`data` text,
|
|
8
|
+
`link` text,
|
|
9
|
+
`read_at` integer,
|
|
10
|
+
`created_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL,
|
|
11
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE cascade
|
|
12
|
+
);
|
|
13
|
+
--> statement-breakpoint
|
|
14
|
+
CREATE TABLE `roles` (
|
|
15
|
+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
16
|
+
`name` text NOT NULL,
|
|
17
|
+
`created_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL,
|
|
18
|
+
`updated_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL
|
|
19
|
+
);
|
|
20
|
+
--> statement-breakpoint
|
|
21
|
+
CREATE UNIQUE INDEX `roles_name_unique` ON `roles` (`name`);--> statement-breakpoint
|
|
22
|
+
CREATE TABLE `email_verification_tokens` (
|
|
23
|
+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
24
|
+
`email` text NOT NULL,
|
|
25
|
+
`token` text NOT NULL,
|
|
26
|
+
`expires_at` integer NOT NULL,
|
|
27
|
+
`created_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL
|
|
28
|
+
);
|
|
29
|
+
--> statement-breakpoint
|
|
30
|
+
CREATE TABLE `password_reset_tokens` (
|
|
31
|
+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
32
|
+
`email` text NOT NULL,
|
|
33
|
+
`token` text NOT NULL,
|
|
34
|
+
`expires_at` integer NOT NULL,
|
|
35
|
+
`created_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL
|
|
36
|
+
);
|
|
37
|
+
--> statement-breakpoint
|
|
38
|
+
CREATE TABLE `refresh_tokens` (
|
|
39
|
+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
40
|
+
`user_id` integer,
|
|
41
|
+
`jti` text NOT NULL,
|
|
42
|
+
`revoked` integer DEFAULT false,
|
|
43
|
+
`expires_at` integer NOT NULL,
|
|
44
|
+
`created_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL,
|
|
45
|
+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE set null
|
|
46
|
+
);
|
|
47
|
+
--> statement-breakpoint
|
|
48
|
+
CREATE UNIQUE INDEX `refresh_tokens_jti_unique` ON `refresh_tokens` (`jti`);--> statement-breakpoint
|
|
49
|
+
CREATE TABLE `users` (
|
|
50
|
+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
51
|
+
`name` text NOT NULL,
|
|
52
|
+
`email` text NOT NULL,
|
|
53
|
+
`password` text NOT NULL,
|
|
54
|
+
`role_id` integer,
|
|
55
|
+
`email_verified_at` integer,
|
|
56
|
+
`created_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL,
|
|
57
|
+
`updated_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL,
|
|
58
|
+
FOREIGN KEY (`role_id`) REFERENCES `roles`(`id`) ON UPDATE cascade ON DELETE set null
|
|
59
|
+
);
|
|
60
|
+
--> statement-breakpoint
|
|
61
|
+
CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);
|
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "6",
|
|
3
|
+
"dialect": "sqlite",
|
|
4
|
+
"id": "e998e08f-4fb2-46ee-baa2-e2480d4b685a",
|
|
5
|
+
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
6
|
+
"tables": {
|
|
7
|
+
"notifications": {
|
|
8
|
+
"name": "notifications",
|
|
9
|
+
"columns": {
|
|
10
|
+
"id": {
|
|
11
|
+
"name": "id",
|
|
12
|
+
"type": "integer",
|
|
13
|
+
"primaryKey": true,
|
|
14
|
+
"notNull": true,
|
|
15
|
+
"autoincrement": true
|
|
16
|
+
},
|
|
17
|
+
"user_id": {
|
|
18
|
+
"name": "user_id",
|
|
19
|
+
"type": "integer",
|
|
20
|
+
"primaryKey": false,
|
|
21
|
+
"notNull": true,
|
|
22
|
+
"autoincrement": false
|
|
23
|
+
},
|
|
24
|
+
"type": {
|
|
25
|
+
"name": "type",
|
|
26
|
+
"type": "text",
|
|
27
|
+
"primaryKey": false,
|
|
28
|
+
"notNull": true,
|
|
29
|
+
"autoincrement": false
|
|
30
|
+
},
|
|
31
|
+
"title": {
|
|
32
|
+
"name": "title",
|
|
33
|
+
"type": "text",
|
|
34
|
+
"primaryKey": false,
|
|
35
|
+
"notNull": true,
|
|
36
|
+
"autoincrement": false
|
|
37
|
+
},
|
|
38
|
+
"body": {
|
|
39
|
+
"name": "body",
|
|
40
|
+
"type": "text",
|
|
41
|
+
"primaryKey": false,
|
|
42
|
+
"notNull": false,
|
|
43
|
+
"autoincrement": false
|
|
44
|
+
},
|
|
45
|
+
"data": {
|
|
46
|
+
"name": "data",
|
|
47
|
+
"type": "text",
|
|
48
|
+
"primaryKey": false,
|
|
49
|
+
"notNull": false,
|
|
50
|
+
"autoincrement": false
|
|
51
|
+
},
|
|
52
|
+
"link": {
|
|
53
|
+
"name": "link",
|
|
54
|
+
"type": "text",
|
|
55
|
+
"primaryKey": false,
|
|
56
|
+
"notNull": false,
|
|
57
|
+
"autoincrement": false
|
|
58
|
+
},
|
|
59
|
+
"read_at": {
|
|
60
|
+
"name": "read_at",
|
|
61
|
+
"type": "integer",
|
|
62
|
+
"primaryKey": false,
|
|
63
|
+
"notNull": false,
|
|
64
|
+
"autoincrement": false
|
|
65
|
+
},
|
|
66
|
+
"created_at": {
|
|
67
|
+
"name": "created_at",
|
|
68
|
+
"type": "integer",
|
|
69
|
+
"primaryKey": false,
|
|
70
|
+
"notNull": true,
|
|
71
|
+
"autoincrement": false,
|
|
72
|
+
"default": "(cast((julianday('now') - 2440587.5)*86400000 as integer))"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"indexes": {},
|
|
76
|
+
"foreignKeys": {
|
|
77
|
+
"notifications_user_id_users_id_fk": {
|
|
78
|
+
"name": "notifications_user_id_users_id_fk",
|
|
79
|
+
"tableFrom": "notifications",
|
|
80
|
+
"tableTo": "users",
|
|
81
|
+
"columnsFrom": [
|
|
82
|
+
"user_id"
|
|
83
|
+
],
|
|
84
|
+
"columnsTo": [
|
|
85
|
+
"id"
|
|
86
|
+
],
|
|
87
|
+
"onDelete": "cascade",
|
|
88
|
+
"onUpdate": "cascade"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"compositePrimaryKeys": {},
|
|
92
|
+
"uniqueConstraints": {},
|
|
93
|
+
"checkConstraints": {}
|
|
94
|
+
},
|
|
95
|
+
"roles": {
|
|
96
|
+
"name": "roles",
|
|
97
|
+
"columns": {
|
|
98
|
+
"id": {
|
|
99
|
+
"name": "id",
|
|
100
|
+
"type": "integer",
|
|
101
|
+
"primaryKey": true,
|
|
102
|
+
"notNull": true,
|
|
103
|
+
"autoincrement": true
|
|
104
|
+
},
|
|
105
|
+
"name": {
|
|
106
|
+
"name": "name",
|
|
107
|
+
"type": "text",
|
|
108
|
+
"primaryKey": false,
|
|
109
|
+
"notNull": true,
|
|
110
|
+
"autoincrement": false
|
|
111
|
+
},
|
|
112
|
+
"created_at": {
|
|
113
|
+
"name": "created_at",
|
|
114
|
+
"type": "integer",
|
|
115
|
+
"primaryKey": false,
|
|
116
|
+
"notNull": true,
|
|
117
|
+
"autoincrement": false,
|
|
118
|
+
"default": "(cast((julianday('now') - 2440587.5)*86400000 as integer))"
|
|
119
|
+
},
|
|
120
|
+
"updated_at": {
|
|
121
|
+
"name": "updated_at",
|
|
122
|
+
"type": "integer",
|
|
123
|
+
"primaryKey": false,
|
|
124
|
+
"notNull": true,
|
|
125
|
+
"autoincrement": false,
|
|
126
|
+
"default": "(cast((julianday('now') - 2440587.5)*86400000 as integer))"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"indexes": {
|
|
130
|
+
"roles_name_unique": {
|
|
131
|
+
"name": "roles_name_unique",
|
|
132
|
+
"columns": [
|
|
133
|
+
"name"
|
|
134
|
+
],
|
|
135
|
+
"isUnique": true
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"foreignKeys": {},
|
|
139
|
+
"compositePrimaryKeys": {},
|
|
140
|
+
"uniqueConstraints": {},
|
|
141
|
+
"checkConstraints": {}
|
|
142
|
+
},
|
|
143
|
+
"email_verification_tokens": {
|
|
144
|
+
"name": "email_verification_tokens",
|
|
145
|
+
"columns": {
|
|
146
|
+
"id": {
|
|
147
|
+
"name": "id",
|
|
148
|
+
"type": "integer",
|
|
149
|
+
"primaryKey": true,
|
|
150
|
+
"notNull": true,
|
|
151
|
+
"autoincrement": true
|
|
152
|
+
},
|
|
153
|
+
"email": {
|
|
154
|
+
"name": "email",
|
|
155
|
+
"type": "text",
|
|
156
|
+
"primaryKey": false,
|
|
157
|
+
"notNull": true,
|
|
158
|
+
"autoincrement": false
|
|
159
|
+
},
|
|
160
|
+
"token": {
|
|
161
|
+
"name": "token",
|
|
162
|
+
"type": "text",
|
|
163
|
+
"primaryKey": false,
|
|
164
|
+
"notNull": true,
|
|
165
|
+
"autoincrement": false
|
|
166
|
+
},
|
|
167
|
+
"expires_at": {
|
|
168
|
+
"name": "expires_at",
|
|
169
|
+
"type": "integer",
|
|
170
|
+
"primaryKey": false,
|
|
171
|
+
"notNull": true,
|
|
172
|
+
"autoincrement": false
|
|
173
|
+
},
|
|
174
|
+
"created_at": {
|
|
175
|
+
"name": "created_at",
|
|
176
|
+
"type": "integer",
|
|
177
|
+
"primaryKey": false,
|
|
178
|
+
"notNull": true,
|
|
179
|
+
"autoincrement": false,
|
|
180
|
+
"default": "(cast((julianday('now') - 2440587.5)*86400000 as integer))"
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"indexes": {},
|
|
184
|
+
"foreignKeys": {},
|
|
185
|
+
"compositePrimaryKeys": {},
|
|
186
|
+
"uniqueConstraints": {},
|
|
187
|
+
"checkConstraints": {}
|
|
188
|
+
},
|
|
189
|
+
"password_reset_tokens": {
|
|
190
|
+
"name": "password_reset_tokens",
|
|
191
|
+
"columns": {
|
|
192
|
+
"id": {
|
|
193
|
+
"name": "id",
|
|
194
|
+
"type": "integer",
|
|
195
|
+
"primaryKey": true,
|
|
196
|
+
"notNull": true,
|
|
197
|
+
"autoincrement": true
|
|
198
|
+
},
|
|
199
|
+
"email": {
|
|
200
|
+
"name": "email",
|
|
201
|
+
"type": "text",
|
|
202
|
+
"primaryKey": false,
|
|
203
|
+
"notNull": true,
|
|
204
|
+
"autoincrement": false
|
|
205
|
+
},
|
|
206
|
+
"token": {
|
|
207
|
+
"name": "token",
|
|
208
|
+
"type": "text",
|
|
209
|
+
"primaryKey": false,
|
|
210
|
+
"notNull": true,
|
|
211
|
+
"autoincrement": false
|
|
212
|
+
},
|
|
213
|
+
"expires_at": {
|
|
214
|
+
"name": "expires_at",
|
|
215
|
+
"type": "integer",
|
|
216
|
+
"primaryKey": false,
|
|
217
|
+
"notNull": true,
|
|
218
|
+
"autoincrement": false
|
|
219
|
+
},
|
|
220
|
+
"created_at": {
|
|
221
|
+
"name": "created_at",
|
|
222
|
+
"type": "integer",
|
|
223
|
+
"primaryKey": false,
|
|
224
|
+
"notNull": true,
|
|
225
|
+
"autoincrement": false,
|
|
226
|
+
"default": "(cast((julianday('now') - 2440587.5)*86400000 as integer))"
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
"indexes": {},
|
|
230
|
+
"foreignKeys": {},
|
|
231
|
+
"compositePrimaryKeys": {},
|
|
232
|
+
"uniqueConstraints": {},
|
|
233
|
+
"checkConstraints": {}
|
|
234
|
+
},
|
|
235
|
+
"refresh_tokens": {
|
|
236
|
+
"name": "refresh_tokens",
|
|
237
|
+
"columns": {
|
|
238
|
+
"id": {
|
|
239
|
+
"name": "id",
|
|
240
|
+
"type": "integer",
|
|
241
|
+
"primaryKey": true,
|
|
242
|
+
"notNull": true,
|
|
243
|
+
"autoincrement": true
|
|
244
|
+
},
|
|
245
|
+
"user_id": {
|
|
246
|
+
"name": "user_id",
|
|
247
|
+
"type": "integer",
|
|
248
|
+
"primaryKey": false,
|
|
249
|
+
"notNull": false,
|
|
250
|
+
"autoincrement": false
|
|
251
|
+
},
|
|
252
|
+
"jti": {
|
|
253
|
+
"name": "jti",
|
|
254
|
+
"type": "text",
|
|
255
|
+
"primaryKey": false,
|
|
256
|
+
"notNull": true,
|
|
257
|
+
"autoincrement": false
|
|
258
|
+
},
|
|
259
|
+
"revoked": {
|
|
260
|
+
"name": "revoked",
|
|
261
|
+
"type": "integer",
|
|
262
|
+
"primaryKey": false,
|
|
263
|
+
"notNull": false,
|
|
264
|
+
"autoincrement": false,
|
|
265
|
+
"default": false
|
|
266
|
+
},
|
|
267
|
+
"expires_at": {
|
|
268
|
+
"name": "expires_at",
|
|
269
|
+
"type": "integer",
|
|
270
|
+
"primaryKey": false,
|
|
271
|
+
"notNull": true,
|
|
272
|
+
"autoincrement": false
|
|
273
|
+
},
|
|
274
|
+
"created_at": {
|
|
275
|
+
"name": "created_at",
|
|
276
|
+
"type": "integer",
|
|
277
|
+
"primaryKey": false,
|
|
278
|
+
"notNull": true,
|
|
279
|
+
"autoincrement": false,
|
|
280
|
+
"default": "(cast((julianday('now') - 2440587.5)*86400000 as integer))"
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
"indexes": {
|
|
284
|
+
"refresh_tokens_jti_unique": {
|
|
285
|
+
"name": "refresh_tokens_jti_unique",
|
|
286
|
+
"columns": [
|
|
287
|
+
"jti"
|
|
288
|
+
],
|
|
289
|
+
"isUnique": true
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
"foreignKeys": {
|
|
293
|
+
"refresh_tokens_user_id_users_id_fk": {
|
|
294
|
+
"name": "refresh_tokens_user_id_users_id_fk",
|
|
295
|
+
"tableFrom": "refresh_tokens",
|
|
296
|
+
"tableTo": "users",
|
|
297
|
+
"columnsFrom": [
|
|
298
|
+
"user_id"
|
|
299
|
+
],
|
|
300
|
+
"columnsTo": [
|
|
301
|
+
"id"
|
|
302
|
+
],
|
|
303
|
+
"onDelete": "set null",
|
|
304
|
+
"onUpdate": "cascade"
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
"compositePrimaryKeys": {},
|
|
308
|
+
"uniqueConstraints": {},
|
|
309
|
+
"checkConstraints": {}
|
|
310
|
+
},
|
|
311
|
+
"users": {
|
|
312
|
+
"name": "users",
|
|
313
|
+
"columns": {
|
|
314
|
+
"id": {
|
|
315
|
+
"name": "id",
|
|
316
|
+
"type": "integer",
|
|
317
|
+
"primaryKey": true,
|
|
318
|
+
"notNull": true,
|
|
319
|
+
"autoincrement": true
|
|
320
|
+
},
|
|
321
|
+
"name": {
|
|
322
|
+
"name": "name",
|
|
323
|
+
"type": "text",
|
|
324
|
+
"primaryKey": false,
|
|
325
|
+
"notNull": true,
|
|
326
|
+
"autoincrement": false
|
|
327
|
+
},
|
|
328
|
+
"email": {
|
|
329
|
+
"name": "email",
|
|
330
|
+
"type": "text",
|
|
331
|
+
"primaryKey": false,
|
|
332
|
+
"notNull": true,
|
|
333
|
+
"autoincrement": false
|
|
334
|
+
},
|
|
335
|
+
"password": {
|
|
336
|
+
"name": "password",
|
|
337
|
+
"type": "text",
|
|
338
|
+
"primaryKey": false,
|
|
339
|
+
"notNull": true,
|
|
340
|
+
"autoincrement": false
|
|
341
|
+
},
|
|
342
|
+
"role_id": {
|
|
343
|
+
"name": "role_id",
|
|
344
|
+
"type": "integer",
|
|
345
|
+
"primaryKey": false,
|
|
346
|
+
"notNull": false,
|
|
347
|
+
"autoincrement": false
|
|
348
|
+
},
|
|
349
|
+
"email_verified_at": {
|
|
350
|
+
"name": "email_verified_at",
|
|
351
|
+
"type": "integer",
|
|
352
|
+
"primaryKey": false,
|
|
353
|
+
"notNull": false,
|
|
354
|
+
"autoincrement": false
|
|
355
|
+
},
|
|
356
|
+
"created_at": {
|
|
357
|
+
"name": "created_at",
|
|
358
|
+
"type": "integer",
|
|
359
|
+
"primaryKey": false,
|
|
360
|
+
"notNull": true,
|
|
361
|
+
"autoincrement": false,
|
|
362
|
+
"default": "(cast((julianday('now') - 2440587.5)*86400000 as integer))"
|
|
363
|
+
},
|
|
364
|
+
"updated_at": {
|
|
365
|
+
"name": "updated_at",
|
|
366
|
+
"type": "integer",
|
|
367
|
+
"primaryKey": false,
|
|
368
|
+
"notNull": true,
|
|
369
|
+
"autoincrement": false,
|
|
370
|
+
"default": "(cast((julianday('now') - 2440587.5)*86400000 as integer))"
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
"indexes": {
|
|
374
|
+
"users_email_unique": {
|
|
375
|
+
"name": "users_email_unique",
|
|
376
|
+
"columns": [
|
|
377
|
+
"email"
|
|
378
|
+
],
|
|
379
|
+
"isUnique": true
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
"foreignKeys": {
|
|
383
|
+
"users_role_id_roles_id_fk": {
|
|
384
|
+
"name": "users_role_id_roles_id_fk",
|
|
385
|
+
"tableFrom": "users",
|
|
386
|
+
"tableTo": "roles",
|
|
387
|
+
"columnsFrom": [
|
|
388
|
+
"role_id"
|
|
389
|
+
],
|
|
390
|
+
"columnsTo": [
|
|
391
|
+
"id"
|
|
392
|
+
],
|
|
393
|
+
"onDelete": "set null",
|
|
394
|
+
"onUpdate": "cascade"
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
"compositePrimaryKeys": {},
|
|
398
|
+
"uniqueConstraints": {},
|
|
399
|
+
"checkConstraints": {}
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
"views": {},
|
|
403
|
+
"enums": {},
|
|
404
|
+
"_meta": {
|
|
405
|
+
"schemas": {},
|
|
406
|
+
"tables": {},
|
|
407
|
+
"columns": {}
|
|
408
|
+
},
|
|
409
|
+
"internal": {
|
|
410
|
+
"indexes": {}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { config } from "dotenv";
|
|
2
|
+
import { expand } from "dotenv-expand";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
expand(config({ override: true }));
|
|
6
|
+
|
|
7
|
+
const envSchema = z
|
|
8
|
+
.object({
|
|
9
|
+
APP_NAME: z.string().default("nexwire"),
|
|
10
|
+
APP_ENV: z.enum(["development", "production", "test"]).default("development"),
|
|
11
|
+
APP_PORT: z.coerce.number().default(3000),
|
|
12
|
+
APP_URL: z.string().trim().min(1, "APP_URL is required in .env"),
|
|
13
|
+
UI: z
|
|
14
|
+
.string()
|
|
15
|
+
.default("true")
|
|
16
|
+
.transform((value) => value.trim().toLowerCase() !== "false" && value.trim() !== "0"),
|
|
17
|
+
FRONTEND_URL: z
|
|
18
|
+
.string()
|
|
19
|
+
.optional()
|
|
20
|
+
.transform((value) => value?.trim() || undefined),
|
|
21
|
+
DATABASE_URL: z.string().default("sqlite:./src/storage/database/nexwire.sqlite"),
|
|
22
|
+
REDIS: z
|
|
23
|
+
.string()
|
|
24
|
+
.default("false")
|
|
25
|
+
.transform((value) => value.trim().toLowerCase() !== "false" && value.trim() !== "0"),
|
|
26
|
+
REDIS_URL: z.string().default("redis://127.0.0.1:6379"),
|
|
27
|
+
REDIS_PREFIX: z
|
|
28
|
+
.string()
|
|
29
|
+
.default("nexwire")
|
|
30
|
+
.transform((value) => value.trim()),
|
|
31
|
+
JWT_ACCESS_SECRET: z.string(),
|
|
32
|
+
JWT_REFRESH_SECRET: z.string(),
|
|
33
|
+
COOKIE_SECRET: z.string(),
|
|
34
|
+
STORAGE_ACCESS_KEY_ID: z
|
|
35
|
+
.string()
|
|
36
|
+
.optional()
|
|
37
|
+
.transform((value) => value?.trim() || undefined),
|
|
38
|
+
STORAGE_SECRET_ACCESS_KEY: z
|
|
39
|
+
.string()
|
|
40
|
+
.optional()
|
|
41
|
+
.transform((value) => value?.trim() || undefined),
|
|
42
|
+
MAIL_USERNAME: z.string().default(""),
|
|
43
|
+
MAIL_PASSWORD: z.string().default(""),
|
|
44
|
+
OPEN_API: z
|
|
45
|
+
.string()
|
|
46
|
+
.default("true")
|
|
47
|
+
.transform((value) => value.trim().toLowerCase() !== "false" && value.trim() !== "0"),
|
|
48
|
+
SOCKET: z
|
|
49
|
+
.string()
|
|
50
|
+
.default("false")
|
|
51
|
+
.transform((value) => value.trim().toLowerCase() !== "false" && value.trim() !== "0"),
|
|
52
|
+
SECURITY_HEADERS: z
|
|
53
|
+
.string()
|
|
54
|
+
.default("true")
|
|
55
|
+
.transform((value) => value.trim().toLowerCase() !== "false" && value.trim() !== "0")
|
|
56
|
+
})
|
|
57
|
+
.superRefine((data, ctx) => {
|
|
58
|
+
for (const key of ["JWT_ACCESS_SECRET", "JWT_REFRESH_SECRET", "COOKIE_SECRET"] as const) {
|
|
59
|
+
if (!data[key]) {
|
|
60
|
+
ctx.addIssue({
|
|
61
|
+
code: "custom",
|
|
62
|
+
path: [key],
|
|
63
|
+
message: `${key} is required`
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const parsedEnv = envSchema.parse(process.env);
|
|
70
|
+
|
|
71
|
+
export const env = {
|
|
72
|
+
...parsedEnv,
|
|
73
|
+
FRONTEND_URL: parsedEnv.FRONTEND_URL
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type Env = typeof env;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { cacheConfig, redisConfig } from "@/config/index.js";
|
|
2
|
+
import { redisClientIfReady } from "@/framework/redis/client.js";
|
|
3
|
+
|
|
4
|
+
function cacheKey(key: string) {
|
|
5
|
+
return `${cacheConfig.keyPrefix}:${key}`;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Why: Provides Redis-backed cache helpers with graceful fallback behavior.
|
|
10
|
+
* When: Controllers/jobs need temporary computed data caching.
|
|
11
|
+
* Where: Application module code via facade.
|
|
12
|
+
* How: Uses namespaced Redis keys and JSON serialization.
|
|
13
|
+
*/
|
|
14
|
+
export const cache = {
|
|
15
|
+
/**
|
|
16
|
+
* Why: Reads cached JSON value by key.
|
|
17
|
+
* When: A feature wants fast lookup before recomputing.
|
|
18
|
+
* Where: Controllers/jobs/services using shared cache.
|
|
19
|
+
* How: Fetches namespaced Redis key and parses JSON.
|
|
20
|
+
*/
|
|
21
|
+
async get<T>(key: string, fallback: T | null = null) {
|
|
22
|
+
const client = redisClientIfReady();
|
|
23
|
+
if (!client) return fallback;
|
|
24
|
+
|
|
25
|
+
const value = await client.get(cacheKey(key));
|
|
26
|
+
return value ? (JSON.parse(value) as T) : fallback;
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Why: Stores value in cache with TTL.
|
|
31
|
+
* When: Data should be reused for a limited period.
|
|
32
|
+
* Where: Application code caching expensive results.
|
|
33
|
+
* How: Serializes value and writes with Redis EX seconds.
|
|
34
|
+
*/
|
|
35
|
+
async put(key: string, value: unknown, ttl = cacheConfig.ttlSeconds) {
|
|
36
|
+
const client = redisClientIfReady();
|
|
37
|
+
if (!client) return false;
|
|
38
|
+
|
|
39
|
+
await client.set(cacheKey(key), JSON.stringify(value), "EX", ttl);
|
|
40
|
+
return true;
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Why: Deletes a cached value by key.
|
|
45
|
+
* When: Cached data becomes stale or must be invalidated.
|
|
46
|
+
* Where: Write/update flows that change source data.
|
|
47
|
+
* How: Removes namespaced Redis cache key.
|
|
48
|
+
*/
|
|
49
|
+
async forget(key: string) {
|
|
50
|
+
const client = redisClientIfReady();
|
|
51
|
+
if (!client) return false;
|
|
52
|
+
|
|
53
|
+
await client.del(cacheKey(key));
|
|
54
|
+
return true;
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Why: Returns cached value or computes/stores a fresh one.
|
|
59
|
+
* When: A feature needs cache-aside behavior.
|
|
60
|
+
* Where: Read paths with potentially expensive callbacks.
|
|
61
|
+
* How: Attempts get first, then executes callback and put.
|
|
62
|
+
*/
|
|
63
|
+
async remember<T>(key: string, ttl: number, callback: () => Promise<T>) {
|
|
64
|
+
const cached = await cache.get<T>(key);
|
|
65
|
+
if (cached !== null) return cached;
|
|
66
|
+
|
|
67
|
+
const fresh = await callback();
|
|
68
|
+
await this.put(key, fresh, ttl);
|
|
69
|
+
return fresh;
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Why: Indicates whether Redis cache backend is currently usable.
|
|
74
|
+
* When: Runtime checks need to branch on cache availability.
|
|
75
|
+
* Where: Health/status endpoints and conditional flows.
|
|
76
|
+
* How: Confirms REDIS flag and ready Redis client instance.
|
|
77
|
+
*/
|
|
78
|
+
isAvailable() {
|
|
79
|
+
return redisConfig.enabled && redisClientIfReady() !== null;
|
|
80
|
+
}
|
|
81
|
+
};
|