@kabyeon/nexusjs 0.6.5
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/LICENSE +21 -0
- package/README.md +860 -0
- package/dist/auth/auth.controller.d.ts +175 -0
- package/dist/auth/auth.controller.d.ts.map +1 -0
- package/dist/auth/auth.d.ts +47 -0
- package/dist/auth/auth.d.ts.map +1 -0
- package/dist/auth/auth.module.d.ts +34 -0
- package/dist/auth/auth.module.d.ts.map +1 -0
- package/dist/auth/auth.service.d.ts +192 -0
- package/dist/auth/auth.service.d.ts.map +1 -0
- package/dist/auth/decorators/current-user.d.ts +58 -0
- package/dist/auth/decorators/current-user.d.ts.map +1 -0
- package/dist/auth/index.d.ts +43 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +730 -0
- package/dist/auth/index.js.map +25 -0
- package/dist/auth/middleware.d.ts +50 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/types.d.ts +135 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/cache/cache.module.d.ts +22 -0
- package/dist/cache/cache.module.d.ts.map +1 -0
- package/dist/cache/cache.service.d.ts +37 -0
- package/dist/cache/cache.service.d.ts.map +1 -0
- package/dist/cache/index.d.ts +9 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +814 -0
- package/dist/cache/index.js.map +25 -0
- package/dist/cache/stores/drizzle.d.ts +76 -0
- package/dist/cache/stores/drizzle.d.ts.map +1 -0
- package/dist/cache/stores/index.d.ts +10 -0
- package/dist/cache/stores/index.d.ts.map +1 -0
- package/dist/cache/stores/memory.d.ts +34 -0
- package/dist/cache/stores/memory.d.ts.map +1 -0
- package/dist/cache/stores/redis.d.ts +46 -0
- package/dist/cache/stores/redis.d.ts.map +1 -0
- package/dist/cache/types.d.ts +88 -0
- package/dist/cache/types.d.ts.map +1 -0
- package/dist/cli/commands/config.d.ts +44 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/db-generate.d.ts +20 -0
- package/dist/cli/commands/db-generate.d.ts.map +1 -0
- package/dist/cli/commands/db-migrate.d.ts +33 -0
- package/dist/cli/commands/db-migrate.d.ts.map +1 -0
- package/dist/cli/commands/db-seed.d.ts +43 -0
- package/dist/cli/commands/db-seed.d.ts.map +1 -0
- package/dist/cli/commands/index.d.ts +11 -0
- package/dist/cli/commands/index.d.ts.map +1 -0
- package/dist/cli/commands/info.d.ts +11 -0
- package/dist/cli/commands/info.d.ts.map +1 -0
- package/dist/cli/commands/init.d.ts +38 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/make-auth.d.ts +17 -0
- package/dist/cli/commands/make-auth.d.ts.map +1 -0
- package/dist/cli/commands/make-controller.d.ts +16 -0
- package/dist/cli/commands/make-controller.d.ts.map +1 -0
- package/dist/cli/commands/make-crud.d.ts +28 -0
- package/dist/cli/commands/make-crud.d.ts.map +1 -0
- package/dist/cli/commands/make-listener.d.ts +15 -0
- package/dist/cli/commands/make-listener.d.ts.map +1 -0
- package/dist/cli/commands/make-middleware.d.ts +7 -0
- package/dist/cli/commands/make-middleware.d.ts.map +1 -0
- package/dist/cli/commands/make-migration.d.ts +21 -0
- package/dist/cli/commands/make-migration.d.ts.map +1 -0
- package/dist/cli/commands/make-model.d.ts +22 -0
- package/dist/cli/commands/make-model.d.ts.map +1 -0
- package/dist/cli/commands/make-module.d.ts +11 -0
- package/dist/cli/commands/make-module.d.ts.map +1 -0
- package/dist/cli/commands/make-queue.d.ts +17 -0
- package/dist/cli/commands/make-queue.d.ts.map +1 -0
- package/dist/cli/commands/make-schedule.d.ts +17 -0
- package/dist/cli/commands/make-schedule.d.ts.map +1 -0
- package/dist/cli/commands/make-service.d.ts +7 -0
- package/dist/cli/commands/make-service.d.ts.map +1 -0
- package/dist/cli/commands/make-session.d.ts +15 -0
- package/dist/cli/commands/make-session.d.ts.map +1 -0
- package/dist/cli/commands/make-validator.d.ts +7 -0
- package/dist/cli/commands/make-validator.d.ts.map +1 -0
- package/dist/cli/commands/new.d.ts +14 -0
- package/dist/cli/commands/new.d.ts.map +1 -0
- package/dist/cli/commands/repl.d.ts +42 -0
- package/dist/cli/commands/repl.d.ts.map +1 -0
- package/dist/cli/commands/route-list.d.ts +12 -0
- package/dist/cli/commands/route-list.d.ts.map +1 -0
- package/dist/cli/core/args.d.ts +29 -0
- package/dist/cli/core/args.d.ts.map +1 -0
- package/dist/cli/core/config.d.ts +137 -0
- package/dist/cli/core/config.d.ts.map +1 -0
- package/dist/cli/core/fs.d.ts +38 -0
- package/dist/cli/core/fs.d.ts.map +1 -0
- package/dist/cli/core/index.d.ts +42 -0
- package/dist/cli/core/index.d.ts.map +1 -0
- package/dist/cli/core/logger.d.ts +46 -0
- package/dist/cli/core/logger.d.ts.map +1 -0
- package/dist/cli/core/loose-json.d.ts +26 -0
- package/dist/cli/core/loose-json.d.ts.map +1 -0
- package/dist/cli/core/prompts.d.ts +22 -0
- package/dist/cli/core/prompts.d.ts.map +1 -0
- package/dist/cli/core/template.d.ts +26 -0
- package/dist/cli/core/template.d.ts.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +6136 -0
- package/dist/cli/index.js.map +91 -0
- package/dist/cli/templates/controller/adonis.d.ts +10 -0
- package/dist/cli/templates/controller/adonis.d.ts.map +1 -0
- package/dist/cli/templates/controller/functional.d.ts +9 -0
- package/dist/cli/templates/controller/functional.d.ts.map +1 -0
- package/dist/cli/templates/controller/nest.d.ts +17 -0
- package/dist/cli/templates/controller/nest.d.ts.map +1 -0
- package/dist/cli/templates/crud/controller.d.ts +8 -0
- package/dist/cli/templates/crud/controller.d.ts.map +1 -0
- package/dist/cli/templates/crud/dto.d.ts +8 -0
- package/dist/cli/templates/crud/dto.d.ts.map +1 -0
- package/dist/cli/templates/crud/index.d.ts +33 -0
- package/dist/cli/templates/crud/index.d.ts.map +1 -0
- package/dist/cli/templates/crud/module.d.ts +6 -0
- package/dist/cli/templates/crud/module.d.ts.map +1 -0
- package/dist/cli/templates/crud/test.d.ts +10 -0
- package/dist/cli/templates/crud/test.d.ts.map +1 -0
- package/dist/cli/templates/index.d.ts +39 -0
- package/dist/cli/templates/index.d.ts.map +1 -0
- package/dist/cli/templates/middleware/middleware.d.ts +8 -0
- package/dist/cli/templates/middleware/middleware.d.ts.map +1 -0
- package/dist/cli/templates/migration/drizzle.d.ts +12 -0
- package/dist/cli/templates/migration/drizzle.d.ts.map +1 -0
- package/dist/cli/templates/migration/sql.d.ts +10 -0
- package/dist/cli/templates/migration/sql.d.ts.map +1 -0
- package/dist/cli/templates/model/drizzle-dialect.d.ts +29 -0
- package/dist/cli/templates/model/drizzle-dialect.d.ts.map +1 -0
- package/dist/cli/templates/model/drizzle.d.ts +14 -0
- package/dist/cli/templates/model/drizzle.d.ts.map +1 -0
- package/dist/cli/templates/model/kysely.d.ts +12 -0
- package/dist/cli/templates/model/kysely.d.ts.map +1 -0
- package/dist/cli/templates/model/prisma.d.ts +12 -0
- package/dist/cli/templates/model/prisma.d.ts.map +1 -0
- package/dist/cli/templates/module/module.d.ts +16 -0
- package/dist/cli/templates/module/module.d.ts.map +1 -0
- package/dist/cli/templates/project/drizzle.config.d.ts +12 -0
- package/dist/cli/templates/project/drizzle.config.d.ts.map +1 -0
- package/dist/cli/templates/project/nx.config.d.ts +7 -0
- package/dist/cli/templates/project/nx.config.d.ts.map +1 -0
- package/dist/cli/templates/repository/repository.d.ts +13 -0
- package/dist/cli/templates/repository/repository.d.ts.map +1 -0
- package/dist/cli/templates/service/service.d.ts +12 -0
- package/dist/cli/templates/service/service.d.ts.map +1 -0
- package/dist/cli/templates/validator/validator.d.ts +8 -0
- package/dist/cli/templates/validator/validator.d.ts.map +1 -0
- package/dist/config/config.module.d.ts +39 -0
- package/dist/config/config.module.d.ts.map +1 -0
- package/dist/config/config.service.d.ts +47 -0
- package/dist/config/config.service.d.ts.map +1 -0
- package/dist/config/index.d.ts +39 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +436 -0
- package/dist/config/index.js.map +21 -0
- package/dist/config/types.d.ts +78 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/core/application.d.ts +77 -0
- package/dist/core/application.d.ts.map +1 -0
- package/dist/core/constants.d.ts +48 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/decorators/controller.d.ts +21 -0
- package/dist/core/decorators/controller.d.ts.map +1 -0
- package/dist/core/decorators/http-methods.d.ts +33 -0
- package/dist/core/decorators/http-methods.d.ts.map +1 -0
- package/dist/core/decorators/index.d.ts +12 -0
- package/dist/core/decorators/index.d.ts.map +1 -0
- package/dist/core/decorators/injectable.d.ts +42 -0
- package/dist/core/decorators/injectable.d.ts.map +1 -0
- package/dist/core/decorators/metadata.d.ts +7 -0
- package/dist/core/decorators/metadata.d.ts.map +1 -0
- package/dist/core/decorators/module.d.ts +23 -0
- package/dist/core/decorators/module.d.ts.map +1 -0
- package/dist/core/decorators/params.d.ts +33 -0
- package/dist/core/decorators/params.d.ts.map +1 -0
- package/dist/core/decorators/repository.d.ts +24 -0
- package/dist/core/decorators/repository.d.ts.map +1 -0
- package/dist/core/decorators/validate.d.ts +21 -0
- package/dist/core/decorators/validate.d.ts.map +1 -0
- package/dist/core/di/container.d.ts +70 -0
- package/dist/core/di/container.d.ts.map +1 -0
- package/dist/core/di/index.d.ts +9 -0
- package/dist/core/di/index.d.ts.map +1 -0
- package/dist/core/di/request-middleware.d.ts +36 -0
- package/dist/core/di/request-middleware.d.ts.map +1 -0
- package/dist/core/di/request-scope.d.ts +45 -0
- package/dist/core/di/request-scope.d.ts.map +1 -0
- package/dist/core/di/scanner.d.ts +36 -0
- package/dist/core/di/scanner.d.ts.map +1 -0
- package/dist/core/di/tokens.d.ts +98 -0
- package/dist/core/di/tokens.d.ts.map +1 -0
- package/dist/core/http/context.d.ts +30 -0
- package/dist/core/http/context.d.ts.map +1 -0
- package/dist/core/http/index.d.ts +8 -0
- package/dist/core/http/index.d.ts.map +1 -0
- package/dist/core/http/middleware.d.ts +31 -0
- package/dist/core/http/middleware.d.ts.map +1 -0
- package/dist/core/http/router.d.ts +46 -0
- package/dist/core/http/router.d.ts.map +1 -0
- package/dist/core/http/server.d.ts +58 -0
- package/dist/core/http/server.d.ts.map +1 -0
- package/dist/core/index.d.ts +20 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/orm/drizzle-adapter.d.ts +73 -0
- package/dist/core/orm/drizzle-adapter.d.ts.map +1 -0
- package/dist/core/orm/index.d.ts +5 -0
- package/dist/core/orm/index.d.ts.map +1 -0
- package/dist/core/runtime/bun.d.ts +13 -0
- package/dist/core/runtime/bun.d.ts.map +1 -0
- package/dist/core/runtime/cloudflare.d.ts +18 -0
- package/dist/core/runtime/cloudflare.d.ts.map +1 -0
- package/dist/core/runtime/index.d.ts +11 -0
- package/dist/core/runtime/index.d.ts.map +1 -0
- package/dist/core/runtime/node.d.ts +10 -0
- package/dist/core/runtime/node.d.ts.map +1 -0
- package/dist/core/validation/index.d.ts +5 -0
- package/dist/core/validation/index.d.ts.map +1 -0
- package/dist/core/validation/validator.d.ts +46 -0
- package/dist/core/validation/validator.d.ts.map +1 -0
- package/dist/crypto/encryption.d.ts +71 -0
- package/dist/crypto/encryption.d.ts.map +1 -0
- package/dist/crypto/hash.d.ts +52 -0
- package/dist/crypto/hash.d.ts.map +1 -0
- package/dist/crypto/index.d.ts +49 -0
- package/dist/crypto/index.d.ts.map +1 -0
- package/dist/crypto/index.js +533 -0
- package/dist/crypto/index.js.map +14 -0
- package/dist/crypto/module.d.ts +28 -0
- package/dist/crypto/module.d.ts.map +1 -0
- package/dist/crypto/types.d.ts +81 -0
- package/dist/crypto/types.d.ts.map +1 -0
- package/dist/drive/drive.module.d.ts +20 -0
- package/dist/drive/drive.module.d.ts.map +1 -0
- package/dist/drive/drive.service.d.ts +21 -0
- package/dist/drive/drive.service.d.ts.map +1 -0
- package/dist/drive/drivers/index.d.ts +9 -0
- package/dist/drive/drivers/index.d.ts.map +1 -0
- package/dist/drive/drivers/local.d.ts +24 -0
- package/dist/drive/drivers/local.d.ts.map +1 -0
- package/dist/drive/drivers/memory.d.ts +19 -0
- package/dist/drive/drivers/memory.d.ts.map +1 -0
- package/dist/drive/drivers/s3.d.ts +44 -0
- package/dist/drive/drivers/s3.d.ts.map +1 -0
- package/dist/drive/index.d.ts +9 -0
- package/dist/drive/index.d.ts.map +1 -0
- package/dist/drive/index.js +714 -0
- package/dist/drive/index.js.map +25 -0
- package/dist/drive/types.d.ts +97 -0
- package/dist/drive/types.d.ts.map +1 -0
- package/dist/drizzle/decorators/columns.d.ts +16 -0
- package/dist/drizzle/decorators/columns.d.ts.map +1 -0
- package/dist/drizzle/decorators/index.d.ts +6 -0
- package/dist/drizzle/decorators/index.d.ts.map +1 -0
- package/dist/drizzle/drivers/base.d.ts +32 -0
- package/dist/drizzle/drivers/base.d.ts.map +1 -0
- package/dist/drizzle/drivers/bun-sqlite.d.ts +6 -0
- package/dist/drizzle/drivers/bun-sqlite.d.ts.map +1 -0
- package/dist/drizzle/drivers/d1.d.ts +7 -0
- package/dist/drizzle/drivers/d1.d.ts.map +1 -0
- package/dist/drizzle/drivers/index.d.ts +14 -0
- package/dist/drizzle/drivers/index.d.ts.map +1 -0
- package/dist/drizzle/drivers/mysql.d.ts +6 -0
- package/dist/drizzle/drivers/mysql.d.ts.map +1 -0
- package/dist/drizzle/drivers/postgres.d.ts +12 -0
- package/dist/drizzle/drivers/postgres.d.ts.map +1 -0
- package/dist/drizzle/drivers/sqlite.d.ts +8 -0
- package/dist/drizzle/drivers/sqlite.d.ts.map +1 -0
- package/dist/drizzle/drizzle.module.d.ts +29 -0
- package/dist/drizzle/drizzle.module.d.ts.map +1 -0
- package/dist/drizzle/drizzle.service.d.ts +52 -0
- package/dist/drizzle/drizzle.service.d.ts.map +1 -0
- package/dist/drizzle/index.d.ts +13 -0
- package/dist/drizzle/index.d.ts.map +1 -0
- package/dist/drizzle/index.js +979 -0
- package/dist/drizzle/index.js.map +32 -0
- package/dist/drizzle/model.d.ts +26 -0
- package/dist/drizzle/model.d.ts.map +1 -0
- package/dist/drizzle/raw-query.d.ts +41 -0
- package/dist/drizzle/raw-query.d.ts.map +1 -0
- package/dist/drizzle/repository/index.d.ts +6 -0
- package/dist/drizzle/repository/index.d.ts.map +1 -0
- package/dist/drizzle/repository/repository.d.ts +60 -0
- package/dist/drizzle/repository/repository.d.ts.map +1 -0
- package/dist/drizzle/types.d.ts +160 -0
- package/dist/drizzle/types.d.ts.map +1 -0
- package/dist/events/decorators/on-event.d.ts +49 -0
- package/dist/events/decorators/on-event.d.ts.map +1 -0
- package/dist/events/emitter.d.ts +52 -0
- package/dist/events/emitter.d.ts.map +1 -0
- package/dist/events/event.service.d.ts +27 -0
- package/dist/events/event.service.d.ts.map +1 -0
- package/dist/events/events.module.d.ts +35 -0
- package/dist/events/events.module.d.ts.map +1 -0
- package/dist/events/index.d.ts +43 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +646 -0
- package/dist/events/index.js.map +23 -0
- package/dist/events/types.d.ts +120 -0
- package/dist/events/types.d.ts.map +1 -0
- package/dist/grpc/decorators.d.ts +34 -0
- package/dist/grpc/decorators.d.ts.map +1 -0
- package/dist/grpc/index.d.ts +70 -0
- package/dist/grpc/index.d.ts.map +1 -0
- package/dist/grpc/index.js +528 -0
- package/dist/grpc/index.js.map +22 -0
- package/dist/grpc/module.d.ts +32 -0
- package/dist/grpc/module.d.ts.map +1 -0
- package/dist/grpc/service.d.ts +60 -0
- package/dist/grpc/service.d.ts.map +1 -0
- package/dist/grpc/types.d.ts +79 -0
- package/dist/grpc/types.d.ts.map +1 -0
- package/dist/health/health.controller.d.ts +61 -0
- package/dist/health/health.controller.d.ts.map +1 -0
- package/dist/health/health.module.d.ts +29 -0
- package/dist/health/health.module.d.ts.map +1 -0
- package/dist/health/health.service.d.ts +34 -0
- package/dist/health/health.service.d.ts.map +1 -0
- package/dist/health/index.d.ts +38 -0
- package/dist/health/index.d.ts.map +1 -0
- package/dist/health/index.js +599 -0
- package/dist/health/index.js.map +25 -0
- package/dist/health/indicators/drizzle.d.ts +18 -0
- package/dist/health/indicators/drizzle.d.ts.map +1 -0
- package/dist/health/indicators/index.d.ts +59 -0
- package/dist/health/indicators/index.d.ts.map +1 -0
- package/dist/health/types.d.ts +105 -0
- package/dist/health/types.d.ts.map +1 -0
- package/dist/i18n/decorators.d.ts +14 -0
- package/dist/i18n/decorators.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +48 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +589 -0
- package/dist/i18n/index.js.map +17 -0
- package/dist/i18n/middleware.d.ts +26 -0
- package/dist/i18n/middleware.d.ts.map +1 -0
- package/dist/i18n/module.d.ts +39 -0
- package/dist/i18n/module.d.ts.map +1 -0
- package/dist/i18n/service.d.ts +130 -0
- package/dist/i18n/service.d.ts.map +1 -0
- package/dist/i18n/types.d.ts +65 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2056 -0
- package/dist/index.js.map +53 -0
- package/dist/limiter/backends/drizzle.d.ts +40 -0
- package/dist/limiter/backends/drizzle.d.ts.map +1 -0
- package/dist/limiter/backends/index.d.ts +6 -0
- package/dist/limiter/backends/index.d.ts.map +1 -0
- package/dist/limiter/backends/memory.d.ts +28 -0
- package/dist/limiter/backends/memory.d.ts.map +1 -0
- package/dist/limiter/index.d.ts +9 -0
- package/dist/limiter/index.d.ts.map +1 -0
- package/dist/limiter/index.js +640 -0
- package/dist/limiter/index.js.map +25 -0
- package/dist/limiter/limiter.middleware.d.ts +11 -0
- package/dist/limiter/limiter.middleware.d.ts.map +1 -0
- package/dist/limiter/limiter.module.d.ts +23 -0
- package/dist/limiter/limiter.module.d.ts.map +1 -0
- package/dist/limiter/limiter.service.d.ts +18 -0
- package/dist/limiter/limiter.service.d.ts.map +1 -0
- package/dist/limiter/types.d.ts +99 -0
- package/dist/limiter/types.d.ts.map +1 -0
- package/dist/logger/index.d.ts +36 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +538 -0
- package/dist/logger/index.js.map +22 -0
- package/dist/logger/logger.module.d.ts +35 -0
- package/dist/logger/logger.module.d.ts.map +1 -0
- package/dist/logger/logger.service.d.ts +55 -0
- package/dist/logger/logger.service.d.ts.map +1 -0
- package/dist/logger/transports/index.d.ts +35 -0
- package/dist/logger/transports/index.d.ts.map +1 -0
- package/dist/logger/types.d.ts +58 -0
- package/dist/logger/types.d.ts.map +1 -0
- package/dist/mail/index.d.ts +9 -0
- package/dist/mail/index.d.ts.map +1 -0
- package/dist/mail/index.js +479 -0
- package/dist/mail/index.js.map +25 -0
- package/dist/mail/mail.module.d.ts +21 -0
- package/dist/mail/mail.module.d.ts.map +1 -0
- package/dist/mail/mail.service.d.ts +18 -0
- package/dist/mail/mail.service.d.ts.map +1 -0
- package/dist/mail/transports/file.d.ts +19 -0
- package/dist/mail/transports/file.d.ts.map +1 -0
- package/dist/mail/transports/index.d.ts +9 -0
- package/dist/mail/transports/index.d.ts.map +1 -0
- package/dist/mail/transports/null.d.ts +11 -0
- package/dist/mail/transports/null.d.ts.map +1 -0
- package/dist/mail/transports/smtp.d.ts +40 -0
- package/dist/mail/transports/smtp.d.ts.map +1 -0
- package/dist/mail/types.d.ts +73 -0
- package/dist/mail/types.d.ts.map +1 -0
- package/dist/metrics/controller.d.ts +27 -0
- package/dist/metrics/controller.d.ts.map +1 -0
- package/dist/metrics/counter.d.ts +36 -0
- package/dist/metrics/counter.d.ts.map +1 -0
- package/dist/metrics/decorators/counted.d.ts +26 -0
- package/dist/metrics/decorators/counted.d.ts.map +1 -0
- package/dist/metrics/decorators/index.d.ts +3 -0
- package/dist/metrics/decorators/index.d.ts.map +1 -0
- package/dist/metrics/decorators/timed.d.ts +25 -0
- package/dist/metrics/decorators/timed.d.ts.map +1 -0
- package/dist/metrics/gauge.d.ts +38 -0
- package/dist/metrics/gauge.d.ts.map +1 -0
- package/dist/metrics/histogram.d.ts +52 -0
- package/dist/metrics/histogram.d.ts.map +1 -0
- package/dist/metrics/index.d.ts +35 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +1033 -0
- package/dist/metrics/index.js.map +21 -0
- package/dist/metrics/module.d.ts +33 -0
- package/dist/metrics/module.d.ts.map +1 -0
- package/dist/metrics/registry.d.ts +52 -0
- package/dist/metrics/registry.d.ts.map +1 -0
- package/dist/metrics/service.d.ts +42 -0
- package/dist/metrics/service.d.ts.map +1 -0
- package/dist/metrics/summary.d.ts +50 -0
- package/dist/metrics/summary.d.ts.map +1 -0
- package/dist/metrics/types.d.ts +115 -0
- package/dist/metrics/types.d.ts.map +1 -0
- package/dist/openapi/decorators/body.d.ts +9 -0
- package/dist/openapi/decorators/body.d.ts.map +1 -0
- package/dist/openapi/decorators/index.d.ts +11 -0
- package/dist/openapi/decorators/index.d.ts.map +1 -0
- package/dist/openapi/decorators/operation.d.ts +9 -0
- package/dist/openapi/decorators/operation.d.ts.map +1 -0
- package/dist/openapi/decorators/param.d.ts +17 -0
- package/dist/openapi/decorators/param.d.ts.map +1 -0
- package/dist/openapi/decorators/property.d.ts +24 -0
- package/dist/openapi/decorators/property.d.ts.map +1 -0
- package/dist/openapi/decorators/response.d.ts +10 -0
- package/dist/openapi/decorators/response.d.ts.map +1 -0
- package/dist/openapi/decorators/security.d.ts +9 -0
- package/dist/openapi/decorators/security.d.ts.map +1 -0
- package/dist/openapi/decorators/tags.d.ts +2 -0
- package/dist/openapi/decorators/tags.d.ts.map +1 -0
- package/dist/openapi/index.d.ts +10 -0
- package/dist/openapi/index.d.ts.map +1 -0
- package/dist/openapi/index.js +974 -0
- package/dist/openapi/index.js.map +31 -0
- package/dist/openapi/openapi.module.d.ts +46 -0
- package/dist/openapi/openapi.module.d.ts.map +1 -0
- package/dist/openapi/openapi.service.d.ts +55 -0
- package/dist/openapi/openapi.service.d.ts.map +1 -0
- package/dist/openapi/scalar.d.ts +16 -0
- package/dist/openapi/scalar.d.ts.map +1 -0
- package/dist/openapi/types.d.ts +266 -0
- package/dist/openapi/types.d.ts.map +1 -0
- package/dist/openapi/zod-to-json-schema.d.ts +34 -0
- package/dist/openapi/zod-to-json-schema.d.ts.map +1 -0
- package/dist/package.json +59 -0
- package/dist/queue/backends/bullmq.d.ts +41 -0
- package/dist/queue/backends/bullmq.d.ts.map +1 -0
- package/dist/queue/backends/cloudflare.d.ts +84 -0
- package/dist/queue/backends/cloudflare.d.ts.map +1 -0
- package/dist/queue/backends/index.d.ts +7 -0
- package/dist/queue/backends/index.d.ts.map +1 -0
- package/dist/queue/backends/memory.d.ts +24 -0
- package/dist/queue/backends/memory.d.ts.map +1 -0
- package/dist/queue/decorators/on-queue-ready.d.ts +43 -0
- package/dist/queue/decorators/on-queue-ready.d.ts.map +1 -0
- package/dist/queue/index.d.ts +57 -0
- package/dist/queue/index.d.ts.map +1 -0
- package/dist/queue/index.js +961 -0
- package/dist/queue/index.js.map +25 -0
- package/dist/queue/queue.module.d.ts +46 -0
- package/dist/queue/queue.module.d.ts.map +1 -0
- package/dist/queue/queue.service.d.ts +61 -0
- package/dist/queue/queue.service.d.ts.map +1 -0
- package/dist/queue/types.d.ts +204 -0
- package/dist/queue/types.d.ts.map +1 -0
- package/dist/redis/adapters/bun.d.ts +27 -0
- package/dist/redis/adapters/bun.d.ts.map +1 -0
- package/dist/redis/adapters/cloudflare.d.ts +51 -0
- package/dist/redis/adapters/cloudflare.d.ts.map +1 -0
- package/dist/redis/adapters/index.d.ts +29 -0
- package/dist/redis/adapters/index.d.ts.map +1 -0
- package/dist/redis/adapters/memory.d.ts +28 -0
- package/dist/redis/adapters/memory.d.ts.map +1 -0
- package/dist/redis/adapters/node.d.ts +36 -0
- package/dist/redis/adapters/node.d.ts.map +1 -0
- package/dist/redis/index.d.ts +33 -0
- package/dist/redis/index.d.ts.map +1 -0
- package/dist/redis/index.js +667 -0
- package/dist/redis/index.js.map +25 -0
- package/dist/redis/module.d.ts +32 -0
- package/dist/redis/module.d.ts.map +1 -0
- package/dist/redis/types.d.ts +146 -0
- package/dist/redis/types.d.ts.map +1 -0
- package/dist/schedule/backends/cloudflare.d.ts +55 -0
- package/dist/schedule/backends/cloudflare.d.ts.map +1 -0
- package/dist/schedule/backends/index.d.ts +3 -0
- package/dist/schedule/backends/index.d.ts.map +1 -0
- package/dist/schedule/backends/memory.d.ts +39 -0
- package/dist/schedule/backends/memory.d.ts.map +1 -0
- package/dist/schedule/cron-parser.d.ts +48 -0
- package/dist/schedule/cron-parser.d.ts.map +1 -0
- package/dist/schedule/decorators/cron.d.ts +71 -0
- package/dist/schedule/decorators/cron.d.ts.map +1 -0
- package/dist/schedule/index.d.ts +51 -0
- package/dist/schedule/index.d.ts.map +1 -0
- package/dist/schedule/index.js +1108 -0
- package/dist/schedule/index.js.map +25 -0
- package/dist/schedule/schedule.module.d.ts +44 -0
- package/dist/schedule/schedule.module.d.ts.map +1 -0
- package/dist/schedule/schedule.service.d.ts +51 -0
- package/dist/schedule/schedule.service.d.ts.map +1 -0
- package/dist/schedule/types.d.ts +150 -0
- package/dist/schedule/types.d.ts.map +1 -0
- package/dist/session/backends/cookie.d.ts +56 -0
- package/dist/session/backends/cookie.d.ts.map +1 -0
- package/dist/session/backends/drizzle.d.ts +65 -0
- package/dist/session/backends/drizzle.d.ts.map +1 -0
- package/dist/session/backends/index.d.ts +6 -0
- package/dist/session/backends/index.d.ts.map +1 -0
- package/dist/session/backends/memory.d.ts +32 -0
- package/dist/session/backends/memory.d.ts.map +1 -0
- package/dist/session/backends/redis.d.ts +53 -0
- package/dist/session/backends/redis.d.ts.map +1 -0
- package/dist/session/decorators/current-session.d.ts +56 -0
- package/dist/session/decorators/current-session.d.ts.map +1 -0
- package/dist/session/index.d.ts +42 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +1498 -0
- package/dist/session/index.js.map +28 -0
- package/dist/session/session-middleware.d.ts +29 -0
- package/dist/session/session-middleware.d.ts.map +1 -0
- package/dist/session/session.module.d.ts +35 -0
- package/dist/session/session.module.d.ts.map +1 -0
- package/dist/session/session.service.d.ts +49 -0
- package/dist/session/session.service.d.ts.map +1 -0
- package/dist/session/types.d.ts +201 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/shield/guards/csrf.d.ts +33 -0
- package/dist/shield/guards/csrf.d.ts.map +1 -0
- package/dist/shield/guards/headers.d.ts +22 -0
- package/dist/shield/guards/headers.d.ts.map +1 -0
- package/dist/shield/guards/index.d.ts +6 -0
- package/dist/shield/guards/index.d.ts.map +1 -0
- package/dist/shield/index.d.ts +8 -0
- package/dist/shield/index.d.ts.map +1 -0
- package/dist/shield/index.js +728 -0
- package/dist/shield/index.js.map +25 -0
- package/dist/shield/shield.module.d.ts +25 -0
- package/dist/shield/shield.module.d.ts.map +1 -0
- package/dist/shield/shield.service.d.ts +21 -0
- package/dist/shield/shield.service.d.ts.map +1 -0
- package/dist/shield/types.d.ts +95 -0
- package/dist/shield/types.d.ts.map +1 -0
- package/dist/sse/index.d.ts +7 -0
- package/dist/sse/index.d.ts.map +1 -0
- package/dist/sse/index.js +214 -0
- package/dist/sse/index.js.map +13 -0
- package/dist/sse/sse-stream.d.ts +46 -0
- package/dist/sse/sse-stream.d.ts.map +1 -0
- package/dist/sse/sse.d.ts +24 -0
- package/dist/sse/sse.d.ts.map +1 -0
- package/dist/sse/types.d.ts +84 -0
- package/dist/sse/types.d.ts.map +1 -0
- package/dist/static/index.d.ts +41 -0
- package/dist/static/index.d.ts.map +1 -0
- package/dist/static/index.js +313 -0
- package/dist/static/index.js.map +13 -0
- package/dist/static/static.module.d.ts +41 -0
- package/dist/static/static.module.d.ts.map +1 -0
- package/dist/static/static.service.d.ts +38 -0
- package/dist/static/static.service.d.ts.map +1 -0
- package/dist/tracing/decorators/index.d.ts +2 -0
- package/dist/tracing/decorators/index.d.ts.map +1 -0
- package/dist/tracing/decorators/trace.d.ts +37 -0
- package/dist/tracing/decorators/trace.d.ts.map +1 -0
- package/dist/tracing/hono-instrumentation.d.ts +21 -0
- package/dist/tracing/hono-instrumentation.d.ts.map +1 -0
- package/dist/tracing/index.d.ts +29 -0
- package/dist/tracing/index.d.ts.map +1 -0
- package/dist/tracing/index.js +782 -0
- package/dist/tracing/index.js.map +24 -0
- package/dist/tracing/module.d.ts +45 -0
- package/dist/tracing/module.d.ts.map +1 -0
- package/dist/tracing/propagation.d.ts +53 -0
- package/dist/tracing/propagation.d.ts.map +1 -0
- package/dist/tracing/service.d.ts +95 -0
- package/dist/tracing/service.d.ts.map +1 -0
- package/dist/tracing/types.d.ts +90 -0
- package/dist/tracing/types.d.ts.map +1 -0
- package/dist/upload/decorators/index.d.ts +6 -0
- package/dist/upload/decorators/index.d.ts.map +1 -0
- package/dist/upload/decorators/upload.d.ts +16 -0
- package/dist/upload/decorators/upload.d.ts.map +1 -0
- package/dist/upload/decorators/uploaded-file.d.ts +10 -0
- package/dist/upload/decorators/uploaded-file.d.ts.map +1 -0
- package/dist/upload/index.d.ts +9 -0
- package/dist/upload/index.d.ts.map +1 -0
- package/dist/upload/index.js +553 -0
- package/dist/upload/index.js.map +25 -0
- package/dist/upload/types.d.ts +103 -0
- package/dist/upload/types.d.ts.map +1 -0
- package/dist/upload/upload.middleware.d.ts +15 -0
- package/dist/upload/upload.middleware.d.ts.map +1 -0
- package/dist/upload/upload.module.d.ts +33 -0
- package/dist/upload/upload.module.d.ts.map +1 -0
- package/dist/upload/upload.service.d.ts +29 -0
- package/dist/upload/upload.service.d.ts.map +1 -0
- package/dist/view/edge.d.ts +23 -0
- package/dist/view/edge.d.ts.map +1 -0
- package/dist/view/eta.d.ts +30 -0
- package/dist/view/eta.d.ts.map +1 -0
- package/dist/view/index.d.ts +34 -0
- package/dist/view/index.d.ts.map +1 -0
- package/dist/view/index.js +240 -0
- package/dist/view/index.js.map +14 -0
- package/dist/view/inertia/default-ssr.d.ts +15 -0
- package/dist/view/inertia/default-ssr.d.ts.map +1 -0
- package/dist/view/inertia/form-helper.d.ts +102 -0
- package/dist/view/inertia/form-helper.d.ts.map +1 -0
- package/dist/view/inertia/form-middleware.d.ts +53 -0
- package/dist/view/inertia/form-middleware.d.ts.map +1 -0
- package/dist/view/inertia/helpers.d.ts +149 -0
- package/dist/view/inertia/helpers.d.ts.map +1 -0
- package/dist/view/inertia/index.d.ts +18 -0
- package/dist/view/inertia/index.d.ts.map +1 -0
- package/dist/view/inertia/inertia-adapter.d.ts +93 -0
- package/dist/view/inertia/inertia-adapter.d.ts.map +1 -0
- package/dist/view/inertia/inertia-response.d.ts +51 -0
- package/dist/view/inertia/inertia-response.d.ts.map +1 -0
- package/dist/view/inertia/ssr/index.d.ts +13 -0
- package/dist/view/inertia/ssr/index.d.ts.map +1 -0
- package/dist/view/inertia/ssr/react-adapter.d.ts +33 -0
- package/dist/view/inertia/ssr/react-adapter.d.ts.map +1 -0
- package/dist/view/inertia/ssr/registry.d.ts +42 -0
- package/dist/view/inertia/ssr/registry.d.ts.map +1 -0
- package/dist/view/inertia/ssr/solid-adapter.d.ts +31 -0
- package/dist/view/inertia/ssr/solid-adapter.d.ts.map +1 -0
- package/dist/view/inertia/ssr/svelte-adapter.d.ts +31 -0
- package/dist/view/inertia/ssr/svelte-adapter.d.ts.map +1 -0
- package/dist/view/inertia/ssr/vue-adapter.d.ts +26 -0
- package/dist/view/inertia/ssr/vue-adapter.d.ts.map +1 -0
- package/dist/view/inertia/types.d.ts +131 -0
- package/dist/view/inertia/types.d.ts.map +1 -0
- package/dist/view/rendu.d.ts +11 -0
- package/dist/view/rendu.d.ts.map +1 -0
- package/dist/view/types.d.ts +52 -0
- package/dist/view/types.d.ts.map +1 -0
- package/dist/view/view-engine.d.ts +28 -0
- package/dist/view/view-engine.d.ts.map +1 -0
- package/dist/ws/client.d.ts +42 -0
- package/dist/ws/client.d.ts.map +1 -0
- package/dist/ws/decorators.d.ts +44 -0
- package/dist/ws/decorators.d.ts.map +1 -0
- package/dist/ws/index.d.ts +57 -0
- package/dist/ws/index.d.ts.map +1 -0
- package/dist/ws/index.js +796 -0
- package/dist/ws/index.js.map +26 -0
- package/dist/ws/module.d.ts +48 -0
- package/dist/ws/module.d.ts.map +1 -0
- package/dist/ws/runtime/bun.d.ts +41 -0
- package/dist/ws/runtime/bun.d.ts.map +1 -0
- package/dist/ws/runtime/index.d.ts +14 -0
- package/dist/ws/runtime/index.d.ts.map +1 -0
- package/dist/ws/runtime/node.d.ts +46 -0
- package/dist/ws/runtime/node.d.ts.map +1 -0
- package/dist/ws/runtime/types.d.ts +18 -0
- package/dist/ws/runtime/types.d.ts.map +1 -0
- package/dist/ws/service.d.ts +65 -0
- package/dist/ws/service.d.ts.map +1 -0
- package/dist/ws/types.d.ts +77 -0
- package/dist/ws/types.d.ts.map +1 -0
- package/package.json +262 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/view/rendu.ts", "../src/view/edge.ts", "../src/view/eta.ts", "../src/view/view-engine.ts", "../src/core/constants.ts", "../src/core/decorators/controller.ts", "../src/core/decorators/http-methods.ts", "../src/core/decorators/params.ts", "../src/core/decorators/validate.ts", "../src/core/di/request-scope.ts", "../src/core/di/container.ts", "../src/core/di/scanner.ts", "../src/core/di/request-middleware.ts", "../src/core/http/middleware.ts", "../src/core/validation/validator.ts", "../src/core/http/router.ts", "../src/core/runtime/bun.ts", "../src/core/runtime/node.ts", "../src/core/runtime/cloudflare.ts", "../src/core/http/server.ts", "../src/view/inertia/helpers.ts", "../src/view/inertia/default-ssr.ts", "../src/view/inertia/inertia-response.ts", "../src/view/inertia/form-helper.ts", "../src/view/inertia/form-middleware.ts", "../src/view/inertia/inertia-adapter.ts", "../src/view/inertia/ssr/registry.ts", "../src/view/inertia/ssr/index.ts", "../src/view/inertia/index.ts", "../src/core/application.ts", "../src/view/index.ts", "../src/index.ts", "../src/core/decorators/module.ts", "../src/core/decorators/index.ts", "../src/core/decorators/injectable.ts", "../src/core/decorators/repository.ts", "../src/core/decorators/metadata.ts", "../src/core/di/index.ts", "../src/core/http/context.ts", "../src/core/http/index.ts", "../src/core/validation/index.ts", "../src/core/orm/drizzle-adapter.ts", "../src/core/runtime/index.ts", "../src/core/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Rendu template engine adapter.\n *\n * Rendu is a PHP-style templating library that compiles templates into\n * render functions, which makes it fast and edge-friendly (no eval, no\n * file-system access at render time). It is the default adapter because\n * it works on every runtime the framework supports.\n *\n * See: https://github.com/h3js/rendu\n */\nimport { compileTemplate } from \"rendu\";\nimport type { ViewAdapter, ViewContext, ViewOptions } from \"./types.js\";\n\nexport class RenduAdapter implements ViewAdapter {\n\treadonly name = \"rendu\";\n\tprivate cache = new Map<string, ReturnType<typeof compileTemplate>>();\n\n\trender(\n\t\ttemplate: string,\n\t\tdata: Record<string, any>,\n\t\tcontext?: ViewContext,\n\t\toptions?: ViewOptions,\n\t): Promise<string> {\n\t\t// Workaround for a Rendu 0.1.0 bug: its generated runtime\n\t\t// does `typeof chunk === \"string\" ? chunk : new TextDecoder()\n\t\t// .decode(chunk)`, so any non-string chunk (a number from\n\t\t// `<?= year ?>`, a boolean, etc.) throws. We shallow-coerce\n\t\t// top-level values to strings here. The framework's contract\n\t\t// is that view templates render output — arithmetic in\n\t\t// templates is rare and users who need it can wrap with\n\t\t// `Number(...)` explicitly.\n\t\tconst safe: Record<string, any> = {};\n\t\tfor (const [k, v] of Object.entries(data)) {\n\t\t\tsafe[k] = typeof v === \"string\" ? v : v == null ? \"\" : String(v);\n\t\t}\n\t\tconst merged = this.mergeData(safe, context, options);\n\t\treturn this.getCompiled(template, options)(merged);\n\t}\n\n\tcompile(template: string, options?: ViewOptions) {\n\t\tconst compiled = this.getCompiled(template, options);\n\t\treturn (data: Record<string, any>) => compiled(data);\n\t}\n\n\tprivate getCompiled(template: string, options?: ViewOptions) {\n\t\tconst cacheKey = options ? `${options.stream ? \"s\" : \"\"}` : \"\";\n\t\tlet compiled = this.cache.get(cacheKey);\n\t\tif (!compiled) {\n\t\t\tcompiled = compileTemplate(template, {\n\t\t\t\tstream: options?.stream ?? false,\n\t\t\t});\n\t\t\tthis.cache.set(cacheKey, compiled);\n\t\t}\n\t\treturn compiled;\n\t}\n\n\t/** Merge user data with view context globals. */\n\tprivate mergeData(\n\t\tdata: Record<string, any>,\n\t\tcontext?: ViewContext,\n\t\toptions?: ViewOptions,\n\t): Record<string, any> {\n\t\tconst merged: Record<string, any> = { ...data };\n\t\tif (context) {\n\t\t\tif (context.request) merged.$REQUEST = context.request;\n\t\t\tif (context.response) merged.$RESPONSE = context.response;\n\t\t\tif (context.globals) Object.assign(merged, context.globals);\n\t\t}\n\t\tif (options?.layout) merged.$LAYOUT = options.layout;\n\t\treturn merged;\n\t}\n}\n",
|
|
6
|
+
"/**\n * Edge-style template engine adapter (Adonis-style).\n *\n * Edge is the templating engine built for AdonisJS with a mustache-like\n * syntax (`{{ }}`, `@if`, `@each`). It is bundled here as a placeholder\n * for users who prefer that style.\n *\n * The adapter does not bundle Edge directly — it expects the user to\n * provide an `Edge` instance via the constructor so the dependency\n * stays optional.\n */\nimport type { ViewAdapter, ViewContext, ViewOptions } from \"./types.js\";\n\nexport interface EdgeLike {\n\trenderRaw?: (template: string, data: Record<string, any>) => Promise<string>;\n\trenderString?: (\n\t\ttemplate: string,\n\t\tdata: Record<string, any>,\n\t) => Promise<string>;\n}\n\nexport class EdgeAdapter implements ViewAdapter {\n\treadonly name = \"edge\";\n\tconstructor(private edge?: EdgeLike) {}\n\n\tasync render(\n\t\ttemplate: string,\n\t\tdata: Record<string, any>,\n\t\tcontext?: ViewContext,\n\t\toptions?: ViewOptions,\n\t): Promise<string> {\n\t\tif (!this.edge) {\n\t\t\tthrow new Error(\n\t\t\t\t\"EdgeAdapter requires an Edge instance. \" +\n\t\t\t\t\t\"Install `edge.js` and pass it to `new EdgeAdapter(edge)`, \" +\n\t\t\t\t\t\"or use the default RenduAdapter instead.\",\n\t\t\t);\n\t\t}\n\t\tconst fn = this.edge.renderRaw ?? this.edge.renderString;\n\t\tif (!fn) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Provided Edge instance does not implement renderRaw/renderString.\",\n\t\t\t);\n\t\t}\n\t\treturn fn.call(this.edge, template, { ...data, $OPTIONS: options });\n\t}\n}\n",
|
|
7
|
+
"/**\n * Eta template engine adapter.\n *\n * Eta is a lightweight, high-performance templating engine with\n * EJS-like syntax (`<%= expr %>`, `<% code %>`). It works on every\n * runtime (Bun, Node, Deno, Cloudflare Workers) because templates\n * are compiled to JavaScript render functions — no eval, no\n * filesystem access at render time.\n *\n * Install (optional peer dep): `bun add eta`\n *\n * import { EtaAdapter } from \"nexusjs/view\";\n * const eta = new EtaAdapter();\n * const html = await eta.render(\"<h1><%= it.title %></h1>\", { title: \"Hi\" });\n *\n * Or just use a file with a `.eta` extension — `renderView` picks\n * the Eta adapter automatically:\n *\n * setViewPaths(\"views\");\n * return { view: \"about.eta\", data: { title: \"Hi\" } };\n */\nimport type { ViewAdapter, ViewContext, ViewOptions } from \"./types.js\";\n\nexport class EtaAdapter implements ViewAdapter {\n\treadonly name = \"eta\";\n\tprivate cache = new Map<string, (data: Record<string, any>) => string>();\n\n\tasync render(\n\t\ttemplate: string,\n\t\tdata: Record<string, any>,\n\t\t_context?: ViewContext,\n\t\t_options?: ViewOptions,\n\t): Promise<string> {\n\t\tconst compiled = this.getCompiled(template);\n\t\treturn compiled(data);\n\t}\n\n\tcompile(template: string, _options?: ViewOptions) {\n\t\tconst compiled = this.getCompiled(template);\n\t\treturn (data: Record<string, any>) => Promise.resolve(compiled(data));\n\t}\n\n\tprivate getCompiled(template: string) {\n\t\tlet fn = this.cache.get(template);\n\t\tif (!fn) {\n\t\t\t// Lazy require so `eta` is truly optional. If the\n\t\t\t// user never uses `.eta` files, Eta isn't loaded.\n\t\t\tlet Eta: any;\n\t\t\ttry {\n\t\t\t\t// @ts-ignore — eta is an optional peer dep\n\t\t\t\tEta = require(\"eta\").Eta;\n\t\t\t} catch (e) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[nexus] EtaAdapter: the \"eta\" package is not installed. ` +\n\t\t\t\t\t\t`Run \\`bun add eta\\` (or \\`npm install eta\\`) to use .eta templates.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst eta = new Eta();\n\t\t\tfn = (data: Record<string, any>) =>\n\t\t\t\teta.renderString(template, data) as string;\n\t\t\tthis.cache.set(template, fn);\n\t\t}\n\t\treturn fn;\n\t}\n}\n",
|
|
8
|
+
"/**\n * View engine abstraction.\n *\n * The framework can render templates using any installed engine. Built-in\n * adapters ship for Rendu (PHP-style templates), Edge (Adonis-style),\n * and Eta (EJS-style).\n *\n * The default adapter is Rendu because it works on every runtime —\n * Cloudflare Workers, Bun, Deno, and Node — without extra dependencies.\n */\nimport { RenduAdapter } from \"./rendu.js\";\nimport { EdgeAdapter } from \"./edge.js\";\nimport { EtaAdapter } from \"./eta.js\";\nimport type { ViewAdapter, ViewContext } from \"./types.js\";\n\nexport type { ViewAdapter, ViewContext, ViewOptions } from \"./types.js\";\n\n/**\n * A single directory to search when the `view` value looks like a file path\n * (e.g. `\"about.html\"` or `\"emails/welcome.html\"`). Configured via\n * `setViewPaths()` or `Application.setViewPaths()`. Empty by default\n * — leave it empty (the default) to require inline templates,\n * or set it once at boot to enable file-based views.\n */\nlet viewPath: string = \"\";\n\n/** Set the directory searched for view files. Pass `\"\"` to disable. */\nexport function setViewPaths(path: string): void {\n\tviewPath = path ? (path.endsWith(\"/\") || path.endsWith(\"\\\\\") ? path : `${path}/`) : \"\";\n}\n\n/** Return the current view path (empty string means disabled). */\nexport function getViewPaths(): string {\n\treturn viewPath;\n}\n\n/** File extensions that indicate the `view` value is a file path. */\nconst VIEW_FILE_EXTS = [\".html\", \".edge\", \".rendu\", \".eta\"] as const;\n\n/**\n * Is the given string a file path (i.e. has one of the known view\n * file extensions)? Used to decide whether `renderView` should\n * load the file from disk or treat the string as inline source.\n */\nfunction isViewFilePath(name: string): boolean {\n\tconst lower = name.toLowerCase();\n\treturn VIEW_FILE_EXTS.some((ext) => lower.endsWith(ext));\n}\n\n/**\n * Pick the right adapter for a given template source. Selection\n * is by file extension:\n * `.edge` → EdgeAdapter\n * `.eta` → EtaAdapter\n * `.html` / `.rendu` / no extension → RenduAdapter (default)\n */\nfunction selectAdapter(template: string): ViewAdapter {\n\tconst lower = template.toLowerCase();\n\tif (lower.endsWith(\".edge\")) return new EdgeAdapter();\n\tif (lower.endsWith(\".eta\")) return new EtaAdapter();\n\treturn new RenduAdapter();\n}\n\n/**\n * Render a view.\n *\n * - If `template` ends in a known view file extension (`.html`,\n * `.edge`, `.rendu`, `.eta`) and `viewPaths` is non-empty, the\n * file is loaded from the first matching directory and used\n * as the template source. The adapter is picked by extension.\n * - Otherwise `template` is treated as inline template source\n * with the default (Rendu) adapter.\n *\n * Override the default adapter globally with\n * `app.setViewAdapter()`.\n */\nexport async function renderView(\n\ttemplate: string,\n\tdata: Record<string, any>,\n\tcontext?: ViewContext,\n): Promise<string> {\n\tlet source = template;\n\tif (isViewFilePath(template) && viewPath.length > 0) {\n\t\tconst loaded = await loadTemplate(viewPath, template);\n\t\tif (loaded === null) {\n\t\t\tthrow new Error(\n\t\t\t\t`[nexus] View file not found: \"${template}\" (searched: ${viewPath})`,\n\t\t\t);\n\t\t}\n\t\tsource = loaded;\n\t}\n\tconst adapter = selectAdapter(source);\n\treturn adapter.render(source, data, context);\n}\n\n/**\n * Try to locate a template file inside the given directory. Returns the\n * file contents or `null` if not found. This is intentionally\n * filesystem-based and only used on serverful runtimes; edge adapters\n * should pass inline strings instead.\n */\nexport async function loadTemplate(\n\tdir: string,\n\tname: string,\n): Promise<string | null> {\n\tif (!dir) return null;\n\tconst full = joinPath(dir, name);\n\ttry {\n\t\tconst file = await readFile(full);\n\t\tif (file !== null) return file;\n\t} catch {\n\t\t// ignore\n\t}\n\treturn null;\n}\n\n/**\n * Path join that works on both POSIX and Windows. Node/Bun provide path,\n * but Cloudflare Workers do not, so we re-implement minimally.\n */\nfunction joinPath(dir: string, name: string): string {\n\tif (!dir.endsWith(\"/\") && !dir.endsWith(\"\\\\\")) return `${dir}/${name}`;\n\treturn `${dir}${name}`;\n}\n\nasync function readFile(path: string): Promise<string | null> {\n\t// Node/Bun.\n\tif (typeof globalThis.Bun !== \"undefined\") {\n\t\ttry {\n\t\t\tconst file = (globalThis as any).Bun.file(path);\n\t\t\tif (await file.exists()) return file.text();\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\t}\n\t// Node-style (also works in Bun).\n\ttry {\n\t\tconst fs = await import(\"node:fs/promises\");\n\t\treturn await fs.readFile(path, \"utf8\");\n\t} catch {\n\t\treturn null;\n\t}\n}\n",
|
|
9
|
+
"/**\n * Metadata keys used by reflect-metadata for storing decorator data.\n *\n * These constants are the contract between decorators and the framework\n * core (DI container, router, validator).\n */\nexport const METADATA_KEY = {\n\t/** Marks a class as a Nest-style controller, stores route prefix. */\n\tCONTROLLER: \"nexus:controller\",\n\n\t/** Marks a class as an injectable provider. */\n\tINJECTABLE: \"nexus:injectable\",\n\n\t/** Marks a class as a repository. */\n\tREPOSITORY: \"nexus:repository\",\n\n\t/** Marks a class as a module. Stores module options. */\n\tMODULE: \"nexus:module\",\n\n\t/** HTTP method routes registered on a controller (Get/Post/...). */\n\tROUTES: \"nexus:routes\",\n\n\t/** Method parameter type metadata (body/query/param/headers/ctx). */\n\tPARAMS: \"nexus:params\",\n\n\t/** Validation schema per method (Zod schema or class). */\n\tVALIDATE: \"nexus:validate\",\n\n\t/** Class-level design:paramtypes (built-in). */\n\tPARAMTYPES: \"design:paramtypes\",\n\n\t/** Class-level design:type (built-in). */\n\tTYPE: \"design:type\",\n\n\t/** Class-level design:returntype (built-in). */\n\tRETURNTYPE: \"design:returntype\",\n\n\t/** Provider token to inject for a parameter (for custom tokens). */\n\tINJECT: \"nexus:inject\",\n} as const;\n\nexport type MetadataKey = (typeof METADATA_KEY)[keyof typeof METADATA_KEY];\n\n/** Available parameter decorator locations. */\nexport const PARAM_TYPES = {\n\tREQUEST: 0,\n\tRESPONSE: 1,\n\tNEXT: 2,\n\tBODY: 3,\n\tQUERY: 4,\n\tPARAM: 5,\n\tHEADERS: 6,\n\tCTX: 7,\n\tUSER: 8,\n} as const;\n\nexport type ParamType = (typeof PARAM_TYPES)[keyof typeof PARAM_TYPES];\n\n/** HTTP methods supported by the router. */\nexport const HTTP_METHODS = [\n\t\"GET\",\n\t\"POST\",\n\t\"PUT\",\n\t\"DELETE\",\n\t\"PATCH\",\n\t\"OPTIONS\",\n\t\"HEAD\",\n] as const;\nexport type HttpMethod = (typeof HTTP_METHODS)[number];\n",
|
|
10
|
+
"/**\n * @Controller decorator.\n *\n * Marks a class as a controller and registers a route prefix.\n * Routes inside the controller class are decorated with @Get/@Post/etc.\n *\n * @example\n * ```ts\n * @Controller('/users')\n * class UserController {\n * @Get('/')\n * list() { ... }\n * }\n * ```\n */\nimport \"reflect-metadata\";\nimport { METADATA_KEY } from \"../constants.js\";\nimport type { ControllerMetadata } from \"../di/tokens.js\";\n\nexport function Controller(prefix: string = \"/\"): ClassDecorator {\n\treturn (target: object) => {\n\t\tconst normalized = normalizePrefix(prefix);\n\t\tconst meta: ControllerMetadata = { prefix: normalized };\n\t\tReflect.defineMetadata(METADATA_KEY.CONTROLLER, meta, target);\n\t};\n}\n\nexport function getControllerMetadata(target: any): ControllerMetadata {\n\treturn (\n\t\tReflect.getMetadata(METADATA_KEY.CONTROLLER, target) ?? { prefix: \"/\" }\n\t);\n}\n\nexport function isController(target: any): boolean {\n\treturn Reflect.hasMetadata(METADATA_KEY.CONTROLLER, target);\n}\n\n/**\n * Normalize a prefix so we can safely concatenate it with handler paths.\n * - Empty string becomes '/'.\n * - Trailing slashes are trimmed (we re-add them on the join).\n * - No leading slash is added; the router always joins with `/`.\n */\nfunction normalizePrefix(prefix: string): string {\n\tif (!prefix) return \"\";\n\tif (prefix !== \"/\" && prefix.endsWith(\"/\")) {\n\t\treturn prefix.slice(0, -1);\n\t}\n\treturn prefix;\n}\n",
|
|
11
|
+
"/**\n * HTTP method decorators.\n *\n * `@Get`, `@Post`, `@Put`, `@Delete`, `@Patch`, `@Options`, `@Head` mark a\n * controller method as a route handler. The path argument is appended to\n * the controller's prefix.\n *\n * @example\n * ```ts\n * @Controller('/users')\n * class UserController {\n * @Get('/')\n * list() {}\n *\n * @Post('/')\n * create(@Body() body: CreateUserDto) {}\n * }\n * ```\n */\nimport \"reflect-metadata\";\nimport { HTTP_METHODS, METADATA_KEY, type HttpMethod } from \"../constants.js\";\nimport type { RouteMetadata } from \"../di/tokens.js\";\n\nfunction defineRoute(method: HttpMethod, path: string): MethodDecorator {\n\treturn (\n\t\ttarget: object,\n\t\tpropertyKey: string | symbol,\n\t\tdescriptor: PropertyDescriptor,\n\t) => {\n\t\tconst routes: RouteMetadata[] =\n\t\t\tReflect.getMetadata(METADATA_KEY.ROUTES, target.constructor) ?? [];\n\n\t\troutes.push({\n\t\t\tmethod,\n\t\t\tpath: normalizePath(path),\n\t\t\tpropertyKey,\n\t\t\thandler: descriptor.value,\n\t\t});\n\n\t\tReflect.defineMetadata(METADATA_KEY.ROUTES, routes, target.constructor);\n\t};\n}\n\nfunction normalizePath(path: string): string {\n\tif (!path || path === \"/\") return \"/\";\n\treturn path.startsWith(\"/\") ? path : `/${path}`;\n}\n\nexport const Get = (path: string = \"/\") => defineRoute(\"GET\", path);\nexport const Post = (path: string = \"/\") => defineRoute(\"POST\", path);\nexport const Put = (path: string = \"/\") => defineRoute(\"PUT\", path);\nexport const Delete = (path: string = \"/\") => defineRoute(\"DELETE\", path);\nexport const Patch = (path: string = \"/\") => defineRoute(\"PATCH\", path);\nexport const Options = (path: string = \"/\") => defineRoute(\"OPTIONS\", path);\nexport const Head = (path: string = \"/\") => defineRoute(\"HEAD\", path);\n\nexport function getRoutes(target: any): RouteMetadata[] {\n\treturn Reflect.getMetadata(METADATA_KEY.ROUTES, target) ?? [];\n}\n\nexport { HTTP_METHODS };\nexport type { RouteMetadata };\n",
|
|
12
|
+
"/**\n * Parameter decorators.\n *\n * These mark a controller method argument as a source of request data:\n * - `@Req()` → Hono context\n * - `@Res()` → Response helper\n * - `@Next()` → next() callback (for middleware-style handlers)\n * - `@Body()` → request body (parsed)\n * - `@Query('key')` → a single query param, or full query object\n * - `@Param('key')` → a single path param, or full params object\n * - `@Headers('k')` → a single header, or full headers object\n * - `@Ctx()` → Hono context (alias for @Req)\n * - `@User()` → authenticated user (resolved via auth provider)\n *\n * The metadata is read by the router at mount time to build the\n * handler invocation list.\n */\nimport \"reflect-metadata\";\nimport { METADATA_KEY, PARAM_TYPES } from \"../constants.js\";\nimport type { ParamMetadata } from \"../di/tokens.js\";\n\nexport function createParamDecorator(\n\ttype: number,\n\tdata?: string | object,\n): ParameterDecorator {\n\treturn (\n\t\ttarget: object,\n\t\tpropertyKey: string | symbol | undefined,\n\t\tparameterIndex: number,\n\t) => {\n\t\t// Method parameter: target is the prototype, propertyKey is the method name.\n\t\t// Constructor parameter: target is the class, propertyKey is undefined.\n\t\tif (propertyKey !== undefined) {\n\t\t\tconst params: ParamMetadata[] =\n\t\t\t\tReflect.getMetadata(METADATA_KEY.PARAMS, target, propertyKey) ?? [];\n\t\t\tparams.push({\n\t\t\t\tindex: parameterIndex,\n\t\t\t\ttype,\n\t\t\t\tname: typeof data === \"string\" ? data : undefined,\n\t\t\t\tdata: typeof data === \"object\" ? data : undefined,\n\t\t\t});\n\t\t\tReflect.defineMetadata(METADATA_KEY.PARAMS, params, target, propertyKey);\n\t\t} else {\n\t\t\tconst params: ParamMetadata[] =\n\t\t\t\tReflect.getMetadata(METADATA_KEY.PARAMS, target) ?? [];\n\t\t\tparams.push({\n\t\t\t\tindex: parameterIndex,\n\t\t\t\ttype,\n\t\t\t\tname: typeof data === \"string\" ? data : undefined,\n\t\t\t\tdata: typeof data === \"object\" ? data : undefined,\n\t\t\t});\n\t\t\tReflect.defineMetadata(METADATA_KEY.PARAMS, params, target);\n\t\t}\n\t};\n}\n\nexport const Req = () => createParamDecorator(PARAM_TYPES.REQUEST);\nexport const Res = () => createParamDecorator(PARAM_TYPES.RESPONSE);\nexport const Next = () => createParamDecorator(PARAM_TYPES.NEXT);\nexport const Body = (key?: string) =>\n\tcreateParamDecorator(PARAM_TYPES.BODY, key);\nexport const Query = (key?: string) =>\n\tcreateParamDecorator(PARAM_TYPES.QUERY, key);\nexport const Param = (key?: string) =>\n\tcreateParamDecorator(PARAM_TYPES.PARAM, key);\nexport const Headers = (key?: string) =>\n\tcreateParamDecorator(PARAM_TYPES.HEADERS, key);\nexport const Ctx = () => createParamDecorator(PARAM_TYPES.CTX);\nexport const User = () => createParamDecorator(PARAM_TYPES.USER);\n\nexport function getParamMetadata(\n\ttarget: any,\n\tpropertyKey: string | symbol,\n): ParamMetadata[] {\n\treturn Reflect.getMetadata(METADATA_KEY.PARAMS, target, propertyKey) ?? [];\n}\n\nexport { PARAM_TYPES };\n",
|
|
13
|
+
"/**\n * @Validate decorator.\n *\n * Attaches Zod schemas (or class validators) to a route handler. Each\n * schema is run against the corresponding request part before the handler\n * executes; failed validation throws or returns a 400 response.\n *\n * @example\n * ```ts\n * const UserSchema = z.object({ name: z.string(), email: z.email() });\n *\n * @Post('/')\n * @Validate({ body: UserSchema })\n * create(@Body() body: z.infer<typeof UserSchema>) { ... }\n * ```\n */\nimport \"reflect-metadata\";\nimport { METADATA_KEY } from \"../constants.js\";\nimport type { ValidationMetadata } from \"../di/tokens.js\";\n\nexport function Validate(options: ValidationMetadata): MethodDecorator {\n\treturn (\n\t\ttarget: object,\n\t\tpropertyKey: string | symbol,\n\t\tdescriptor: PropertyDescriptor,\n\t) => {\n\t\tReflect.defineMetadata(\n\t\t\tMETADATA_KEY.VALIDATE,\n\t\t\toptions,\n\t\t\ttarget.constructor,\n\t\t\tpropertyKey,\n\t\t);\n\t};\n}\n\nexport function getValidationMetadata(\n\ttarget: any,\n\tpropertyKey: string | symbol,\n): ValidationMetadata | undefined {\n\treturn Reflect.getMetadata(METADATA_KEY.VALIDATE, target, propertyKey);\n}\n",
|
|
14
|
+
"/**\n * `RequestScope` — per-request DI lifetime via `AsyncLocalStorage`.\n *\n * Usage from a controller:\n *\n * @Get('/')\n * index(@Inject(REQUEST) req: any, @Inject(RequestContext) ctx: MyCtx) {\n * return { requestId: ctx.requestId };\n * }\n *\n * Usage from anywhere (e.g. a service deeper in the call tree):\n *\n * import { getRequest, getRequestScope } from 'nexusjs/core';\n *\n * function audit() {\n * const req = getRequest();\n * const scope = getRequestScope();\n * // ... read user, request id, etc.\n * }\n *\n * Implementation: a single `AsyncLocalStorage` slot per request. The\n * HTTP server middleware enters a new context at request start, and\n * the DI container checks for an active context when resolving\n * `scope: 'request'` providers.\n */\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { randomUUID } from \"node:crypto\";\nimport type { DIContainer } from \"./container.js\";\n\n/** The Hono context type. Kept loose to avoid a circular import. */\nexport type HonoContext = any;\n\n/**\n * Per-request state. Created by the HTTP middleware, lives for the\n * duration of a single request, and is propagated through the entire\n * async call tree via `AsyncLocalStorage`.\n */\nexport interface RequestScope {\n\t/** Unique id for this request. Useful for log correlation. */\n\treadonly id: string;\n\t/** The Hono context (c). */\n\tcontext: HonoContext;\n\t/** A per-request DI container (singleton container + this scope). */\n\tcontainer: DIContainer;\n\t/** User-extensible state bag. Modules can stash request-scoped data here. */\n\tstate: Map<string | symbol, unknown>;\n}\n\n/** Symbol token: inject the active Hono context. */\nexport const REQUEST = Symbol.for(\"nexus:REQUEST\");\n\n/** Symbol token: inject the entire RequestScope. */\nexport const REQUEST_SCOPE = Symbol.for(\"nexus:REQUEST_SCOPE\");\n\n/** Generate a short, log-friendly id. */\nfunction newRequestId(): string {\n\treturn randomUUID().slice(0, 8);\n}\n\nconst storage = new AsyncLocalStorage<RequestScope>();\n\n/** Internal: read/write access to the AsyncLocalStorage slot. */\nexport const RequestScopeStorage = {\n\t/** Get the current scope, or `undefined` if not inside a request. */\n\tget(): RequestScope | undefined {\n\t\treturn storage.getStore();\n\t},\n\t/**\n\t * Run `fn` inside a new request scope. The scope is propagated\n\t * through the async call tree.\n\t */\n\trun<T>(scope: RequestScope, fn: () => T | Promise<T>): T | Promise<T> {\n\t\treturn storage.run(scope, fn);\n\t},\n\t/**\n\t * Create a new scope. Used by the HTTP middleware.\n\t */\n\tcreate(context: HonoContext, container: DIContainer): RequestScope {\n\t\treturn {\n\t\t\tid: newRequestId(),\n\t\t\tcontext,\n\t\t\tcontainer,\n\t\t\tstate: new Map(),\n\t\t};\n\t},\n};\n\n// ---------------------------------------------------------------------------\n// Convenience helpers\n// ---------------------------------------------------------------------------\n\n/** Get the active Hono context, or `undefined` if not in a request. */\nexport function getRequest<T = HonoContext>(): T | undefined {\n\treturn storage.getStore()?.context as T | undefined;\n}\n\n/** Get the active RequestScope, or `undefined`. */\nexport function getRequestScope(): RequestScope | undefined {\n\treturn storage.getStore();\n}\n\n/** Get a piece of request-scoped state by key. */\nexport function getRequestState<T = unknown>(key: string | symbol): T | undefined {\n\treturn storage.getStore()?.state.get(key) as T | undefined;\n}\n\n/** Set a piece of request-scoped state. */\nexport function setRequestState(key: string | symbol, value: unknown): void {\n\tconst s = storage.getStore();\n\tif (s) s.state.set(key, value);\n}\n",
|
|
15
|
+
"/**\n * Dependency Injection Container.\n *\n * The container is the heart of the framework. It:\n * - Registers providers (classes, values, factories, aliases)\n * - Resolves dependencies recursively through reflect-metadata\n * - Manages instance lifecycles (singleton / request / transient)\n * - Detects circular dependencies and throws helpful errors\n *\n * Design notes:\n * - Modules each have their own container scope, but share the root\n * container for global providers. Exports propagate tokens upward.\n * - The container is lazy: nothing is instantiated until first resolve.\n */\nimport \"reflect-metadata\";\nimport { METADATA_KEY } from \"../constants.js\";\nimport type {\n\tFactoryProvider,\n\tInjectionToken,\n\tProvider,\n\tProviderScope,\n\tType,\n\tValueProvider,\n} from \"./tokens.js\";\nimport { RequestScopeStorage } from \"./request-scope.js\";\n\ninterface ProviderRecord {\n\ttoken: InjectionToken<any>;\n\tprovider: Provider<any>;\n\tscope: ProviderScope;\n\t/** Set of tokens this provider depends on (for cycle detection). */\n\tdependencies: Set<InjectionToken<any>>;\n}\n\nexport class DIContainer {\n\t/** Token -> provider record. */\n\tprivate providers = new Map<InjectionToken<any>, ProviderRecord>();\n\n\t/** Token -> singleton instance (lazy). */\n\tprivate singletons = new Map<InjectionToken<any>, any>();\n\n\t/** Token -> \"currently resolving\" flag for cycle detection. */\n\tprivate resolving = new Set<InjectionToken<any>>();\n\n\t/** Parent container (for hierarchical lookup of exports). */\n\tprivate parent?: DIContainer;\n\n\tconstructor(parent?: DIContainer) {\n\t\tthis.parent = parent;\n\t}\n\n\t/** Create a child container (used by modules). */\n\tcreateChild(): DIContainer {\n\t\treturn new DIContainer(this);\n\t}\n\n\t/** Register a provider or list of providers. */\n\tregister(providers: Provider<any> | Provider<any>[]): void {\n\t\tconst list = Array.isArray(providers) ? providers : [providers];\n\t\tfor (const provider of list) {\n\t\t\tthis.registerOne(provider);\n\t\t}\n\t}\n\n\tprivate registerOne(provider: Provider<any>): void {\n\t\tconst record = this.normalizeProvider(provider);\n\t\tif (this.providers.has(record.token)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Duplicate provider for token \"${this.tokenName(record.token)}\". ` +\n\t\t\t\t\t`Each token may only be registered once per container.`,\n\t\t\t);\n\t\t}\n\t\tthis.providers.set(record.token, record);\n\t}\n\n\t/**\n\t * Normalize a provider union into a uniform ProviderRecord.\n\t * - Type<...> → useClass equivalent\n\t * - { useClass | useValue | useFactory | useExisting } → as-is\n\t */\n\tprivate normalizeProvider(provider: Provider<any>): ProviderRecord {\n\t\tif (this.isClass(provider)) {\n\t\t\tconst dependencies = this.readClassDependencies(provider);\n\t\t\t// Read scope from @Injectable({ scope }) metadata if present.\n\t\t\tconst classScope = Reflect.getMetadata(\"nexus:di:scope\", provider) as\n\t\t\t\t| ProviderScope\n\t\t\t\t| undefined;\n\t\t\treturn {\n\t\t\t\ttoken: provider,\n\t\t\t\tprovider,\n\t\t\t\tscope: classScope ?? \"singleton\",\n\t\t\t\tdependencies,\n\t\t\t};\n\t\t}\n\n\t\tconst deps = this.readProviderDependencies(provider);\n\t\tconst scope: ProviderScope =\n\t\t\t(\"scope\" in provider && provider.scope) || \"singleton\";\n\n\t\treturn {\n\t\t\ttoken: provider.provide,\n\t\t\tprovider,\n\t\t\tscope,\n\t\t\tdependencies: deps,\n\t\t};\n\t}\n\n\t/** Read constructor parameter types from a class using reflect-metadata. */\n\tprivate readClassDependencies(cls: Type<any>): Set<InjectionToken<any>> {\n\t\tconst paramTypes: any[] =\n\t\t\tReflect.getMetadata(METADATA_KEY.PARAMTYPES, cls) || [];\n\t\tconst set = new Set<InjectionToken<any>>();\n\t\tfor (const t of paramTypes) {\n\t\t\tif (t && t !== Object) set.add(t);\n\t\t}\n\t\treturn set;\n\t}\n\n\t/** Read dependencies from a structured provider's `inject` array (factory). */\n\tprivate readProviderDependencies(\n\t\tprovider: Provider<any>,\n\t): Set<InjectionToken<any>> {\n\t\tconst set = new Set<InjectionToken<any>>();\n\t\tif (\n\t\t\t\"inject\" in provider &&\n\t\t\tArray.isArray((provider as FactoryProvider).inject)\n\t\t) {\n\t\t\tfor (const dep of (provider as FactoryProvider).inject!) {\n\t\t\t\tif (dep && typeof dep === \"object\" && \"token\" in dep) {\n\t\t\t\t\tset.add((dep as any).token);\n\t\t\t\t} else if (dep) {\n\t\t\t\t\tset.add(dep as InjectionToken<any>);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (\"useClass\" in provider) {\n\t\t\tconst cls = (provider as any).useClass;\n\t\t\treturn this.readClassDependencies(cls);\n\t\t}\n\t\treturn set;\n\t}\n\n\t/**\n\t * Resolve a token to an instance. Walks up the parent chain on miss.\n\t * Returns undefined when nothing is registered and the token is optional.\n\t */\n\tresolve<T = any>(token: InjectionToken<T>): T {\n\t\tif (this.resolving.has(token)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Circular dependency detected while resolving \"${this.tokenName(token)}\". ` +\n\t\t\t\t\t`Resolution stack: ${[...this.resolving].map((t) => this.tokenName(t)).join(\" -> \")}`,\n\t\t\t);\n\t\t}\n\n\t\t// Singletons are memoized at the container level where they were registered.\n\t\tconst cached = this.singletons.get(token);\n\t\tif (cached !== undefined) return cached;\n\n\t\t// Request-scoped providers are memoized per active request. The\n\t\t// request scope is held in AsyncLocalStorage so any deep call\n\t\t// (services, repositories, ...) sees the same instance.\n\t\tconst record0 = this.providers.get(token);\n\t\tif (record0 && record0.scope === \"request\") {\n\t\t\tconst scope = RequestScopeStorage.get();\n\t\t\tif (scope) {\n\t\t\t\tconst r2 = scope.container.singletons.get(token);\n\t\t\t\tif (r2 !== undefined) return r2;\n\t\t\t\tconst inst = this.instantiate(record0);\n\t\t\t\tscope.container.singletons.set(token, inst);\n\t\t\t\treturn inst;\n\t\t\t}\n\t\t}\n\n\t\tconst record = this.providers.get(token);\n\t\tif (!record) {\n\t\t\tif (this.parent) {\n\t\t\t\ttry {\n\t\t\t\t\treturn this.parent.resolve<T>(token);\n\t\t\t\t} catch {\n\t\t\t\t\t// Fall through to throw a richer error below.\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new Error(\n\t\t\t\t`No provider for \"${this.tokenName(token)}\". ` +\n\t\t\t\t\t`Register it via DIContainer.register() or @Module({ providers: [...] }).`,\n\t\t\t);\n\t\t}\n\n\t\t// Singletons resolve from the registering container so identity is stable.\n\t\tconst owningContainer = this.providers.get(token) === record ? this : this;\n\n\t\tthis.resolving.add(token);\n\t\ttry {\n\t\t\tconst instance = owningContainer.instantiate(record);\n\t\t\tif (record.scope === \"singleton\") {\n\t\t\t\towningContainer.singletons.set(token, instance);\n\t\t\t}\n\t\t\treturn instance;\n\t\t} finally {\n\t\t\tthis.resolving.delete(token);\n\t\t}\n\t}\n\n\t/** Try to resolve; return undefined instead of throwing when missing. */\n\ttryResolve<T = any>(token: InjectionToken<T>): T | undefined {\n\t\ttry {\n\t\t\treturn this.resolve<T>(token);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Instantiate a single provider record. Calls itself recursively\n\t * for each constructor parameter.\n\t */\n\tprivate instantiate(record: ProviderRecord): any {\n\t\tconst provider = record.provider;\n\n\t\tif (this.isClass(provider)) {\n\t\t\tconst paramTypes: any[] =\n\t\t\t\tReflect.getMetadata(METADATA_KEY.PARAMTYPES, provider) || [];\n\t\t\t// Bun's TypeScript transformer does NOT emit `design:paramtypes`,\n\t\t\t// so we also accept explicit @Inject() tokens per parameter as a\n\t\t\t// portable fallback. If @Inject metadata exists for a given index,\n\t\t\t// it overrides the (missing) type metadata.\n\t\t\tconst injectMap: Map<number, any> =\n\t\t\t\tReflect.getMetadata(METADATA_KEY.INJECT, provider) ?? new Map();\n\n\t\t\t// Use the larger of paramTypes.length and the highest @Inject key,\n\t\t\t// because esbuild/Bun may emit empty paramTypes while @Inject metadata\n\t\t\t// still describes real dependencies.\n\t\t\tconst maxInjectIndex =\n\t\t\t\tinjectMap.size > 0 ? Math.max(...Array.from(injectMap.keys())) + 1 : 0;\n\t\t\tconst totalParams = Math.max(paramTypes.length, maxInjectIndex);\n\t\t\tconst params: any[] = new Array(totalParams);\n\n\t\t\tfor (let index = 0; index < totalParams; index++) {\n\t\t\t\tif (injectMap.has(index)) {\n\t\t\t\t\tparams[index] = this.resolve(injectMap.get(index));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst type = paramTypes[index];\n\t\t\t\tif (!type || type === Object) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Cannot inject parameter at index ${index} of \"${provider.name || \"<anonymous>\"}\" ` +\n\t\t\t\t\t\t\t`(type is \"Object\" or \"undefined\"). This usually means ` +\n\t\t\t\t\t\t\t`reflect-metadata was not emitted by your toolchain (Bun's ` +\n\t\t\t\t\t\t\t`native transpiler doesn't emit decorator metadata). Use the ` +\n\t\t\t\t\t\t\t`@Inject(Token) parameter decorator to specify the dependency ` +\n\t\t\t\t\t\t\t`explicitly, e.g. \\`constructor(@Inject(UserService) private users: UserService)\\`.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tparams[index] = this.resolve(type);\n\t\t\t}\n\n\t\t\treturn new provider(...params);\n\t\t}\n\n\t\tif (\"useValue\" in provider) {\n\t\t\treturn (provider as ValueProvider<any>).useValue;\n\t\t}\n\n\t\tif (\"useClass\" in provider) {\n\t\t\tconst ClassRef = (provider as any).useClass as Type<any>;\n\t\t\t// Same logic as the bare-class branch: prefer @Inject tokens, fall\n\t\t\t// back to design:paramtypes, throw on missing metadata.\n\t\t\tconst paramTypes: any[] =\n\t\t\t\tReflect.getMetadata(METADATA_KEY.PARAMTYPES, ClassRef) || [];\n\t\t\tconst injectMap: Map<number, any> =\n\t\t\t\tReflect.getMetadata(METADATA_KEY.INJECT, ClassRef) ?? new Map();\n\t\t\tconst maxInjectIndex =\n\t\t\t\tinjectMap.size > 0 ? Math.max(...Array.from(injectMap.keys())) + 1 : 0;\n\t\t\tconst totalParams = Math.max(paramTypes.length, maxInjectIndex);\n\t\t\tconst params: any[] = new Array(totalParams);\n\t\t\tfor (let index = 0; index < totalParams; index++) {\n\t\t\t\tif (injectMap.has(index)) {\n\t\t\t\t\tparams[index] = this.resolve(injectMap.get(index));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst type = paramTypes[index];\n\t\t\t\tif (!type || type === Object) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Cannot inject parameter at index ${index} of \"${ClassRef.name}\" ` +\n\t\t\t\t\t\t\t`(type is \"Object\" or \"undefined\"). Add explicit type annotations or ` +\n\t\t\t\t\t\t\t`use @Inject(Token).`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tparams[index] = this.resolve(type);\n\t\t\t}\n\t\t\treturn new ClassRef(...params);\n\t\t}\n\n\t\tif (\"useFactory\" in provider) {\n\t\t\tconst factoryProvider = provider as FactoryProvider<any>;\n\t\t\tconst inject = factoryProvider.inject ?? [];\n\t\t\tconst args = inject.map((dep) => {\n\t\t\t\tif (dep && typeof dep === \"object\" && \"token\" in dep) {\n\t\t\t\t\tconst { token, optional } = dep as any;\n\t\t\t\t\treturn optional ? this.tryResolve(token) : this.resolve(token);\n\t\t\t\t}\n\t\t\t\treturn this.resolve(dep as InjectionToken<any>);\n\t\t\t});\n\t\t\treturn factoryProvider.useFactory(...args);\n\t\t}\n\n\t\tif (\"useExisting\" in provider) {\n\t\t\tconst existing = (provider as any).useExisting as InjectionToken<any>;\n\t\t\treturn this.resolve(existing);\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t`Unknown provider shape for token \"${this.tokenName(record.token)}\"`,\n\t\t);\n\t}\n\n\t/** Check whether a token is registered locally (does not consult parent). */\n\thas(token: InjectionToken<any>): boolean {\n\t\treturn this.providers.has(token);\n\t}\n\n\t/** Inspect the registered tokens (debug aid). */\n\tlist(): string[] {\n\t\treturn [...this.providers.keys()].map((t) => this.tokenName(t));\n\t}\n\n\tprivate isClass(value: any): value is Type<any> {\n\t\treturn typeof value === \"function\";\n\t}\n\n\tprivate tokenName(token: InjectionToken<any>): string {\n\t\tif (typeof token === \"function\") return token.name || \"<anonymous class>\";\n\t\tif (typeof token === \"symbol\") return token.toString();\n\t\treturn String(token);\n\t}\n}\n\n/**\n * Root application container. Modules created via @Module register their\n * providers into child containers of this root.\n */\nexport class ApplicationContainer extends DIContainer {\n\tprivate moduleContainers = new Map<Type<any>, DIContainer>();\n\n\tregisterModule(moduleClass: Type<any>, container: DIContainer): void {\n\t\tthis.moduleContainers.set(moduleClass, container);\n\t}\n\n\tgetModuleContainer(moduleClass: Type<any>): DIContainer | undefined {\n\t\treturn this.moduleContainers.get(moduleClass);\n\t}\n}\n",
|
|
16
|
+
"/**\n * Module scanner.\n *\n * Reads the @Module({...}) metadata and recursively registers all\n * providers/controllers from imports, registering exports into the\n * parent container so cross-module injection works.\n */\nimport { METADATA_KEY } from \"../constants.js\";\nimport type { ApplicationContainer, DIContainer } from \"./container.js\";\nimport type { ModuleOptions, Provider, Type } from \"./tokens.js\";\n\ninterface ScanResult {\n\t/** Controllers registered by this module. */\n\tcontrollers: Type[];\n\t/** Providers registered locally (classes + non-class providers). */\n\tproviders: Provider[];\n\t/** Tokens exported by this module. */\n\texports: any[];\n\t/** Container holding the module's locally-scoped providers. */\n\tcontainer: DIContainer;\n}\n\nexport class ModuleScanner {\n\tprivate scanned = new Map<Type<any>, ScanResult>();\n\n\tconstructor(private root: ApplicationContainer) {}\n\n\t/**\n\t * Scan a module tree starting from `rootModule`, registering all\n\t * providers and controllers into the appropriate containers.\n\t */\n\tscan(rootModule: Type<any>): { root: ScanResult; modules: ScanResult[] } {\n\t\tconst rootResult = this.scanModule(rootModule, this.root);\n\t\tconst all = [...this.scanned.values()];\n\t\treturn { root: rootResult, modules: all };\n\t}\n\n\t/**\n\t * Scan one module. Recurses into its `imports`, then registers its\n\t * providers and controllers. Exports are exposed to the parent\n\t * container.\n\t */\n\tprivate scanModule(\n\t\tmoduleClass: Type<any>,\n\t\tparentContainer: DIContainer,\n\t): ScanResult {\n\t\tif (this.scanned.has(moduleClass)) {\n\t\t\treturn this.scanned.get(moduleClass)!;\n\t\t}\n\n\t\tconst options = this.readModuleOptions(moduleClass);\n\t\tconst container = parentContainer.createChild();\n\t\tthis.root.registerModule(moduleClass, container);\n\n\t\t// Pre-fill the slot to break import cycles when modules reference each other.\n\t\tconst placeholder: ScanResult = {\n\t\t\tcontrollers: [],\n\t\t\tproviders: [],\n\t\t\texports: [],\n\t\t\tcontainer,\n\t\t};\n\t\tthis.scanned.set(moduleClass, placeholder);\n\n\t\t// Recurse into imports first so dependent tokens exist.\n\t\tfor (const imported of options.imports ?? []) {\n\t\t\tconst importedResult = this.scanModule(imported, parentContainer);\n\t\t\t// Expose imports' exports to the parent's container so the importing\n\t\t\t// module can resolve them.\n\t\t\tfor (const exp of importedResult.exports) {\n\t\t\t\tif (!parentContainer.has(exp)) {\n\t\t\t\t\t// Re-export by creating a passthrough provider that resolves from\n\t\t\t\t\t// the imported module's container.\n\t\t\t\t\tparentContainer.register({\n\t\t\t\t\t\tprovide: exp,\n\t\t\t\t\t\tuseFactory: () => importedResult.container.resolve(exp),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Register providers (and controllers as providers for DI).\n\t\tconst providers = [\n\t\t\t...(options.providers ?? []),\n\t\t\t...(options.controllers ?? []),\n\t\t];\n\t\tcontainer.register(providers);\n\n\t\t// Expose declared exports from this module's container to the parent.\n\t\tfor (const exp of options.exports ?? []) {\n\t\t\tif (!parentContainer.has(exp)) {\n\t\t\t\tparentContainer.register({\n\t\t\t\t\tprovide: exp,\n\t\t\t\t\tuseFactory: () => container.resolve(exp),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst result: ScanResult = {\n\t\t\tcontrollers: options.controllers ?? [],\n\t\t\tproviders: options.providers ?? [],\n\t\t\texports: options.exports ?? [],\n\t\t\tcontainer,\n\t\t};\n\t\tthis.scanned.set(moduleClass, result);\n\t\treturn result;\n\t}\n\n\tprivate readModuleOptions(moduleClass: Type<any>): ModuleOptions {\n\t\tconst meta = Reflect.getMetadata(METADATA_KEY.MODULE, moduleClass) as\n\t\t\t| ModuleOptions\n\t\t\t| undefined;\n\t\tif (!meta) {\n\t\t\tthrow new Error(\n\t\t\t\t`Class \"${moduleClass.name}\" is missing the @Module() decorator.`,\n\t\t\t);\n\t\t}\n\t\treturn meta;\n\t}\n\n\t/** Get a previously-scanned module's result (debug aid). */\n\tget(moduleClass: Type<any>): ScanResult | undefined {\n\t\treturn this.scanned.get(moduleClass);\n\t}\n}\n",
|
|
17
|
+
"/**\n * Hono middleware that activates a `RequestScope` for the duration\n * of an HTTP request. The scope is held in `AsyncLocalStorage` and\n * propagated through the entire async call tree.\n *\n * - At request start: build a new `RequestScope` (with a child\n * DI container that inherits from the application's container).\n * - Run the rest of the request inside the scope.\n * - At request end: the scope (and child container) is dropped,\n * so all per-request state is garbage-collected.\n *\n * The framework installs this middleware on the Hono app at\n * `NexusServer.start()` / `Application.listen()` time.\n */\nimport type { MiddlewareHandler } from \"hono\";\nimport { DIContainer } from \"./container.js\";\nimport {\n\tRequestScopeStorage,\n\tREQUEST,\n\tREQUEST_SCOPE,\n\ttype HonoContext,\n} from \"./request-scope.js\";\n\n/**\n * One-time setup: register the `REQUEST` and `REQUEST_SCOPE` tokens\n * on the root container. The factory reads the active scope on\n * each resolve, so the same `REQUEST` always points at the\n * current request regardless of which container resolves it.\n *\n * Idempotent — calling it twice is a no-op.\n */\nexport function installRequestTokens(root: DIContainer): void {\n\t// Avoid duplicate registrations on the same container.\n\tconst existing = (root as any).providers as Map<unknown, unknown> | undefined;\n\tif (existing && (existing.has(REQUEST) || existing.has(REQUEST_SCOPE))) return;\n\n\troot.register({\n\t\tprovide: REQUEST,\n\t\tscope: \"transient\",\n\t\tuseFactory: () => RequestScopeStorage.get()?.context,\n\t});\n\troot.register({\n\t\tprovide: REQUEST_SCOPE,\n\t\tscope: \"transient\",\n\t\tuseFactory: () => RequestScopeStorage.get(),\n\t});\n}\n\n/**\n * Build the request-scope middleware against the given root container.\n * The root container is the application's `ApplicationContainer` —\n * the one that holds every singleton provider.\n *\n * Call `installRequestTokens(root)` once before the server starts.\n * (The framework does this for you; you only need to call this\n * factory directly when wiring a custom Hono app.)\n */\nexport function requestScopeMiddleware(root: DIContainer): MiddlewareHandler {\n\tinstallRequestTokens(root);\n\treturn async (c, next) => {\n\t\t// The request container shares the root's providers but\n\t\t// gets its own per-request cache (the `singletons` Map).\n\t\tconst reqContainer = new DIContainer(root);\n\t\tconst scope = RequestScopeStorage.create(c as HonoContext, reqContainer);\n\t\treturn RequestScopeStorage.run(scope, () => next());\n\t};\n}",
|
|
18
|
+
"/**\n * HTTP middleware primitives.\n *\n * Middleware in Nexus is just a Hono-compatible function: `(c, next) => ...`.\n * The framework exposes a few ready-made middlewares (logger, CORS, error)\n * and lets users write their own.\n */\nimport type { Context, Next } from \"hono\";\n\n/** A Nexus/Hono middleware signature. */\nexport type Middleware = (c: Context, next: Next) => any | Promise<any>;\n\n/** Simple request logger. Logs method, URL, status, duration. */\nexport function logger(): Middleware {\n\treturn async (c, next) => {\n\t\tconst start = performance.now();\n\t\tawait next();\n\t\tconst ms = (performance.now() - start).toFixed(2);\n\t\tconst status = c.res.status;\n\t\tconsole.log(`[${c.req.method}] ${c.req.path} -> ${status} (${ms}ms)`);\n\t\treturn;\n\t};\n}\n\n/**\n * CORS middleware.\n *\n * An explicit origin (string or string[]) is required. The function does\n * not default to '*' because that is unsafe with credentials. Pass '*'\n * explicitly via `origin: '*'` only if you know your API has no cookies.\n */\nexport function cors(options: {\n\torigin: string | string[];\n\tmethods?: string[];\n\theaders?: string[];\n\tcredentials?: boolean;\n}): Middleware {\n\tconst origin = options.origin;\n\tconst methods = options.methods ?? [\n\t\t\"GET\",\n\t\t\"POST\",\n\t\t\"PUT\",\n\t\t\"DELETE\",\n\t\t\"PATCH\",\n\t\t\"OPTIONS\",\n\t\t\"HEAD\",\n\t];\n\tconst headerList = options.headers ?? [\"Content-Type\", \"Authorization\"];\n\tconst headersValue = Array.isArray(headerList)\n\t\t? headerList.join(\",\")\n\t\t: headerList;\n\n\treturn async (c, next) => {\n\t\tconst set = (key: string, value: string) => {\n\t\t\tc.res.headers.set(key, value);\n\t\t};\n\t\tset(\n\t\t\t\"Access-Control-Allow-Origin\",\n\t\t\tArray.isArray(origin) ? origin.join(\",\") : origin,\n\t\t);\n\t\tset(\"Access-Control-Allow-Methods\", methods.join(\",\"));\n\t\tset(\"Access-Control-Allow-Headers\", headersValue);\n\t\tif (options.credentials) set(\"Access-Control-Allow-Credentials\", \"true\");\n\n\t\tif (c.req.method === \"OPTIONS\") {\n\t\t\treturn c.body(null, 204);\n\t\t}\n\t\tawait next();\n\t\treturn;\n\t};\n}\n\n/**\n * Catch-all error handler. Translates errors with `status` and `body`\n * properties into JSON responses.\n */\nexport function errorHandler(): Middleware {\n\treturn async (c, next) => {\n\t\ttry {\n\t\t\tawait next();\n\t\t} catch (err: any) {\n\t\t\tconst status = err?.status ?? 500;\n\t\t\tconst body = err?.body ?? {\n\t\t\t\terror: err?.message ?? \"Internal Server Error\",\n\t\t\t};\n\t\t\treturn c.json(body, status as any);\n\t\t}\n\t\treturn;\n\t};\n}\n",
|
|
19
|
+
"/**\n * Zod-based validation pipeline.\n *\n * `validateRequest` runs the configured Zod schemas for each request part\n * and either returns the parsed value or throws a ValidationError.\n *\n * Schemas are read from @Validate({ body, query, params, headers }) on the\n * handler method.\n */\nimport type { ZodError, ZodSchema } from \"zod\";\nimport type { ValidationMetadata } from \"../di/tokens.js\";\n\nexport class ValidationError extends Error {\n\treadonly status = 400;\n\treadonly issues: ZodError[\"issues\"];\n\n\tconstructor(zodError: ZodError) {\n\t\tsuper(\"Validation failed\");\n\t\tthis.name = \"ValidationError\";\n\t\tthis.issues = zodError.issues;\n\t}\n}\n\nexport interface ValidationInput {\n\tbody?: unknown;\n\tquery?: unknown;\n\tparams?: unknown;\n\theaders?: unknown;\n}\n\nexport interface ValidationResult {\n\tbody?: unknown;\n\tquery?: unknown;\n\tparams?: unknown;\n\theaders?: unknown;\n}\n\n/**\n * Validate the request using the handler's @Validate metadata. Returns\n * parsed values keyed by part. Throws ValidationError on the first\n * failure (body → query → params → headers order).\n */\nexport function validateRequest(\n\tmetadata: ValidationMetadata | undefined,\n\tinput: ValidationInput,\n): ValidationResult {\n\tif (!metadata) return input as ValidationResult;\n\n\tconst result: ValidationResult = {};\n\n\tif (metadata.body) result.body = runSchema(metadata.body, input.body, \"body\");\n\telse result.body = input.body;\n\n\tif (metadata.query)\n\t\tresult.query = runSchema(metadata.query, input.query, \"query\");\n\telse result.query = input.query;\n\n\tif (metadata.params)\n\t\tresult.params = runSchema(metadata.params, input.params, \"params\");\n\telse result.params = input.params;\n\n\tif (metadata.headers)\n\t\tresult.headers = runSchema(metadata.headers, input.headers, \"headers\");\n\telse result.headers = input.headers;\n\n\treturn result;\n}\n\nfunction runSchema(schema: any, value: unknown, part: string): unknown {\n\tif (!isZodSchema(schema)) {\n\t\t// Allow passing a class validator or function as an escape hatch.\n\t\tif (typeof schema === \"function\") return schema(value);\n\t\tthrow new Error(\n\t\t\t`@Validate \"${part}\" must be a Zod schema or validator function. Got ${typeof schema}.`,\n\t\t);\n\t}\n\tconst parsed = schema.safeParse(value);\n\tif (!parsed.success) {\n\t\tthrow new ValidationError(parsed.error);\n\t}\n\treturn parsed.data;\n}\n\nfunction isZodSchema(value: any): value is ZodSchema {\n\treturn (\n\t\tvalue !== null &&\n\t\ttypeof value === \"object\" &&\n\t\ttypeof value.safeParse === \"function\"\n\t);\n}\n\n/**\n * Default error formatter for ValidationError.\n * Renders a JSON body suitable for the framework's HTTP layer.\n */\nexport function formatValidationError(err: ValidationError): {\n\tstatus: number;\n\tbody: { error: string; issues: ZodError[\"issues\"] };\n} {\n\treturn {\n\t\tstatus: err.status,\n\t\tbody: {\n\t\t\terror: err.message,\n\t\t\tissues: err.issues,\n\t\t},\n\t};\n}\n",
|
|
20
|
+
"/**\n * Router.\n *\n * The router is responsible for translating the framework's declarative\n * metadata (controllers + @Get/@Post + param decorators + validation)\n * into Hono route handlers.\n *\n * It supports three registration styles:\n * 1. **Nest style** — class decorators (@Controller, @Get, ...)\n * 2. **Adonis style** — `router.get('/users', UserController, 'list')`\n * 3. **Functional style** — `app.get('/users', async (c) => ...)`\n *\n * The router does NOT own the Hono instance; it just adds routes to\n * the Hono app passed to `Router.create(app, container)`.\n */\nimport \"reflect-metadata\";\nimport type { Hono } from \"hono\";\nimport { PARAM_TYPES } from \"../constants.js\";\nimport type { ApplicationContainer, DIContainer } from \"../di/container.js\";\nimport {\n\tgetControllerMetadata,\n\tisController,\n} from \"../decorators/controller.js\";\nimport { getRoutes } from \"../decorators/http-methods.js\";\nimport { getParamMetadata } from \"../decorators/params.js\";\nimport { getValidationMetadata } from \"../decorators/validate.js\";\nimport {\n\tValidationError,\n\tformatValidationError,\n\tvalidateRequest,\n} from \"../validation/validator.js\";\nimport type { HttpMethod, RouteMetadata, Type } from \"../di/tokens.js\";\n\nexport interface NexusRouter {\n\t/** Register a controller class (Nest style). */\n\tregisterController(controller: Type<any>, container?: DIContainer): void;\n\t/** Register a method handler in Adonis style. */\n\tadd(\n\t\tmethod: HttpMethod,\n\t\tpath: string,\n\t\thandler: any,\n\t\tmethodName?: string,\n\t\tcontainer?: DIContainer,\n\t): void;\n\t/** Register a raw Hono-compatible handler. */\n\traw(method: HttpMethod, path: string, handler: HonoHandler): void;\n\t/** Return the underlying Hono instance. */\n\tgetHono(): Hono;\n\t/** Return all registered routes (for OpenAPI spec generation). */\n\tgetRoutes(): Array<{\n\t\tmethod: string;\n\t\tpath: string;\n\t\ttarget: any;\n\t\tpropertyKey: string | symbol;\n\t\tvalidation?: {\n\t\t\tbody?: unknown;\n\t\t\tquery?: unknown;\n\t\t\tparams?: unknown;\n\t\t\theaders?: unknown;\n\t\t};\n\t}>;\n}\n\nexport type HonoHandler = (c: any, next?: any) => any | Promise<any>;\n\nconst HTTP_METHOD_TO_HONO: Record<\n\tHttpMethod,\n\t\"get\" | \"post\" | \"put\" | \"delete\" | \"patch\" | \"options\" | \"head\"\n> = {\n\tGET: \"get\",\n\tPOST: \"post\",\n\tPUT: \"put\",\n\tDELETE: \"delete\",\n\tPATCH: \"patch\",\n\tOPTIONS: \"options\",\n\tHEAD: \"head\",\n};\n\nclass NexusRouterImpl implements NexusRouter {\n\tprivate hono: Hono;\n\tprivate root: ApplicationContainer;\n\t/** Stored route metadata for OpenAPI spec generation. */\n\t#routeList: Array<{\n\t\tmethod: string;\n\t\tpath: string;\n\t\ttarget: any;\n\t\tpropertyKey: string | symbol;\n\t\tvalidation?: {\n\t\t\tbody?: unknown;\n\t\t\tquery?: unknown;\n\t\t\tparams?: unknown;\n\t\t\theaders?: unknown;\n\t\t};\n\t}> = [];\n\n\tconstructor(hono: Hono, root: ApplicationContainer) {\n\t\tthis.hono = hono;\n\t\tthis.root = root;\n\t}\n\n\tgetHono(): Hono {\n\t\treturn this.hono;\n\t}\n\n\t/** Return all registered routes (for OpenAPI spec generation). */\n\tgetRoutes(): Array<{\n\t\tmethod: string;\n\t\tpath: string;\n\t\ttarget: any;\n\t\tpropertyKey: string | symbol;\n\t\tvalidation?: {\n\t\t\tbody?: unknown;\n\t\t\tquery?: unknown;\n\t\t\tparams?: unknown;\n\t\t\theaders?: unknown;\n\t\t};\n\t}> {\n\t\treturn this.#routeList;\n\t}\n\n\tregisterController(controller: Type<any>, container?: DIContainer): void {\n\t\tif (!isController(controller)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Class \"${controller.name}\" is missing the @Controller() decorator.`,\n\t\t\t);\n\t\t}\n\n\t\tconst { prefix } = getControllerMetadata(controller);\n\t\tconst routes = getRoutes(controller);\n\t\tconst resolvedContainer =\n\t\t\tcontainer ?? this.resolveControllerContainer(controller);\n\n\t\tif (routes.length === 0) {\n\t\t\t// Register the controller so DI still wires it up; useful for future\n\t\t\t// features (CLI introspection, lifecycle hooks, etc.).\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const route of routes) {\n\t\t\tconst fullPath = this.joinPaths(prefix, route.path);\n\t\t\tthis.mountRoute(controller, route, fullPath, resolvedContainer);\n\t\t}\n\t}\n\n\tadd(\n\t\tmethod: HttpMethod,\n\t\tpath: string,\n\t\thandler: any,\n\t\tmethodName?: string,\n\t\tcontainer?: DIContainer,\n\t): void {\n\t\t// Two forms:\n\t\t// add('GET', '/users', handlerFn) → functional style\n\t\t// add('GET', '/users', UserController, 'list') → Adonis style\n\t\tif (\n\t\t\ttypeof handler === \"function\" &&\n\t\t\tmethodName &&\n\t\t\thandler.prototype &&\n\t\t\tisController(handler)\n\t\t) {\n\t\t\tconst controllerInstance = (container ?? this.root).resolve(handler);\n\t\t\tconst handlerFn = controllerInstance[methodName];\n\t\t\tconst fullPath = this.joinPaths(\n\t\t\t\tgetControllerMetadata(handler).prefix,\n\t\t\t\tpath,\n\t\t\t);\n\t\t\tconst routes = getRoutes(handler);\n\t\t\tconst route = routes.find((r) => r.propertyKey === methodName);\n\t\t\tif (!route) {\n\t\t\t\t// The route metadata wasn't found because we passed a free path\n\t\t\t\t// (not declared with @Get). Fall back to invoking the raw method.\n\t\t\t\tthis.raw(method, fullPath, async (c) =>\n\t\t\t\t\thandlerFn.call(controllerInstance, c),\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.mountRoute(\n\t\t\t\thandler,\n\t\t\t\t{ ...route, handler: handlerFn },\n\t\t\t\tfullPath,\n\t\t\t\tcontainer ?? this.root,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// Functional style: handler is already a Hono-compatible function.\n\t\tthis.raw(method, path, handler);\n\t}\n\n\traw(method: HttpMethod, path: string, handler: HonoHandler): void {\n\t\tconst fn = HTTP_METHOD_TO_HONO[method];\n\t\t// Hono doesn't expose a `head` method; fall back to `on` for HEAD.\n\t\tif (method === \"HEAD\") {\n\t\t\t(this.hono as any).on(\"HEAD\", path, handler as any);\n\t\t\treturn;\n\t\t}\n\t\t(this.hono as any)[fn](path, handler as any);\n\t}\n\n\t/**\n\t * Mount a single @Route-decorated method to Hono, including validation,\n\t * param resolution, and DI lookup of the controller instance.\n\t */\n\tprivate mountRoute(\n\t\tcontroller: Type<any>,\n\t\troute: RouteMetadata,\n\t\tfullPath: string,\n\t\tcontainer: DIContainer,\n\t): void {\n\t\tconst validation = getValidationMetadata(controller, route.propertyKey);\n\t\tconst paramMeta = getParamMetadata(controller.prototype, route.propertyKey);\n\n\t\t// Store for OpenAPI spec generation.\n\t\tthis.#routeList.push({\n\t\t\tmethod: route.method,\n\t\t\tpath: fullPath,\n\t\t\ttarget: controller.prototype,\n\t\t\tpropertyKey: route.propertyKey,\n\t\t\tvalidation: validation ?? undefined,\n\t\t});\n\n\t\tconst honoHandler = async (c: any) => {\n\t\t\ttry {\n\t\t\t\t// Lazy: resolve the controller from the container for each request.\n\t\t\t\t// This is important for transient/request-scoped controllers.\n\t\t\t\tconst instance = container.resolve(controller);\n\t\t\t\tconst args = await this.buildArgs(c, paramMeta, validation);\n\n\t\t\t\tconst result = await Promise.resolve(\n\t\t\t\t\troute.handler.call(instance, ...args),\n\t\t\t\t);\n\n\t\t\t\treturn await this.serialize(c, result);\n\t\t\t} catch (err) {\n\t\t\t\treturn this.handleError(c, err);\n\t\t\t}\n\t\t};\n\n\t\tconst fn = HTTP_METHOD_TO_HONO[route.method];\n\t\tif (route.method === \"HEAD\") {\n\t\t\t(this.hono as any).on(\"HEAD\", fullPath, honoHandler);\n\t\t\treturn;\n\t\t}\n\t\t(this.hono as any)[fn](fullPath, honoHandler);\n\t}\n\n\t/**\n\t * Build the argument list for a controller method invocation based on\n\t * the parameter decorator metadata.\n\t */\n\tprivate async buildArgs(\n\t\tc: any,\n\t\tparams: ReturnType<typeof getParamMetadata>,\n\t\tvalidation: any,\n\t) {\n\t\t// Run validation once; pass parsed values into @Body/@Query/@Param/@Headers.\n\t\tlet parsed: any;\n\t\tconst needsValidation =\n\t\t\tvalidation &&\n\t\t\t(validation.body ||\n\t\t\t\tvalidation.query ||\n\t\t\t\tvalidation.params ||\n\t\t\t\tvalidation.headers);\n\n\t\t// We also need the raw body when *any* parameter uses `@Body()`,\n\t\t// even without a `@Validate` schema. Without this a controller\n\t\t// like `@Post('/store') async store(@Body() input) { ... }`\n\t\t// would receive an empty body in vitest (and any environment\n\t\t// where the framework's parser isn't called eagerly).\n\t\tconst hasBodyParam = params.some((p: any) => p.type === PARAM_TYPES.BODY);\n\n\t\tif (needsValidation || hasBodyParam) {\n\t\t\tconst bodyPromise =\n\t\t\t\tneedsValidation && validation.body\n\t\t\t\t\t? safeReadBody(c)\n\t\t\t\t\t: hasBodyParam\n\t\t\t\t\t\t? safeReadBody(c)\n\t\t\t\t\t\t: Promise.resolve(undefined);\n\t\t\tconst [body] = await Promise.all([bodyPromise]);\n\t\t\tparsed = validateRequest(validation ?? {}, {\n\t\t\t\tbody,\n\t\t\t\tquery: c.req.query(),\n\t\t\t\tparams: c.req.param(),\n\t\t\t\theaders: c.req.header(),\n\t\t\t});\n\t\t}\n\n\t\tconst positional: any[] = [];\n\t\tfor (const param of params) {\n\t\t\tpositional[param.index] = this.resolveParam(c, param, parsed);\n\t\t}\n\t\treturn positional;\n\t}\n\n\tprivate resolveParam(c: any, param: any, parsed: any) {\n\t\tswitch (param.type) {\n\t\t\tcase PARAM_TYPES.REQUEST:\n\t\t\tcase PARAM_TYPES.CTX:\n\t\t\t\treturn c;\n\t\t\tcase PARAM_TYPES.RESPONSE:\n\t\t\t\treturn c.res;\n\t\t\tcase PARAM_TYPES.NEXT:\n\t\t\t\treturn async () => {};\n\t\t\tcase PARAM_TYPES.BODY:\n\t\t\t\tif (parsed) return parsed.body;\n\t\t\t\treturn param.name\n\t\t\t\t\t? (safeReadBody(c) as any)?.[param.name]\n\t\t\t\t\t: safeReadBody(c);\n\t\t\tcase PARAM_TYPES.QUERY:\n\t\t\t\tif (parsed) {\n\t\t\t\t\tif (param.name) return (parsed.query as any)?.[param.name];\n\t\t\t\t\treturn parsed.query;\n\t\t\t\t}\n\t\t\t\treturn param.name ? c.req.query(param.name) : c.req.query();\n\t\t\tcase PARAM_TYPES.PARAM:\n\t\t\t\tif (parsed) {\n\t\t\t\t\tif (param.name) return (parsed.params as any)?.[param.name];\n\t\t\t\t\treturn parsed.params;\n\t\t\t\t}\n\t\t\t\treturn param.name ? c.req.param(param.name) : c.req.param();\n\t\t\tcase PARAM_TYPES.HEADERS:\n\t\t\t\tif (parsed) {\n\t\t\t\t\tif (param.name)\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t(parsed.headers as any)?.[param.name] ?? c.req.header(param.name)\n\t\t\t\t\t\t);\n\t\t\t\t\treturn parsed.headers ?? c.req.header();\n\t\t\t\t}\n\t\t\t\treturn param.name ? c.req.header(param.name) : c.req.header();\n\t\t\tcase PARAM_TYPES.USER:\n\t\t\t\treturn (c as any).var?.nexus?.user;\n\t\t\tdefault:\n\t\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Serialize a controller return value into a Hono response. Supports:\n\t * - `Response` / `Response`-like objects\n\t * - `InertiaResponse` — serializes per the Inertia protocol\n\t * - `{ view: 'name', data }` for templates\n\t * - `{ redirect: '/path', status: 302 }` for redirects\n\t * - Plain objects → JSON\n\t * - Strings → text/html\n\t */\n\tprivate async serialize(c: any, value: any): Promise<any> {\n\t\tif (value === undefined || value === null) {\n\t\t\treturn c.body(null, 204);\n\t\t}\n\t\tif (value instanceof Response) {\n\t\t\t// Pass through to Hono by wrapping into the context. Going through\n\t\t\t// `c.body` ensures Hono correctly forwards the status, headers,\n\t\t\t// and body even when the response was created outside the\n\t\t\t// request-scoped Hono instance (e.g. from the Inertia adapter's\n\t\t\t// redirect/redirect-back helpers).\n\t\t\tconst headers: Record<string, string> = {};\n\t\t\tvalue.headers.forEach((v, k) => {\n\t\t\t\theaders[k] = v;\n\t\t\t});\n\t\t\tconst text = await value.text();\n\t\t\treturn c.body(text, value.status as any, headers);\n\t\t}\n\t\t// Inertia responses carry a discriminator tag — route them through\n\t\t// the dedicated serializer (handles JSON vs HTML, asset-version\n\t\t// mismatch, partial reloads, deferred props, etc.).\n\t\tif (this.isInertiaResponse(value)) {\n\t\t\treturn this.serializeInertia(c, value);\n\t\t}\n\t\tif (typeof value === \"object\") {\n\t\t\tif (\"view\" in value) {\n\t\t\t\t// Lazy import to avoid circular dependency.\n\t\t\t\treturn renderViewResponse(c, value);\n\t\t\t}\n\t\t\tif (\"redirect\" in value) {\n\t\t\t\treturn c.redirect(value.redirect, value.status ?? 302);\n\t\t\t}\n\t\t\tif (\"status\" in value && \"body\" in value) {\n\t\t\t\treturn c.json(value.body, value.status);\n\t\t\t}\n\t\t\treturn c.json(value);\n\t\t}\n\t\tif (typeof value === \"string\") {\n\t\t\treturn c.html(value);\n\t\t}\n\t\treturn c.json(value);\n\t}\n\n\t/**\n\t * Type guard for InertiaResponse — uses the discriminator tag set in\n\t * the constructor. We avoid `instanceof` so user code can subclass.\n\t */\n\tprivate isInertiaResponse(value: any): boolean {\n\t\treturn (\n\t\t\tvalue !== null &&\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue[\"__nexus_inertia_response__\"] === true &&\n\t\t\ttypeof value.toResponse === \"function\"\n\t\t);\n\t}\n\n\t/**\n\t * Serialize an InertiaResponse. Detects XHR vs HTML and emits the\n\t * correct shape. The response itself owns the version check and partial\n\t * reload logic.\n\t */\n\tprivate async serializeInertia(c: any, value: any): Promise<Response> {\n\t\treturn await value.toResponse(c);\n\t}\n\n\tprivate handleError(c: any, err: any): any {\n\t\tif (err instanceof ValidationError) {\n\t\t\tconst { status, body } = formatValidationError(err);\n\t\t\treturn c.json(body, status as any);\n\t\t}\n\t\t// Re-throw; the user-provided error middleware (if any) will catch it.\n\t\tthrow err;\n\t}\n\n\tprivate resolveControllerContainer(controller: Type<any>): DIContainer {\n\t\t// Walk the module tree looking for the container that owns this class.\n\t\tfor (const [, container] of (this.root as any).moduleContainers ??\n\t\t\tnew Map()) {\n\t\t\tif ((container as any).has?.(controller)) return container;\n\t\t}\n\t\t// Fallback to root.\n\t\treturn this.root;\n\t}\n\n\tprivate joinPaths(prefix: string, path: string): string {\n\t\tif (!prefix || prefix === \"/\") return path || \"/\";\n\t\tif (!path || path === \"/\") return prefix;\n\t\tif (prefix.endsWith(\"/\")) return `${prefix}${path}`;\n\t\treturn `${prefix}${path}`;\n\t}\n}\n\nasync function renderViewResponse(c: any, value: any): Promise<Response> {\n\tconst { renderView } = await import(\"../../view/view-engine.js\");\n\tconst html = await renderView(value.view, value.data ?? {});\n\treturn c.html(html, value.status ?? 200);\n}\n\nasync function safeReadBody(c: any): Promise<any> {\n\ttry {\n\t\tconst ct = c.req.header(\"content-type\") ?? \"\";\n\t\tif (ct.includes(\"application/json\")) {\n\t\t\treturn await c.req.json();\n\t\t}\n\t\tif (\n\t\t\tct.includes(\"application/x-www-form-urlencoded\") ||\n\t\t\tct.includes(\"multipart/form-data\")\n\t\t) {\n\t\t\treturn await c.req.parseBody();\n\t\t}\n\t\treturn await c.req.text();\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** Factory: build a router wrapping a Hono instance + container. */\nexport function createRouter(\n\thono: Hono,\n\tcontainer: ApplicationContainer,\n): NexusRouter {\n\treturn new NexusRouterImpl(hono, container);\n}\n",
|
|
21
|
+
"/**\n * Bun runtime adapter.\n *\n * Uses Bun's native HTTP server (Bun.serve) which is built on top of\n * uWebSockets and provides the fastest HTTP throughput in JavaScript.\n *\n * Usage:\n * const { bunAdapter } = await import('nexusjs/runtime');\n * bunAdapter(honoApp, 3000);\n */\nimport type { Hono } from \"hono\";\n\nexport function bunAdapter(app: Hono, port: number = 3000): any {\n\tconst Bun = (globalThis as any).Bun;\n\tif (!Bun || typeof Bun.serve !== \"function\") {\n\t\tthrow new Error(\"bunAdapter() requires the Bun runtime.\");\n\t}\n\n\tconst server = Bun.serve({\n\t\tport,\n\t\tfetch: (req: Request) => app.fetch(req),\n\t\terror: (err: Error) => {\n\t\t\tconsole.error(\"[bun-adapter] error:\", err);\n\t\t\treturn new Response(\"Internal Server Error\", { status: 500 });\n\t\t},\n\t});\n\n\tconsole.log(`[nexus] Listening on http://localhost:${server.port}`);\n\treturn server;\n}\n",
|
|
22
|
+
"/**\n * Node.js runtime adapter.\n *\n * Falls back to the standard `node:http` module. Bun can also run this\n * adapter when targeting Node-compatible servers, but Bun's native\n * adapter is significantly faster — only use this on actual Node.\n */\nimport type { Hono } from \"hono\";\nimport { createServer } from \"node:http\";\n\nexport function nodeAdapter(app: Hono, port: number = 3000): any {\n\tconst server = createServer(async (req, res) => {\n\t\ttry {\n\t\t\tconst url = `http://${req.headers.host}${req.url}`;\n\t\t\tconst headers = new Headers();\n\t\t\tfor (const [k, v] of Object.entries(req.headers)) {\n\t\t\t\tif (v == null) continue;\n\t\t\t\tif (Array.isArray(v)) headers.set(k, v.join(\", \"));\n\t\t\t\telse headers.set(k, String(v));\n\t\t\t}\n\n\t\t\tconst method = req.method ?? \"GET\";\n\t\t\tconst init: RequestInit = { method, headers };\n\n\t\t\tif (method !== \"GET\" && method !== \"HEAD\") {\n\t\t\t\tconst bodyBuf = await new Promise<Buffer>((resolve, reject) => {\n\t\t\t\t\tconst chunks: Buffer[] = [];\n\t\t\t\t\treq.on(\"data\", (c) => chunks.push(c));\n\t\t\t\t\treq.on(\"end\", () => resolve(Buffer.concat(chunks)));\n\t\t\t\t\treq.on(\"error\", reject);\n\t\t\t\t});\n\t\t\t\t// Web Request accepts ReadableStream (preferred) or a BufferSource.\n\t\t\t\t// Node's Buffer is a Uint8Array subclass but TS treats it as\n\t\t\t\t// `Buffer<ArrayBufferLike>` which isn't assignable to BodyInit, so\n\t\t\t\t// we copy into a plain Uint8Array view of the same memory.\n\t\t\t\tinit.body = new Uint8Array(\n\t\t\t\t\tbodyBuf.buffer,\n\t\t\t\t\tbodyBuf.byteOffset,\n\t\t\t\t\tbodyBuf.byteLength,\n\t\t\t\t) as BodyInit;\n\t\t\t\t// Duplex is required when sending a body in undici.\n\t\t\t\t(init as any).duplex = \"half\";\n\t\t\t}\n\n\t\t\tconst honoRes = await app.fetch(new Request(url, init));\n\t\t\tres.statusCode = honoRes.status;\n\t\t\thonoRes.headers.forEach((v, k) => res.setHeader(k, v));\n\t\t\tconst buf = Buffer.from(await honoRes.arrayBuffer());\n\t\t\tres.end(buf);\n\t\t} catch (err) {\n\t\t\tconsole.error(\"[node-adapter] error:\", err);\n\t\t\tres.statusCode = 500;\n\t\t\tres.end(\"Internal Server Error\");\n\t\t}\n\t});\n\n\tserver.listen(port, () => {\n\t\tconsole.log(`[nexus] Listening on http://localhost:${port}`);\n\t});\n\n\treturn server;\n}\n",
|
|
23
|
+
"/**\n * Cloudflare Workers runtime adapter.\n *\n * Returns a fetch handler suitable for `export default { fetch }` in a\n * Workers entry point. The Hono app is the actual fetch handler, so this\n * is mostly a thin wrapper.\n *\n * Usage:\n * // src/worker.ts\n * import { bootstrap } from './app.js';\n * const { fetch } = bootstrap();\n * export default { fetch };\n */\nimport type { Hono } from \"hono\";\n\nexport function cloudflareAdapter(app: Hono) {\n\treturn {\n\t\tfetch: (req: Request, env?: any, ctx?: any) => app.fetch(req, env, ctx),\n\t};\n}\n",
|
|
24
|
+
"/**\n * HTTP server.\n *\n * Builds a Hono app, attaches framework-level middleware (logging, CORS,\n * error handler), and returns a configured server instance. The Hono app\n * is exposed for users who want to register additional routes/middleware.\n *\n * Server.start() chooses the correct runtime adapter (Bun, Node, or\n * Cloudflare) automatically based on the global environment.\n */\nimport \"reflect-metadata\";\nimport { Hono } from \"hono\";\nimport type { ApplicationContainer } from \"../di/container.js\";\nimport { errorHandler, logger } from \"./middleware.js\";\nimport { createRouter, type NexusRouter } from \"./router.js\";\n\nexport interface NexusServerOptions {\n\t/** Enable request logging (default: true). */\n\tlogging?: boolean;\n\t/**\n\t * Enable the framework error handler (default: true). CORS is NOT\n\t * installed automatically; use `app.use(cors({ origin }))` for explicit\n\t * cross-origin setup.\n\t */\n\terrorHandler?: boolean;\n\t/** Port for the underlying HTTP server (Bun/Node). */\n\tport?: number;\n}\n\nexport class NexusServer {\n\treadonly app: Hono;\n\treadonly container: ApplicationContainer;\n\treadonly router: NexusRouter;\n\tprivate options: Required<NexusServerOptions>;\n\n\tconstructor(\n\t\tcontainer: ApplicationContainer,\n\t\toptions: NexusServerOptions = {},\n\t) {\n\t\tthis.container = container;\n\t\tthis.app = new Hono();\n\t\tthis.router = createRouter(this.app, container);\n\t\tthis.options = {\n\t\t\tlogging: options.logging ?? true,\n\t\t\terrorHandler: options.errorHandler ?? true,\n\t\t\tport: options.port ?? 3000,\n\t\t};\n\t\tthis.bootstrap();\n\t}\n\n\t/** Install the framework's built-in middleware. */\n\tprivate bootstrap(): void {\n\t\t// Request-scope middleware MUST come first so that everything\n\t\t// downstream (logging, error handler, controllers) can read\n\t\t// from the request scope.\n\t\tconst { requestScopeMiddleware } = require(\"../di/request-middleware.js\") as typeof import(\"../di/request-middleware.js\");\n\t\tthis.app.use(\"*\", requestScopeMiddleware(this.container as any));\n\t\tif (this.options.errorHandler) this.app.use(\"*\", errorHandler());\n\t\tif (this.options.logging) this.app.use(\"*\", logger());\n\t\t// CORS is intentionally NOT enabled by default. Use\n\t\t// `app.use(cors({ origin: 'https://example.com' }))` explicitly.\n\t}\n\n\t/** Register additional global middleware. */\n\tuse(...handlers: any[]): this {\n\t\tfor (const h of handlers) this.app.use(\"*\", h);\n\t\treturn this;\n\t}\n\n\t/** Override the port (use before start()). */\n\tsetPort(port: number): this {\n\t\t(this.options as any).port = port;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Start the HTTP server using the best available runtime adapter.\n\t * Returns the underlying server handle (Bun.Server, Node http.Server, or\n\t * a fetch-compatible Hono instance for Cloudflare Workers).\n\t */\n\tasync start(): Promise<any> {\n\t\tconst runtime = await detectRuntime();\n\t\tif (runtime === \"bun\") {\n\t\t\tconst { bunAdapter } = await import(\"../runtime/bun.js\");\n\t\t\treturn bunAdapter(this.app, this.options.port);\n\t\t}\n\t\tif (runtime === \"node\") {\n\t\t\tconst { nodeAdapter } = await import(\"../runtime/node.js\");\n\t\t\treturn nodeAdapter(this.app, this.options.port);\n\t\t}\n\t\tif (runtime === \"cloudflare\") {\n\t\t\tconst { cloudflareAdapter } = await import(\"../runtime/cloudflare.js\");\n\t\t\treturn cloudflareAdapter(this.app);\n\t\t}\n\t\tthrow new Error(\n\t\t\t\"No supported runtime detected (Bun, Node, or Cloudflare Workers).\",\n\t\t);\n\t}\n\n\t/**\n\t * For serverless / Edge runtimes: return a fetch handler that can be\n\t * exported from a Workers entry point.\n\t */\n\tget fetch(): (req: Request, env?: any, ctx?: any) => Promise<Response> {\n\t\treturn async (req, env, ctx) => this.app.fetch(req, env, ctx);\n\t}\n}\n\n/**\n * Auto-detect the current runtime. Order matters:\n * - Bun first (most specific)\n * - Node next\n * - Cloudflare Workers last (no Bun/Node globals)\n */\nexport async function detectRuntime(): Promise<\"bun\" | \"node\" | \"cloudflare\"> {\n\tif (typeof (globalThis as any).Bun !== \"undefined\") return \"bun\";\n\tif (typeof process !== \"undefined\" && process.versions?.node) return \"node\";\n\treturn \"cloudflare\";\n}\n",
|
|
25
|
+
"/**\n * Inertia.js lazy-evaluation helpers.\n *\n * These wrap a callback so the framework can decide *when* to resolve\n * it:\n *\n * - `defer()` → resolved on a follow-up partial reload only.\n * - `always()` → included in every partial reload, never trimmed.\n * - `optional()` → skipped on partial reloads when empty.\n * - `merge()` → client merges new value with previous.\n * - `deepMerge()` → client deep-merges new value with previous.\n * - `once()` → included only on first page load.\n *\n * Each helper is a thin wrapper class with a discriminator tag. The\n * adapter inspects the tag to decide the correct serialization behaviour.\n */\n\n/** Common shape for all Inertia helper wrappers. */\nexport interface InertiaHelper<T = any> {\n\t/** Discriminator tag — read by the adapter, never sent to the client. */\n\treadonly __inertiaKind: string;\n\t/** Resolve the wrapped callback. */\n\tresolve(): T | Promise<T>;\n}\n\n/**\n * Deferred prop. The client receives a `null` placeholder initially and\n * issues a follow-up request to fetch the real value. Use for expensive\n * data that shouldn't block the initial render.\n */\nexport class DeferredProp<T = any> implements InertiaHelper<T> {\n\treadonly __inertiaKind = \"deferred\";\n\n\tconstructor(\n\t\tprivate readonly callback: () => T | Promise<T>,\n\t\t/** Group name. Props in the same group resolve in one request. */\n\t\tpublic readonly group: string = \"default\",\n\t) {}\n\n\tresolve(): T | Promise<T> {\n\t\treturn this.callback();\n\t}\n}\n\n/** Build a deferred prop. */\nexport function defer<T>(\n\tcallback: () => T | Promise<T>,\n\tgroup: string = \"default\",\n): DeferredProp<T> {\n\treturn new DeferredProp(callback, group);\n}\n\n/**\n * Always-on prop. Included in *every* partial reload, regardless of the\n * client's `only` / `except` filter. Useful for data that nearly every\n * page needs (e.g. notification counts, current user).\n */\nexport class AlwaysProp<T = any> implements InertiaHelper<T> {\n\treadonly __inertiaKind = \"always\";\n\tconstructor(private readonly callback: () => T | Promise<T>) {}\n\tresolve(): T | Promise<T> {\n\t\treturn this.callback();\n\t}\n}\n\nexport function always<T>(callback: () => T | Promise<T>): AlwaysProp<T> {\n\treturn new AlwaysProp(callback);\n}\n\n/**\n * Optional prop. On partial reloads, omitted when the resolved value is\n * an array shorter than or equal to `threshold` (default 0). Helps\n * reduce response size when the user is filtering down to zero results.\n */\nexport class OptionalProp<T = any> implements InertiaHelper<T> {\n\treadonly __inertiaKind = \"optional\";\n\tconstructor(\n\t\tprivate readonly callback: () => T | Promise<T>,\n\t\tpublic readonly threshold: number = 0,\n\t) {}\n\tresolve(): T | Promise<T> {\n\t\treturn this.callback();\n\t}\n}\n\nexport function optional<T>(\n\tcallback: () => T | Promise<T>,\n\tthreshold: number = 0,\n): OptionalProp<T> {\n\treturn new OptionalProp(callback, threshold);\n}\n\n/**\n * Merge prop. The client merges the new value with its previous value,\n * which is essential for infinite-scroll pagination (append rather\n * than replace).\n */\nexport class MergeProp<T = any> implements InertiaHelper<T> {\n\treadonly __inertiaKind = \"merge\";\n\t/**\n\t * When provided, the client uses these paths to identify matching\n\t * items between the old and new arrays. Each inner array is a list of\n\t * property names whose combined values are compared.\n\t */\n\tpublic readonly matchPropsOn: string[][];\n\n\tconstructor(callback: () => T | Promise<T>, matchPropsOn: string[][] = []) {\n\t\tthis.matchPropsOn = matchPropsOn;\n\t\tthis.callback = callback;\n\t}\n\n\tprivate callback: () => T | Promise<T>;\n\tresolve(): T | Promise<T> {\n\t\treturn this.callback();\n\t}\n}\n\nexport function merge<T>(\n\tcallback: () => T | Promise<T>,\n\tmatchPropsOn: string[][] = [],\n): MergeProp<T> {\n\treturn new MergeProp(callback, matchPropsOn);\n}\n\n/**\n * Deep-merge prop. Like `merge`, but the client performs a recursive\n * object merge instead of array deduplication.\n */\nexport class DeepMergeProp<T = any> implements InertiaHelper<T> {\n\treadonly __inertiaKind = \"deepMerge\";\n\tconstructor(private readonly callback: () => T | Promise<T>) {}\n\tresolve(): T | Promise<T> {\n\t\treturn this.callback();\n\t}\n}\n\nexport function deepMerge<T>(callback: () => T | Promise<T>): DeepMergeProp<T> {\n\treturn new DeepMergeProp(callback);\n}\n\n/**\n * Once prop. Resolved and included only on the very first page load;\n * subsequent partial reloads never include it.\n */\nexport class OnceProp<T = any> implements InertiaHelper<T> {\n\treadonly __inertiaKind = \"once\";\n\tconstructor(private readonly callback: () => T | Promise<T>) {}\n\tresolve(): T | Promise<T> {\n\t\treturn this.callback();\n\t}\n}\n\nexport function once<T>(callback: () => T | Promise<T>): OnceProp<T> {\n\treturn new OnceProp(callback);\n}\n\n/**\n * Lazy prop. Resolved on every response (just like a plain prop), but\n * with two important differences:\n *\n * 1. The factory is invoked only once per request — even if multiple\n * keys point at the same factory or the same prop is referenced\n * elsewhere on the page. The adapter keys the cache on\n * `LazyProp.tag`, so two `lazy()` calls with the same tag share\n * their resolved value.\n * 2. Resolutions run alongside other lazy props so independent work\n * can overlap.\n *\n * Use this for any expensive computation you don't want to repeat\n * within a single request, but that should not be deferred to a\n * follow-up partial reload.\n */\nexport class LazyProp<T = any> implements InertiaHelper<T> {\n\treadonly __inertiaKind = \"lazy\";\n\t/** Cache key used by the adapter to deduplicate. */\n\treadonly tag: string;\n\t/** Increments on every resolve() — useful for tests / observability. */\n\tinvocations = 0;\n\n\tconstructor(\n\t\tprivate readonly callback: () => T | Promise<T>,\n\t\ttag?: string,\n\t) {\n\t\tthis.tag = tag ?? `lazy:${Math.random().toString(36).slice(2)}`;\n\t}\n\n\tresolve(): T | Promise<T> {\n\t\tthis.invocations++;\n\t\treturn this.callback();\n\t}\n}\n\n/** Build a lazy prop. Two calls with the same `tag` share their value. */\nexport function lazy<T>(\n\tcallback: () => T | Promise<T>,\n\ttag?: string,\n): LazyProp<T> {\n\treturn new LazyProp(callback, tag);\n}\n\n/**\n * Type guard: check whether a value is any Inertia helper wrapper.\n */\nexport function isInertiaHelper(value: unknown): value is InertiaHelper {\n\treturn (\n\t\tvalue !== null &&\n\t\ttypeof value === \"object\" &&\n\t\ttypeof (value as any).__inertiaKind === \"string\" &&\n\t\ttypeof (value as any).resolve === \"function\"\n\t);\n}\n\n/**\n * Strip helper wrappers from a props object, returning a plain\n * `{ [helperKind]: string[] }` map of which keys were wrapped and how.\n */\nexport interface PropAnnotation {\n\t/** Map of helperKind → array of prop keys. */\n\tbyKind: Record<string, string[]>;\n\t/** Optional config extracted per prop (e.g. merge matchPropsOn). */\n\tconfigs: Record<string, InertiaHelper>;\n}\n\nexport function annotateProps(props: Record<string, any>): PropAnnotation {\n\tconst byKind: Record<string, string[]> = {};\n\tconst configs: Record<string, InertiaHelper> = {};\n\n\tfor (const [key, value] of Object.entries(props)) {\n\t\tif (isInertiaHelper(value)) {\n\t\t\tconst kind = value.__inertiaKind;\n\t\t\t(byKind[kind] ??= []).push(key);\n\t\t\tconfigs[key] = value;\n\t\t}\n\t}\n\n\treturn { byKind, configs };\n}\n",
|
|
26
|
+
"/**\n * Default Inertia HTML shell renderer.\n *\n * When no SSR adapter is configured (the most common case for getting\n * started), we ship a minimal HTML page with the page object embedded\n * as a `data-page` attribute. The client picks it up and hydrates from\n * there.\n *\n * When an SSR adapter is configured, we render the page tree and\n * inject the resulting HTML into `<div id=\"app\">` before sending.\n */\nimport type { Context } from \"hono\";\nimport type { InertiaAdapter, InertiaPage, SsrAdapter } from \"./types.js\";\n\nexport async function renderDefaultRoot(\n\tadapter: InertiaAdapter,\n\tssr: SsrAdapter | null,\n\tcomponent: string,\n\tpage: InertiaPage,\n\tc: Context,\n): Promise<Response> {\n\tconst title = adapter.title();\n\tconst headTags: string[] = [];\n\tlet bodyHtml = \"\";\n\n\tif (ssr) {\n\t\ttry {\n\t\t\tconst result = await ssr.render(component, page.props);\n\t\t\tbodyHtml = result.html ?? \"\";\n\t\t\tif (result.head) headTags.push(...result.head);\n\t\t\tif (result.data) {\n\t\t\t\t// Merge any extra data the SSR engine emitted (rare).\n\t\t\t\tObject.assign(page, result.data);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\t// SSR is best-effort. If it fails we fall through to the shell\n\t\t\t// so the client can still hydrate from `data-page`.\n\t\t\tconsole.error(`[inertia] SSR render failed for \"${component}\":`, err);\n\t\t}\n\t}\n\n\tif (ssr?.head) {\n\t\ttry {\n\t\t\tconst extra = await ssr.head();\n\t\t\theadTags.push(...extra);\n\t\t} catch {\n\t\t\t// Ignore — head tags are optional.\n\t\t}\n\t}\n\n\tconst html = `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>${escapeHtml(title)}</title>\n${headTags.join(\"\\n\")}\n</head>\n<body>\n<div id=\"app\" data-page=\"${escapeAttr(JSON.stringify(page))}\">${bodyHtml}</div>\n</body>\n</html>`;\n\n\treturn c.html(html, 200, {\n\t\tVary: \"X-Inertia\",\n\t});\n}\n\nfunction escapeHtml(s: string): string {\n\treturn s\n\t\t.replace(/&/g, \"&\")\n\t\t.replace(/</g, \"<\")\n\t\t.replace(/>/g, \">\")\n\t\t.replace(/\"/g, \""\");\n}\n\nfunction escapeAttr(s: string): string {\n\treturn escapeHtml(s).replace(/'/g, \"'\");\n}\n",
|
|
27
|
+
"/**\n * InertiaResponse.\n *\n * The controller returns one of these via `inertia.render(...)`. When\n * the router sees it (a marker property), it asks the response to\n * serialize itself for the current request. The serialization differs\n * for Inertia XHR requests (JSON) and first-page loads (HTML shell).\n */\nimport type { Context } from \"hono\";\nimport type {\n\tInertiaAdapter,\n\tInertiaRequestInfo,\n\tInertiaPage,\n} from \"./types.js\";\nimport { isInertiaHelper } from \"./helpers.js\";\nimport { renderDefaultRoot } from \"./default-ssr.js\";\n\n/** Discriminator: the router detects InertiaResponse by this tag. */\nexport const INERTIA_RESPONSE_TAG = \"__nexus_inertia_response__\";\n\nexport class InertiaResponse {\n\t/** Discriminator tag — the router checks this before serializing. */\n\treadonly [INERTIA_RESPONSE_TAG] = true;\n\n\tprivate readonly options: {\n\t\tencryptHistory?: boolean;\n\t\tclearHistory?: boolean;\n\t} = {};\n\n\t/**\n\t * Per-response memoization cache for `lazy()` props. Keyed by\n\t * `LazyProp.tag`. Populated as factories resolve and reused on\n\t * subsequent lookups in the same request.\n\t */\n\tprivate readonly lazyCache = new Map<string, any>();\n\n\tconstructor(\n\t\tprivate readonly adapter: InertiaAdapter,\n\t\tprivate readonly component: string,\n\t\tprivate readonly props: Record<string, any>,\n\t) {}\n\n\t/** Override `encryptHistory` for this response. */\n\twithEncryptHistory(encrypt: boolean = true): this {\n\t\tthis.options.encryptHistory = encrypt;\n\t\treturn this;\n\t}\n\n\t/** Override `clearHistory` for this response. */\n\twithClearHistory(clear: boolean = true): this {\n\t\tthis.options.clearHistory = clear;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Serialize the response. The router calls this; you typically don't.\n\t */\n\tasync toResponse(c: Context): Promise<Response> {\n\t\tconst url = c.req.url;\n\t\tconst info = this.parseInertiaRequest(c);\n\n\t\t// 1. Asset-version mismatch → 409 + X-Inertia-Location.\n\t\tif (info.isInertia && info.clientVersion !== undefined) {\n\t\t\tconst serverVersion = await this.adapter.resolveVersion();\n\t\t\tif (serverVersion !== undefined && info.clientVersion !== serverVersion) {\n\t\t\t\treturn this.assetVersionMismatch(c.req.url);\n\t\t\t}\n\t\t}\n\n\t\t// 2. Build the page object.\n\t\tconst page = await this.buildPage(url, info, c);\n\n\t\t// 3. Branch on request type.\n\t\tif (info.isInertia) {\n\t\t\treturn this.jsonResponse(page);\n\t\t}\n\t\treturn this.htmlResponse(c, page);\n\t}\n\n\t// ============================================================================\n\t// Internals\n\t// ============================================================================\n\n\tprivate async buildPage(\n\t\turl: string,\n\t\tinfo: InertiaRequestInfo,\n\t\tc: Context,\n\t): Promise<InertiaPage> {\n\t\t// 1. Merge shared data (config-level shared + app-level shared).\n\t\tconst shared = await this.adapter.getSharedFor(c);\n\t\tconst allProps = { ...shared, ...this.props };\n\n\t\t// 2. Annotate helper wrappers and resolve them.\n\t\tconst resolved: Record<string, any> = {};\n\t\tconst deferredProps: Record<string, string[]> = {};\n\t\tconst mergeProps: string[] = [];\n\t\tconst deepMergeProps: string[] = [];\n\t\tconst matchPropsOn: string[][] = [];\n\n\t\tfor (const [key, value] of Object.entries(allProps)) {\n\t\t\tif (isInertiaHelper(value)) {\n\t\t\t\tconst helper = value;\n\t\t\t\tswitch (helper.__inertiaKind) {\n\t\t\t\t\tcase \"deferred\": {\n\t\t\t\t\t\tconst d = helper as any;\n\t\t\t\t\t\tconst group: string = d.group ?? \"default\";\n\t\t\t\t\t\t(deferredProps[group] ??= []).push(key);\n\t\t\t\t\t\t// Placeholder: must be `null` per spec.\n\t\t\t\t\t\tresolved[key] = null;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"always\": {\n\t\t\t\t\t\tresolved[key] = await Promise.resolve(helper.resolve());\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"optional\": {\n\t\t\t\t\t\tconst v = await Promise.resolve(helper.resolve());\n\t\t\t\t\t\tconst o = helper as any;\n\t\t\t\t\t\tconst threshold: number = o.threshold ?? 0;\n\t\t\t\t\t\tif (Array.isArray(v) && v.length <= threshold) {\n\t\t\t\t\t\t\t// On partial reload, drop; on full load, keep.\n\t\t\t\t\t\t\tif (this.isPartialReload(info)) {\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tresolved[key] = v;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"merge\": {\n\t\t\t\t\t\tconst v = await Promise.resolve(helper.resolve());\n\t\t\t\t\t\tmergeProps.push(key);\n\t\t\t\t\t\tconst m = helper as any;\n\t\t\t\t\t\tif (m.matchPropsOn && m.matchPropsOn.length > 0) {\n\t\t\t\t\t\t\tdeepMergeProps.push(key);\n\t\t\t\t\t\t\tmatchPropsOn.push(m.matchPropsOn);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tresolved[key] = v;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"deepMerge\": {\n\t\t\t\t\t\tresolved[key] = await Promise.resolve(helper.resolve());\n\t\t\t\t\t\tmergeProps.push(key);\n\t\t\t\t\t\tdeepMergeProps.push(key);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"once\": {\n\t\t\t\t\t\tif (info.isInertia) {\n\t\t\t\t\t\t\t// Already loaded once — skip.\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tresolved[key] = await Promise.resolve(helper.resolve());\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"lazy\": {\n\t\t\t\t\t\t// Lazy props are memoised per response. If multiple\n\t\t\t\t\t\t// keys share the same LazyProp tag, the factory\n\t\t\t\t\t\t// runs only once and every key receives the result.\n\t\t\t\t\t\tconst lz = helper as any;\n\t\t\t\t\t\tconst tag = lz.tag;\n\t\t\t\t\t\tif (this.lazyCache.has(tag)) {\n\t\t\t\t\t\t\tresolved[key] = this.lazyCache.get(tag);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst v = await Promise.resolve(helper.resolve());\n\t\t\t\t\t\t\tthis.lazyCache.set(tag, v);\n\t\t\t\t\t\t\tresolved[key] = v;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\t// Future helper kinds: just resolve and send.\n\t\t\t\t\t\tresolved[key] = await Promise.resolve(helper.resolve());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tresolved[key] = value;\n\t\t\t}\n\t\t}\n\n\t\t// 3. Apply partial-reload filters (only/except).\n\t\tconst sharedKeys = new Set(Object.keys(shared));\n\t\tthis.applyPartialFilter(resolved, info, sharedKeys);\n\n\t\t// 4. Resolve final metadata.\n\t\tconst version = await this.adapter.resolveVersion();\n\t\treturn {\n\t\t\tcomponent: this.component,\n\t\t\tprops: resolved,\n\t\t\turl,\n\t\t\tversion: version ?? \"\",\n\t\t\tencryptHistory:\n\t\t\t\tthis.options.encryptHistory ?? this.adapter.encryptHistory(),\n\t\t\tclearHistory: this.options.clearHistory ?? false,\n\t\t\tdeferredProps:\n\t\t\t\tObject.keys(deferredProps).length > 0 ? deferredProps : undefined,\n\t\t\tmergeProps: mergeProps.length > 0 ? mergeProps : undefined,\n\t\t\tdeepMergeProps: deepMergeProps.length > 0 ? deepMergeProps : undefined,\n\t\t\tmatchPropsOn: matchPropsOn.length > 0 ? matchPropsOn : undefined,\n\t\t\tscrollRegions: {},\n\t\t};\n\t}\n\n\t/**\n\t * Partial-reload filtering. Props not in `only` (or in `except`) are\n\t * dropped, except for:\n\t * - `AlwaysProp`-wrapped props\n\t * - Shared props (configured via `inertia.share(...)` or `sharedProps`)\n\t * - Deferred props (placeholders are kept so the client knows what to fetch)\n\t */\n\tprivate applyPartialFilter(\n\t\tresolved: Record<string, any>,\n\t\tinfo: InertiaRequestInfo,\n\t\tsharedKeys: Set<string>,\n\t): void {\n\t\tif (!this.isPartialReload(info)) return;\n\n\t\tif (info.partialOnly) {\n\t\t\tfor (const key of Object.keys(resolved)) {\n\t\t\t\tconst isAlways = sharedKeys.has(key); // shared + always treated equally\n\t\t\t\tif (!info.partialOnly.includes(key) && !isAlways) {\n\t\t\t\t\tdelete resolved[key];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (info.partialExcept) {\n\t\t\tfor (const key of Object.keys(resolved)) {\n\t\t\t\tconst isAlways = sharedKeys.has(key);\n\t\t\t\tif (info.partialExcept.includes(key) && !isAlways) {\n\t\t\t\t\tdelete resolved[key];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate isPartialReload(info: InertiaRequestInfo): boolean {\n\t\treturn info.isInertia && (!!info.partialOnly || !!info.partialExcept);\n\t}\n\n\tprivate parseInertiaRequest(c: Context): InertiaRequestInfo {\n\t\tconst isInertia = c.req.header(\"x-inertia\") === \"true\";\n\t\tconst partialOnlyHeader = c.req.header(\"x-inertia-partial-data\");\n\t\tconst partialExceptHeader = c.req.header(\"x-inertia-partial-except\");\n\t\tconst resetHeader = c.req.header(\"x-inertia-reset\");\n\n\t\treturn {\n\t\t\tisInertia,\n\t\t\tclientVersion: c.req.header(\"x-inertia-version\") ?? undefined,\n\t\t\tpartialComponent:\n\t\t\t\tc.req.header(\"x-inertia-partial-component\") ?? undefined,\n\t\t\tpartialOnly: this.csv(partialOnlyHeader),\n\t\t\tpartialExcept: this.csv(partialExceptHeader),\n\t\t\treset: this.csv(resetHeader),\n\t\t\tisHardReload: c.req.header(\"x-inertia-hard-reload\") === \"true\",\n\t\t};\n\t}\n\n\tprivate csv(value: string | undefined): string[] | undefined {\n\t\tif (!value) return undefined;\n\t\tconst parts = value\n\t\t\t.split(\",\")\n\t\t\t.map((s) => s.trim())\n\t\t\t.filter(Boolean);\n\t\treturn parts.length > 0 ? parts : undefined;\n\t}\n\n\tprivate jsonResponse(page: InertiaPage): Response {\n\t\treturn new Response(JSON.stringify(page), {\n\t\t\tstatus: 200,\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\tVary: \"X-Inertia\",\n\t\t\t\t\"X-Inertia\": \"true\",\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate htmlResponse(\n\t\tc: Context,\n\t\tpage: InertiaPage,\n\t): Promise<Response> | Response {\n\t\tconst ssr = this.adapter.ssr();\n\t\treturn renderDefaultRoot(\n\t\t\tthis.adapter,\n\t\t\tssr ?? null,\n\t\t\tthis.component,\n\t\t\tpage,\n\t\t\tc,\n\t\t);\n\t}\n\n\tprivate assetVersionMismatch(url: string): Response {\n\t\treturn new Response(null, {\n\t\t\tstatus: 409,\n\t\t\theaders: {\n\t\t\t\t\"X-Inertia-Location\": url,\n\t\t\t},\n\t\t});\n\t}\n}\n",
|
|
28
|
+
"/**\n * Inertia `<Form>` server-side helper.\n *\n * Mirrors the Inertia v3 client-side `<Form>` component behaviour:\n *\n * 1. Controllers wrap form actions with `inertia.form(...)`.\n * 2. They validate input (typically with Zod). On failure they call\n * `.withErrors(...).render()` and the page re-renders with the\n * `errors` and (optionally) `errorBag` props injected.\n * 3. On success they call `.redirect(url)` which emits a 303 — the\n * PRG (Post-Redirect-Get) pattern that prevents double-submits.\n * 4. `.withValues(input)` re-populates the form after a validation\n * failure so the user does not have to retype everything.\n *\n * The `errors` prop is special-cased by the Inertia client: it surfaces\n * validation errors to form fields automatically when you wire up the\n * matching `useForm` hook. `errorBag` lets multiple forms on the same\n * page coexist (each form has its own error namespace).\n *\n * @example\n * ```ts\n * @Post('/users')\n * async store(@Body() input: any) {\n * const form = this.inertia.form('Users/Create');\n * const result = UserSchema.safeParse(input);\n * if (!result.success) {\n * return form\n * .withErrorBag('createUser')\n * .withErrors(result.error.flatten().fieldErrors)\n * .withValues(input)\n * .render();\n * }\n * await this.userService.create(result.data);\n * return form.redirect('/users');\n * }\n * ```\n */\nimport type { Inertia } from \"./inertia-adapter.js\";\nimport type { InertiaResponse } from \"./inertia-response.js\";\n\n/**\n * Value shape for `withErrors`. Each field maps to a string (single\n * error) or an array of strings (multiple errors).\n */\nexport type ErrorMap = Record<string, string | string[]>;\n\n/**\n * Builder for an Inertia form response. Fluent API — every method\n * returns `this` so calls can be chained.\n */\nexport class InertiaFormBuilder {\n\tprivate props: Record<string, any>;\n\tprivate errorMap: Record<string, string[]> = {};\n\tprivate errorBagName?: string;\n\n\tconstructor(\n\t\tprivate readonly adapter: Inertia,\n\t\tprivate readonly component: string,\n\t\tinitialProps: Record<string, any> = {},\n\t) {\n\t\tthis.props = { ...initialProps };\n\t}\n\n\t// ============================================================================\n\t// Builder methods — all return `this` for chaining.\n\t// ============================================================================\n\n\t/** Merge a batch of props at once. */\n\twithProps(extra: Record<string, any>): this {\n\t\tObject.assign(this.props, extra);\n\t\treturn this;\n\t}\n\n\t/** Set a single prop. */\n\twith(key: string, value: any): this {\n\t\tthis.props[key] = value;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Attach validation errors. Each field maps to a string (single\n\t * error) or string[] (multiple). Strings are wrapped in arrays\n\t * internally to keep the shape uniform.\n\t */\n\twithErrors(errors: ErrorMap): this {\n\t\tfor (const [field, message] of Object.entries(errors)) {\n\t\t\tconst list = Array.isArray(message) ? message : [message];\n\t\t\t// Merge with existing errors on the same field.\n\t\t\tthis.errorMap[field] = [...(this.errorMap[field] ?? []), ...list];\n\t\t}\n\t\treturn this;\n\t}\n\n\t/** Add a single error to a field. */\n\twithError(field: string, message: string): this {\n\t\t(this.errorMap[field] ??= []).push(message);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Name the form's error namespace. Useful when multiple forms share\n\t * a page; each `useForm` hook on the client can read its own bag.\n\t */\n\twithErrorBag(name: string): this {\n\t\tthis.errorBagName = name;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Re-populate the form with the originally submitted values so\n\t * users don't have to retype them after a validation failure.\n\t */\n\twithValues(values: Record<string, any>): this {\n\t\tthis.props.values = values;\n\t\treturn this;\n\t}\n\n\t// ============================================================================\n\t// Terminal methods — emit the actual response.\n\t// ============================================================================\n\n\t/**\n\t * Render the page with the (possibly error-laden) props. If any\n\t * errors were attached, they are automatically injected as the\n\t * `errors` prop (and `errorBag` if a bag name was set).\n\t */\n\trender(): InertiaResponse {\n\t\tif (Object.keys(this.errorMap).length > 0) {\n\t\t\tthis.props.errors = { ...this.errorMap };\n\t\t}\n\t\tif (this.errorBagName) {\n\t\t\tthis.props.errorBag = this.errorBagName;\n\t\t}\n\t\treturn this.adapter.render(this.component, this.props);\n\t}\n\n\t/**\n\t * Issue a 303 redirect. 303 is the right status for non-GET methods\n\t * (POST/PUT/PATCH/DELETE) because it forces the client to follow up\n\t * with a GET — i.e. the PRG pattern. This prevents the browser from\n\t * resubmitting the form on refresh.\n\t */\n\tredirect(url: string): Response {\n\t\treturn new Response(null, {\n\t\t\tstatus: 303,\n\t\t\theaders: { Location: url },\n\t\t});\n\t}\n\n\t/**\n\t * Navigate back to the previous page (the Inertia client interprets\n\t * `Location: back` and steps one entry in its history). If `to` is\n\t * provided, redirect there instead.\n\t */\n\tback(to?: string): Response {\n\t\treturn new Response(null, {\n\t\t\tstatus: 303,\n\t\t\theaders: { Location: to ?? \"back\" },\n\t\t});\n\t}\n\n\t// ============================================================================\n\t// Inspection — useful in tests.\n\t// ============================================================================\n\n\t/** Read the currently-accumulated errors (without rendering). */\n\tgetErrors(): Record<string, string[]> {\n\t\treturn { ...this.errorMap };\n\t}\n\n\t/** Read the current prop draft. */\n\tgetProps(): Record<string, any> {\n\t\treturn { ...this.props };\n\t}\n}\n",
|
|
29
|
+
"/**\n * Inertia form middleware.\n *\n * Hooks into the request lifecycle for form actions (POST/PUT/PATCH/\n * DELETE) to do two things:\n *\n * 1. **Pre-parse form bodies.** When the client posts URL-encoded or\n * multipart data, parsing the body consumes the request stream.\n * The framework's `@Body()` parameter decorator parses JSON bodies\n * by default; this middleware additionally caches the parsed form\n * under `c.var.nexus.formBody` so controllers can read it via\n * `c.get('formBody')` without re-parsing.\n *\n * 2. **CSRF token validation.** If `validateCsrf` is enabled the\n * middleware looks for a token either in a header (`csrfHeader`) or\n * a form field (`csrfField`), compares it to the token registered\n * in shared props (`csrfSharedKey`), and returns 419 on mismatch.\n *\n * The middleware does NOT enforce a specific redirect strategy — the\n * `InertiaFormBuilder` handles that at the action level (303 + PRG).\n */\nimport type { Context, Next } from \"hono\";\nimport type { Middleware } from \"../../core/http/middleware.js\";\n\nexport interface InertiaFormMiddlewareOptions {\n\t/**\n\t * Whether to enforce CSRF validation. Off by default; turn on for\n\t * any deployment that exposes session-cookie auth.\n\t */\n\tvalidateCsrf?: boolean;\n\n\t/** Header name carrying the CSRF token. Default: `X-CSRF-Token`. */\n\tcsrfHeader?: string;\n\n\t/** Form field name carrying the CSRF token. Default: `_token`. */\n\tcsrfField?: string;\n\n\t/**\n\t * Key under `sharedProps` where the canonical CSRF token lives.\n\t * Default: `csrfToken`. The middleware reads this from\n\t * `c.var.nexus?.shared` (populated by `inertia.share(...)`).\n\t */\n\tcsrfSharedKey?: string;\n\n\t/**\n\t * Provide a custom CSRF resolver. Overrides the default shared-prop\n\t * lookup. Useful when the token is rotated per request via a\n\t * dedicated provider.\n\t */\n\tgetCsrfToken?: (c: Context) => string | undefined;\n\n\t/**\n\t * Status code to return on CSRF mismatch. Default: 419 (Laravel's\n\t * \"Page Expired\" convention).\n\t */\n\tcsrfFailureStatus?: number;\n}\n\n/** Methods that may carry form bodies and are CSRF-sensitive. */\nconst FORM_METHODS = new Set([\"POST\", \"PUT\", \"PATCH\", \"DELETE\"]);\n\nexport function inertiaFormMiddleware(\n\toptions: InertiaFormMiddlewareOptions = {},\n): Middleware {\n\tconst csrfHeader = (options.csrfHeader ?? \"X-CSRF-Token\").toLowerCase();\n\tconst csrfField = options.csrfField ?? \"_token\";\n\tconst csrfSharedKey = options.csrfSharedKey ?? \"csrfToken\";\n\tconst csrfStatus = options.csrfFailureStatus ?? 419;\n\n\treturn async (c: Context, next: Next) => {\n\t\tconst method = c.req.method;\n\n\t\t// 1. Skip non-form methods. We still want this middleware in the\n\t\t// chain so the user doesn't have to think about ordering.\n\t\tif (!FORM_METHODS.has(method)) {\n\t\t\tawait next();\n\t\t\treturn;\n\t\t}\n\n\t\t// 2. CSRF check (optional). Done before parsing the body so we\n\t\t// don't waste cycles on requests we'll reject.\n\t\tif (options.validateCsrf) {\n\t\t\tconst expected = options.getCsrfToken\n\t\t\t\t? options.getCsrfToken(c)\n\t\t\t\t: (c.get(\"nexusjs\") as any)?.shared?.[csrfSharedKey];\n\n\t\t\tif (typeof expected === \"string\" && expected.length > 0) {\n\t\t\t\tconst submittedHeader = c.req.header(csrfHeader);\n\t\t\t\tconst submittedField = await readFieldFromBody(c, csrfField);\n\t\t\t\tconst submitted = submittedHeader ?? submittedField;\n\n\t\t\t\tif (submitted !== expected) {\n\t\t\t\t\treturn c.json({ message: \"CSRF token mismatch\" }, csrfStatus as any);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// 3. Pre-parse form body. We only parse when the Content-Type\n\t\t// indicates a form encoding — JSON is handled by the\n\t\t// `@Body()` parameter decorator.\n\t\tconst contentType = c.req.header(\"content-type\") ?? \"\";\n\t\tif (\n\t\t\tcontentType.includes(\"application/x-www-form-urlencoded\") ||\n\t\t\tcontentType.includes(\"multipart/form-data\")\n\t\t) {\n\t\t\ttry {\n\t\t\t\tconst parsed = await c.req.parseBody();\n\t\t\t\t// Expose to downstream handlers via Hono's `c.set` so any\n\t\t\t\t// middleware in the chain (e.g. logging) can see it.\n\t\t\t\tc.set(\"formBody\" as any, parsed as Record<string, any>);\n\t\t\t} catch {\n\t\t\t\t// Malformed body — let the controller deal with it. We\n\t\t\t\t// don't want to 400 here because the user might have\n\t\t\t\t// shipped a controller that validates manually.\n\t\t\t}\n\t\t}\n\n\t\tawait next();\n\t\treturn;\n\t};\n}\n\n/**\n * Look for a single field in a form body. We avoid a full body parse\n * if Hono hasn't already cached one. In practice the `parseBody` call\n * upstream is the expensive bit; reading a field from the result is\n * constant time.\n */\nasync function readFieldFromBody(\n\tc: Context,\n\tfield: string,\n): Promise<string | undefined> {\n\tconst cached = c.get(\"formBody\" as any) as Record<string, any> | undefined;\n\tif (cached && Object.hasOwn(cached, field)) {\n\t\tconst v = cached[field];\n\t\treturn Array.isArray(v) ? v[0] : v;\n\t}\n\ttry {\n\t\tconst body = await c.req.parseBody();\n\t\tif (body && Object.hasOwn(body, field)) {\n\t\t\tconst v = (body as any)[field];\n\t\t\treturn Array.isArray(v) ? v[0] : v;\n\t\t}\n\t} catch {\n\t\t// Body was JSON or malformed; CSRF token cannot live there.\n\t}\n\treturn undefined;\n}\n",
|
|
30
|
+
"/**\n * The Inertia adapter.\n *\n * One instance lives on `app.inertia`. Controllers call\n * `inertia.render('Users/Index', { users: ... })` to build a page\n * response; the router detects the marker tag and routes the response\n * through the appropriate XHR / HTML pipeline.\n *\n * The adapter also exposes:\n * - `share(...)` for global per-page props (current user, flash, CSRF)\n * - `setVersion(...)` for asset versioning\n * - `setSsrAdapter(...)` for plugging in React/Vue/Svelte SSR\n * - `location(...)` for full-page reloads (e.g. on logout)\n * - `back()` to navigate one step in history\n */\nimport \"reflect-metadata\";\nimport type { Context } from \"hono\";\nimport type {\n\tInertiaConfig,\n\tInertiaAdapter,\n\tInertiaVersion,\n\tSsrAdapter,\n} from \"./types.js\";\nimport {\n\tAlwaysProp,\n\tDeepMergeProp,\n\tDeferredProp,\n\tMergeProp,\n\tOptionalProp,\n\tOnceProp,\n\tannotateProps,\n\ttype isInertiaHelper,\n} from \"./helpers.js\";\nimport { InertiaResponse, INERTIA_RESPONSE_TAG } from \"./inertia-response.js\";\nimport { InertiaFormBuilder } from \"./form-helper.js\";\n\nconst INERTIA_TOKEN = Symbol.for(\"nexus:Inertia\");\n\nexport class Inertia implements InertiaAdapter {\n\tprivate config: InertiaConfig;\n\t/** Static, in-process shared data. Resolved via `share(...)`. */\n\tprivate shared: Record<string, any> = {};\n\n\tconstructor(config: InertiaConfig = {}) {\n\t\tthis.config = {\n\t\t\tencryptHistory: false,\n\t\t\t...config,\n\t\t};\n\t}\n\n\t// ============================================================================\n\t// Public API — the controller-facing surface\n\t// ============================================================================\n\n\t/**\n\t * Render an Inertia page. Supports two call shapes:\n\t *\n\t * render(component, props) — simple form\n\t * render(component, deferred, props) — advanced form with deferred map\n\t *\n\t * Props can be plain values or helper wrappers (`defer()`, `always()`, ...).\n\t */\n\trender(component: string, props: Record<string, any>): InertiaResponse;\n\trender(\n\t\tcomponent: string,\n\t\tdeferred: Record<string, DeferredProp>,\n\t\tprops: Record<string, any>,\n\t): InertiaResponse;\n\trender(\n\t\tcomponent: string,\n\t\tpropsOrDeferred: Record<string, any>,\n\t\tmaybeProps?: Record<string, any>,\n\t): InertiaResponse {\n\t\tconst { component: comp, props } = this.normalizeRenderArgs(\n\t\t\tcomponent,\n\t\t\tpropsOrDeferred,\n\t\t\tmaybeProps,\n\t\t);\n\t\treturn new InertiaResponse(this, comp, props);\n\t}\n\n\t/**\n\t * Build a redirect-style response that forces the client to do a full\n\t * page navigation (NOT a client-side visit). Useful for logout, asset\n\t * revalidation, or any time you want to bypass Inertia's history.\n\t */\n\tlocation(url: string): Response {\n\t\treturn new Response(null, {\n\t\t\tstatus: 409,\n\t\t\theaders: {\n\t\t\t\t\"X-Inertia-Location\": url,\n\t\t\t},\n\t\t});\n\t}\n\n\t/** Render a redirect that the Inertia client can follow. */\n\tredirect(url: string, status: number = 302): Response {\n\t\t// Inertia treats 302/303 as client-side visits; use 409 for hard\n\t\t// redirects (bypassing Inertia history).\n\t\treturn new Response(null, {\n\t\t\tstatus,\n\t\t\theaders: { Location: url },\n\t\t});\n\t}\n\n\t/** Special \"back\" navigation — the client steps back in its history. */\n\tback(): Response {\n\t\treturn new Response(null, {\n\t\t\tstatus: 302,\n\t\t\theaders: { Location: \"back\" },\n\t\t});\n\t}\n\n\t/**\n\t * Begin a `<Form>` server-side flow. Returns a builder that the\n\t * controller chains onto (validate → on-error render, on-success\n\t * redirect). See `form-helper.ts` for the full lifecycle.\n\t *\n\t * @example\n\t * ```ts\n\t * const form = inertia.form('Users/Create');\n\t * const r = UserSchema.safeParse(input);\n\t * if (!r.success) return form.withErrors(r.error.flatten().fieldErrors).render();\n\t * return form.redirect('/users');\n\t * ```\n\t */\n\tform(\n\t\tcomponent: string,\n\t\tinitialProps: Record<string, any> = {},\n\t): InertiaFormBuilder {\n\t\treturn new InertiaFormBuilder(this, component, initialProps);\n\t}\n\n\t// ============================================================================\n\t// Configuration\n\t// ============================================================================\n\n\tsetVersion(version: InertiaVersion): this {\n\t\tthis.config.version = version;\n\t\treturn this;\n\t}\n\n\tsetSsrAdapter(adapter: SsrAdapter | null): this {\n\t\tthis.config.ssr = adapter ?? undefined;\n\t\treturn this;\n\t}\n\n\tsetTitle(title: string): this {\n\t\tthis.config.title = title;\n\t\treturn this;\n\t}\n\n\tsetEncryptHistory(encrypt: boolean = true): this {\n\t\tthis.config.encryptHistory = encrypt;\n\t\treturn this;\n\t}\n\n\tsetSharedProps(shared: InertiaConfig[\"sharedProps\"]): this {\n\t\tthis.config.sharedProps = shared;\n\t\treturn this;\n\t}\n\n\t// ============================================================================\n\t// Shared data\n\t// ============================================================================\n\n\t/**\n\t * Share data with every response. Two call shapes:\n\t * - `share('key', value)` — single key/value\n\t * - `share({ a: 1, b: 2 })` — batch update\n\t */\n\tshare(key: string | Record<string, any>, value?: any): void {\n\t\tif (typeof key === \"string\") {\n\t\t\tthis.shared[key] = value;\n\t\t} else if (key && typeof key === \"object\") {\n\t\t\tObject.assign(this.shared, key);\n\t\t}\n\t}\n\n\t/** Remove a previously shared key. */\n\tunshare(key: string): void {\n\t\tdelete this.shared[key];\n\t}\n\n\t/** Read the currently shared static data. */\n\tgetShared(): Record<string, any> {\n\t\treturn { ...this.shared };\n\t}\n\n\t// ============================================================================\n\t// InertiaAdapter interface — used by InertiaResponse\n\t// ============================================================================\n\n\ttitle(): string {\n\t\treturn this.config.title ?? \"Nexus\";\n\t}\n\n\tencryptHistory(): boolean {\n\t\treturn this.config.encryptHistory ?? false;\n\t}\n\n\tssr(): SsrAdapter | null {\n\t\treturn this.config.ssr ?? null;\n\t}\n\n\tasync resolveVersion(): Promise<string | undefined> {\n\t\tconst v = this.config.version;\n\t\tif (typeof v === \"function\") return await v();\n\t\treturn v;\n\t}\n\n\tasync getSharedFor(_c: Context): Promise<Record<string, any>> {\n\t\tconst static_ = this.getShared();\n\t\tconst configured = this.config.sharedProps;\n\t\tif (typeof configured === \"function\") {\n\t\t\tconst dyn = await configured();\n\t\t\treturn { ...static_, ...dyn };\n\t\t}\n\t\treturn { ...static_, ...(configured ?? {}) };\n\t}\n\n\t// ============================================================================\n\t// DI token — so users can inject the Inertia instance.\n\t// ============================================================================\n\n\t/** Symbol used as the DI token for the Inertia instance. */\n\tstatic readonly TOKEN = INERTIA_TOKEN;\n\n\t// ============================================================================\n\t// Internals\n\t// ============================================================================\n\n\t/**\n\t * Normalize the two call shapes into `{ component, props }`. The\n\t * `deferred` map (3-arg form) is folded into the props here so the\n\t * InertiaResponse sees a single props map.\n\t */\n\tprivate normalizeRenderArgs(\n\t\tcomponent: string,\n\t\tpropsOrDeferred: Record<string, any>,\n\t\tmaybeProps?: Record<string, any>,\n\t): {\n\t\tcomponent: string;\n\t\tprops: Record<string, any>;\n\t} {\n\t\tif (maybeProps !== undefined) {\n\t\t\t// 3-arg form: render(component, deferred, props)\n\t\t\tconst deferred: Record<string, DeferredProp> = {};\n\t\t\tfor (const [k, v] of Object.entries(propsOrDeferred)) {\n\t\t\t\tif (v instanceof DeferredProp) deferred[k] = v;\n\t\t\t\telse\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Inertia.render: 3-arg form expects the second argument to be a map of deferred props. ` +\n\t\t\t\t\t\t\t`Got non-deferred value at key \"${k}\".`,\n\t\t\t\t\t);\n\t\t\t}\n\t\t\treturn { component, props: { ...deferred, ...maybeProps } };\n\t\t}\n\n\t\t// 2-arg form: render(component, props) — helpers are left in place\n\t\t// so the response builder can recognize and resolve them.\n\t\treturn { component, props: propsOrDeferred ?? {} };\n\t}\n}\n\n// ============================================================================\n// Re-exports for convenience (so users can do `import { Inertia, defer }`)\n// ============================================================================\n\nexport {\n\tAlwaysProp,\n\tDeepMergeProp,\n\ttype DeferredProp,\n\tMergeProp,\n\tOptionalProp,\n\tOnceProp,\n\tannotateProps,\n\ttype isInertiaHelper,\n};\nexport type {\n\tAlwaysProp as AlwaysPropType,\n\tDeepMergeProp as DeepMergePropType,\n\tDeferredProp as DeferredPropType,\n\tMergeProp as MergePropType,\n\tOptionalProp as OptionalPropType,\n\tOnceProp as OncePropType,\n} from \"./helpers.js\";\n\nexport { InertiaResponse, INERTIA_RESPONSE_TAG };\n",
|
|
31
|
+
"/**\n * Component registry shared by all SSR adapters.\n *\n * Each SSR adapter (React, Vue, Svelte, Solid) needs to map an Inertia\n * component name (e.g. `\"Users/Index\"`) to a real component that can\n * be rendered server-side. The registry centralizes that mapping so\n * the same configuration works across adapters and so users can\n * register components once and reuse them across requests.\n *\n * The registry is intentionally framework-agnostic: it doesn't care\n * what a \"component\" actually is, only that the SSR adapter knows how\n * to render it.\n */\nexport class ComponentRegistry {\n\tprivate readonly map = new Map<string, any>();\n\n\t/**\n\t * Register a single component under `name`. Returns `this` so\n\t * registrations can be chained.\n\t */\n\tregister(name: string, component: any): this {\n\t\tthis.map.set(name, component);\n\t\treturn this;\n\t}\n\n\t/** Register a batch of components at once. */\n\tregisterAll(components: Record<string, any>): this {\n\t\tfor (const [name, component] of Object.entries(components)) {\n\t\t\tthis.map.set(name, component);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/** Look up a component by name. Returns `undefined` when missing. */\n\tresolve(name: string): any {\n\t\treturn this.map.get(name);\n\t}\n\n\t/** Whether the registry has a binding for `name`. */\n\thas(name: string): boolean {\n\t\treturn this.map.has(name);\n\t}\n\n\t/** Drop a binding. */\n\tunregister(name: string): boolean {\n\t\treturn this.map.delete(name);\n\t}\n\n\t/** List of all registered component names (for diagnostics). */\n\tnames(): string[] {\n\t\treturn [...this.map.keys()];\n\t}\n\n\t/** Total number of registered components. */\n\tget size(): number {\n\t\treturn this.map.size;\n\t}\n}\n\n/** Convenience factory. */\nexport function createRegistry(\n\tinitial?: Record<string, any>,\n): ComponentRegistry {\n\tconst reg = new ComponentRegistry();\n\tif (initial) reg.registerAll(initial);\n\treturn reg;\n}\n\n/**\n * Normalize the `components` option from any SSR adapter. Adapters\n * accept either an existing `ComponentRegistry` or a plain object\n * map; this helper unifies the two.\n */\nexport function asRegistry(\n\tinput: ComponentRegistry | Record<string, any>,\n): ComponentRegistry {\n\treturn input instanceof ComponentRegistry ? input : createRegistry(input);\n}\n",
|
|
32
|
+
"/**\n * SSR adapter barrel.\n *\n * Each adapter is loaded dynamically by the Inertia response when\n * SSR is needed. The framework core stays framework-agnostic; users\n * install only the frontend packages they actually use.\n */\nexport * from \"./registry.js\";\nexport * from \"./react-adapter.js\";\nexport * from \"./vue-adapter.js\";\nexport * from \"./svelte-adapter.js\";\nexport * from \"./solid-adapter.js\";\n",
|
|
33
|
+
"/**\n * Inertia adapter barrel.\n *\n * Public exports for the server-side Inertia.js v2/v3 adapter. The\n * adapter implements the Inertia protocol: JSON responses for XHR,\n * HTML shell with embedded page data for first-page loads, deferred /\n * merge / always / once / lazy prop helpers, asset versioning, shared\n * data, form helpers, and a pluggable SSR adapter interface.\n */\nexport * from \"./types.js\";\nexport * from \"./helpers.js\";\nexport * from \"./inertia-response.js\";\nexport * from \"./form-helper.js\";\nexport * from \"./form-middleware.js\";\nexport * from \"./inertia-adapter.js\";\nexport * from \"./default-ssr.js\";\nexport * from \"./ssr/index.js\";\n",
|
|
34
|
+
"/**\n * Application.\n *\n * The Application is the user-facing entry point: it owns the DI container,\n * the HTTP server, and the view engine. Typical bootstrap:\n *\n * ```ts\n * const app = await new Application(AppModule).bootstrap();\n * await app.listen(3000);\n * ```\n *\n * The class is intentionally small — every feature (DI, HTTP, ORM, view)\n * is a separate concern with its own module. Application composes them.\n */\nimport \"reflect-metadata\";\nimport { ApplicationContainer } from \"./di/container.js\";\nimport { ModuleScanner } from \"./di/scanner.js\";\nimport { NexusServer, type NexusServerOptions } from \"./http/server.js\";\nimport type { ViewAdapter } from \"../view/types.js\";\nimport { RenduAdapter } from \"../view/rendu.js\";\nimport { setViewPaths as setViewPathsModule } from \"../view/view-engine.js\";\nimport type { Type } from \"./di/tokens.js\";\nimport { Inertia, type InertiaConfig } from \"../view/inertia/index.js\";\n\nexport interface ApplicationOptions extends NexusServerOptions {\n\t/** Default view adapter. Defaults to Rendu. */\n\tviewAdapter?: ViewAdapter;\n\t/** Inertia configuration. If supplied, `app.inertia` is initialized. */\n\tinertia?: InertiaConfig;\n}\n\nexport class Application {\n\treadonly container: ApplicationContainer;\n\treadonly server: NexusServer;\n\t/** Inertia adapter (or `null` if not configured). Always defined after ctor. */\n\treadonly inertia: Inertia | null;\n\tprivate viewAdapter: ViewAdapter;\n\n\tconstructor(rootModule: Type<any>, options: ApplicationOptions = {}) {\n\t\t// Build the DI container and scan the module tree.\n\t\tthis.container = new ApplicationContainer();\n\t\tconst scanner = new ModuleScanner(this.container);\n\t\tconst { root, modules } = scanner.scan(rootModule);\n\n\t\t// Create the HTTP server around the same container.\n\t\tthis.server = new NexusServer(this.container, options);\n\n\t\t// Register all controllers from every scanned module.\n\t\tfor (const m of modules) {\n\t\t\tfor (const controller of m.controllers) {\n\t\t\t\tthis.server.router.registerController(controller, m.container);\n\t\t\t}\n\t\t}\n\t\t// Root module providers/controllers were already added in the scan.\n\t\tfor (const controller of root.controllers) {\n\t\t\tthis.server.router.registerController(controller, root.container);\n\t\t}\n\n\t\tthis.viewAdapter = options.viewAdapter ?? new RenduAdapter();\n\n\t\t// Initialize the Inertia adapter if configured. The instance is\n\t\t// also registered into the container under its symbol token so\n\t\t// controllers can inject it via `@Inject(Inertia.TOKEN)`.\n\t\tif (options.inertia) {\n\t\t\tthis.inertia = new Inertia(options.inertia);\n\t\t\tthis.container.register({\n\t\t\t\tprovide: Inertia.TOKEN,\n\t\t\t\tuseValue: this.inertia,\n\t\t\t});\n\t\t} else {\n\t\t\tthis.inertia = null;\n\t\t}\n\n\t\t// Auto-load nx.config.ts at boot so viewPaths (and future config)\n\t\t// take effect without an explicit app.setViewPaths() call.\n\t\tthis.tryLoadNxConfig();\n\n\t\t// Surface debug info in dev.\n\t\tif (process.env[\"NEXUS_DEBUG\"] === \"1\") {\n\t\t\tconsole.log(\"[nexus] Modules:\", modules.length);\n\t\t\tconsole.log(\n\t\t\t\t\"[nexus] Controllers:\",\n\t\t\t\tmodules.flatMap((m) => m.controllers).map((c) => c.name),\n\t\t\t);\n\t\t\tconsole.log(\"[nexus] Providers (root):\", this.container.list());\n\t\t\tconsole.log(\"[nexus] Inertia:\", this.inertia ? \"enabled\" : \"disabled\");\n\t\t}\n\t}\n\n\t/** Try to load nx.config.ts and apply runtime-relevant settings. */\n\tprivate tryLoadNxConfig(): void {\n\t\t// Bun provides require() even in ESM. On other runtimes (Node,\n\t\t// Cloudflare Workers) nx.config.ts may not be loadable — that's\n\t\t// fine, the user can set viewPaths explicitly via\n\t\t// app.setViewPaths().\n\t\tif (typeof require === \"undefined\") return;\n\t\ttry {\n\t\t\tconst mod = require(process.cwd() + \"/nx.config.ts\");\n\t\t\tconst cfg = mod.default ?? mod;\n\t\t\tif (cfg && typeof cfg.viewPaths === \"string\" && cfg.viewPaths.length > 0) {\n\t\t\t\tsetViewPathsModule(cfg.viewPaths);\n\t\t\t}\n\t\t} catch {\n\t\t\t// nx.config.ts not found or unparseable — that's fine.\n\t\t}\n\t}\n\n\t/** Replace the default view adapter. */\n\tsetViewAdapter(adapter: ViewAdapter): this {\n\t\tthis.viewAdapter = adapter;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set the directories to search when a controller returns\n\t * `{ view: 'about.html' }`. Defaults to `[]` (no file-based\n\t * views; controllers must pass inline template source).\n\t *\n\t * The Application auto-loads nx.config.ts at construction time, so if\n\t * you already set viewPaths there, no explicit call is needed.\n\t * This method exists to override the config-file value at runtime.\n\t *\n\t * Typical setup in nx.config.ts (auto-detected):\n\t *\n\t * export default {\n\t * view: 'rendu',\n\t * viewPaths: 'resources/views',\n\t * };\n\t *\n\t * After this, `@Get('/about') return { view: 'about.html', data }`\n\t * loads `views/about.html` from disk instead of treating the\n\t * string as inline template source.\n\t *\n\t * Edge-only runtimes (Cloudflare Workers) should leave this\n\t * empty and pass inline template strings.\n\t */\n\tsetViewPaths(path: string): this {\n\t\tsetViewPathsModule(path);\n\t\treturn this;\n\t}\n\n\t/** Render a view using the configured adapter. */\n\tasync render(view: string, data: Record<string, any> = {}): Promise<string> {\n\t\treturn this.viewAdapter.render(view, data);\n\t}\n\n\t/**\n\t * Convenience: start the server using the auto-detected runtime adapter.\n\t */\n\tasync listen(port?: number): Promise<any> {\n\t\tif (port) {\n\t\t\tthis.server.setPort(port);\n\t\t}\n\t\treturn this.server.start();\n\t}\n\n\t/**\n\t * For Cloudflare / Workers: return the fetch handler.\n\t */\n\tget fetch() {\n\t\treturn this.server.fetch;\n\t}\n\n\t/**\n\t * Static factory that mirrors the typical `bootstrap()` pattern.\n\t */\n\tstatic bootstrap(\n\t\trootModule: Type<any>,\n\t\toptions?: ApplicationOptions,\n\t): Application {\n\t\treturn new Application(rootModule, options);\n\t}\n}\n",
|
|
35
|
+
"/**\n * `nexusjs/view` — view engine adapter + file-based view loader.\n *\n * Public API:\n * - `renderView(template, data, context?)` — render a view.\n * If `template` ends in a known file extension (`.html`, `.edge`,\n * `.rendu`, `.eta`) AND `setViewPaths()` has been called, the\n * file is loaded from the first matching directory and used\n * as the template source. Otherwise the string is treated as\n * inline source.\n * The adapter is selected by file extension (or Rendu for\n * inline / non-extension values).\n * - `setViewPaths(path)` — configure the directory searched for\n * view files. Pass `\"\"` to disable.\n * - `getViewPaths()` — return the current path (empty = disabled).\n * - `loadTemplate(dir, name)` — low-level: load a file from\n * the given directory.\n * - `Application.setViewPaths(path)` — same as the module\n * function, but chainable.\n *\n * Adapters:\n * - RenduAdapter (default for `.html`/`.rendu`/inline)\n * - EdgeAdapter (for `.edge`)\n * - EtaAdapter (for `.eta`)\n *\n * Override with `app.setViewAdapter(new MyAdapter())` to install\n * a different engine globally.\n */\n\nexport type {\n\tViewAdapter,\n\tViewContext,\n\tViewOptions,\n} from \"./types.js\";\nexport { RenduAdapter } from \"./rendu.js\";\nexport { EdgeAdapter } from \"./edge.js\";\nexport { EtaAdapter } from \"./eta.js\";\nexport {\n\trenderView,\n\tloadTemplate,\n\tsetViewPaths,\n\tgetViewPaths,\n} from \"./view-engine.js\";\n",
|
|
36
|
+
"/**\n * Nexus — Bun Native Fullstack Framework.\n *\n * The public API. Users should import from `nexusjs` (this file), not from\n * deep paths, unless they specifically need advanced internals.\n */\nimport \"reflect-metadata\";\n\nexport * from \"./core/index.js\";\n\n// Default export is the Application class so it can be imported as\n// `import Nexus from 'nexusjs'` in addition to named imports.\nimport { Application } from \"./core/application.js\";\nexport default Application;\n",
|
|
37
|
+
"/**\n * @Module decorator.\n *\n * Marks a class as a Nest-style module: a logical grouping of\n * controllers and providers with explicit imports/exports.\n *\n * @example\n * ```ts\n * @Module({\n * imports: [UserModule],\n * controllers: [UserController],\n * providers: [UserService],\n * exports: [UserService],\n * })\n * class AppModule {}\n * ```\n */\nimport \"reflect-metadata\";\nimport { METADATA_KEY } from \"../constants.js\";\nimport type { ModuleOptions, Type } from \"../di/tokens.js\";\n\nexport function Module(options: ModuleOptions = {}): ClassDecorator {\n\treturn (target: object) => {\n\t\tReflect.defineMetadata(METADATA_KEY.MODULE, options, target);\n\t};\n}\n\n/** Read the @Module options from a class. */\nexport function getModuleOptions(target: Type<any>): ModuleOptions {\n\treturn Reflect.getMetadata(METADATA_KEY.MODULE, target) ?? {};\n}\n",
|
|
38
|
+
"/**\n * Convenience barrel for all decorators.\n */\nexport * from \"./module.js\";\nexport * from \"./controller.js\";\nexport * from \"./injectable.js\";\nexport * from \"./http-methods.js\";\nexport * from \"./params.js\";\nexport * from \"./validate.js\";\nexport * from \"./repository.js\";\nexport * from \"./metadata.js\";\n",
|
|
39
|
+
"/**\n * @Injectable decorator.\n *\n * Marks a class as available for DI. The container uses reflect-metadata's\n * `design:paramtypes` to read constructor parameter types and resolve them\n * automatically.\n *\n * @example\n * ```ts\n * @Injectable()\n * class UserService {\n * constructor(private repo: UserRepository) {}\n * }\n *\n * @Injectable({ scope: 'request' })\n * class RequestContext {\n * constructor(@Inject(REQUEST) private req: any) {}\n * }\n * ```\n */\nimport \"reflect-metadata\";\nimport { METADATA_KEY } from \"../constants.js\";\n\nexport interface InjectableOptions {\n\tscope?: \"singleton\" | \"request\" | \"transient\";\n}\n\nexport function Injectable(options: InjectableOptions = {}): ClassDecorator {\n\treturn (target: object) => {\n\t\tReflect.defineMetadata(METADATA_KEY.INJECTABLE, true, target);\n\t\tif (options.scope) {\n\t\t\tReflect.defineMetadata(\n\t\t\t\t\"nexus:di:scope\",\n\t\t\t\toptions.scope,\n\t\t\t\ttarget,\n\t\t\t);\n\t\t}\n\t};\n}\n\nexport function isInjectable(target: any): boolean {\n\treturn Reflect.hasMetadata(METADATA_KEY.INJECTABLE, target);\n}\n\n/**\n * Read the scope declared on a class via `@Injectable({ scope })`.\n * Returns undefined when no scope is declared (defaults to singleton).\n */\nexport function getScope(\n\ttarget: any,\n): \"singleton\" | \"request\" | \"transient\" | undefined {\n\treturn Reflect.getMetadata(\"nexus:di:scope\", target);\n}\n\n/**\n * Mark a parameter as resolved by a specific token instead of its declared\n * type. Useful for interfaces, abstract classes, or string tokens.\n *\n * @example\n * ```ts\n * constructor(@Inject('CONFIG') private config: AppConfig) {}\n * ```\n */\nexport function Inject<T = any>(token: any): ParameterDecorator {\n\treturn (\n\t\ttarget: object,\n\t\tpropertyKey: string | symbol | undefined,\n\t\tparameterIndex: number,\n\t) => {\n\t\tconst existing: Map<number, any> =\n\t\t\tReflect.getMetadata(METADATA_KEY.INJECT, target) ?? new Map();\n\t\texisting.set(parameterIndex, token);\n\t\tReflect.defineMetadata(METADATA_KEY.INJECT, existing, target);\n\t};\n}",
|
|
40
|
+
"/**\n * @Repository decorator.\n *\n * Marks a class as a Spring-style repository. Repositories are normal\n * `@Injectable()` classes; the decorator is a marker so the framework\n * can register them with a database adapter (Drizzle/Prisma) and emit\n * a friendly error if you forget to wire one.\n *\n * @example\n * ```ts\n * @Repository()\n * class UserRepository {\n * findAll() { return db.select().from(users); }\n * }\n * ```\n */\nimport \"reflect-metadata\";\nimport { METADATA_KEY } from \"../constants.js\";\nimport type { InjectionToken } from \"../di/tokens.js\";\n\nexport function Repository(entityToken?: InjectionToken<any>): ClassDecorator {\n\treturn (target: object) => {\n\t\tReflect.defineMetadata(\n\t\t\tMETADATA_KEY.REPOSITORY,\n\t\t\t{ entity: entityToken },\n\t\t\ttarget,\n\t\t);\n\t\tReflect.defineMetadata(METADATA_KEY.INJECTABLE, true, target);\n\t};\n}\n\nexport function getRepositoryMetadata(\n\ttarget: any,\n): { entity?: InjectionToken<any> } | undefined {\n\treturn Reflect.getMetadata(METADATA_KEY.REPOSITORY, target);\n}\n\nexport function isRepository(target: any): boolean {\n\treturn Reflect.hasMetadata(METADATA_KEY.REPOSITORY, target);\n}\n",
|
|
41
|
+
"/**\n * Reflect-metadata helper. Centralizes the keys the framework uses so\n * decorator files stay clean.\n */\nexport { METADATA_KEY, PARAM_TYPES, HTTP_METHODS } from \"../constants.js\";\nexport type { MetadataKey, ParamType, HttpMethod } from \"../constants.js\";\n",
|
|
42
|
+
"/**\n * DI barrel exports.\n */\nexport * from \"./tokens.js\";\nexport * from \"./container.js\";\nexport * from \"./scanner.js\";\nexport * from \"./request-scope.js\";\nexport { requestScopeMiddleware } from \"./request-middleware.js\";",
|
|
43
|
+
"/**\n * Framework context types.\n *\n * The HTTP layer is built on Hono, so the request handler receives a\n * Hono context (`c`) which exposes `c.req`, `c.res`, `c.json`, etc.\n *\n * The framework adds:\n * - `c.var.nexus` for framework-injected properties (current user,\n * container snapshot for the request, etc.)\n * - `NexusResponse` helpers for streaming views and returning view\n * objects in a uniform way.\n */\nimport type { Context as HonoContext, Next } from \"hono\";\nimport type { ApplicationContainer } from \"../di/container.js\";\n\nexport type NexusContext = HonoContext;\nexport type NexusNext = Next;\n\n/** Framework-specific data attached to Hono's `c.var`. */\nexport interface NexusContextVar {\n\t/** Root container available during the request lifetime. */\n\tcontainer: ApplicationContainer;\n\t/** Resolved authenticated user (filled by @Auth middleware). */\n\tuser?: any;\n\t/** Per-request state bag. */\n\tstate: Record<string, any>;\n\t/** Cached parsed body, validation result, etc. */\n\tcache: Map<string, any>;\n}\n\n/** Helper: typed access to `c.var.nexus`. */\nexport function getNexusVar(c: NexusContext): NexusContextVar {\n\t// Hono's `var` is open-ended; we cast to keep call sites clean.\n\treturn (c as any).var.nexus as NexusContextVar;\n}\n",
|
|
44
|
+
"/**\n * HTTP barrel exports.\n */\nexport * from \"./context.js\";\nexport * from \"./middleware.js\";\nexport * from \"./router.js\";\nexport * from \"./server.js\";\n",
|
|
45
|
+
"/**\n * Validation barrel.\n */\nexport * from \"./validator.js\";\n",
|
|
46
|
+
"/**\n * Drizzle ORM adapter.\n *\n * Provides a thin, opt-in integration with Drizzle. The framework does\n * not bundle Drizzle as a hard dependency — users install it on demand:\n *\n * bun add drizzle-orm\n *\n * The adapter exposes a `getDb(schema, client)` helper and a\n * `DrizzleModule` class that wires a Drizzle client into the DI container.\n *\n * The adapter intentionally stays small: full ORM ergonomics live in\n * Drizzle itself; the framework just integrates it.\n */\nimport type { DIContainer } from \"../di/container.js\";\n\n/** Minimal subset of Drizzle's API we care about. */\nexport interface DrizzleLike<Schema extends Record<string, any> = any> {\n\tselect: (...args: any[]) => any;\n\tinsert: (...args: any[]) => any;\n\tupdate: (...args: any[]) => any;\n\tdelete: (...args: any[]) => any;\n\tquery: Record<string, (...args: any[]) => any>;\n\tschema: Schema;\n}\n\n/** Database client options the adapter knows how to construct. */\nexport interface DrizzleConfig<Schema extends Record<string, any> = any> {\n\t/** Pre-built Drizzle instance. */\n\tinstance?: DrizzleLike<Schema>;\n\t/** Schema definition (passed to drizzle()). */\n\tschema?: Schema;\n\t/** Database client (any driver: bun:sqlite, pg, mysql2, etc.). */\n\tclient?: any;\n\t/** Drizzle driver factory, e.g. `drizzle` from drizzle-orm/bun-sqlite. */\n\tdriver?: (...args: any[]) => DrizzleLike<Schema>;\n}\n\n/**\n * Module that registers a Drizzle instance under a token. Use the\n * returned provider token with `@Inject()` to access the DB from services.\n *\n * @example\n * ```ts\n * const dbModule = new DrizzleModule('DB', {\n * schema,\n * driver: drizzle,\n * });\n *\n * @Module({ imports: [dbModule.asModule()] })\n * class UserModule {}\n * ```\n */\nexport class DrizzleModule<Schema extends Record<string, any> = any> {\n\treadonly token: string;\n\n\tconstructor(\n\t\ttoken: string = \"DB\",\n\t\tprivate config: DrizzleConfig<Schema>,\n\t) {\n\t\tthis.token = token;\n\t}\n\n\t/**\n\t * Build the actual Drizzle instance. Throws a helpful error if neither\n\t * a pre-built instance nor a driver+schema is configured.\n\t */\n\tbuild(): DrizzleLike<Schema> {\n\t\tif (this.config.instance) return this.config.instance;\n\t\tif (this.config.driver && this.config.schema) {\n\t\t\treturn this.config.driver({\n\t\t\t\tschema: this.config.schema,\n\t\t\t\tclient: this.config.client,\n\t\t\t});\n\t\t}\n\t\tthrow new Error(\n\t\t\t\"DrizzleModule requires either `instance` or `driver` + `schema` configuration.\",\n\t\t);\n\t}\n\n\t/**\n\t * Export a list of providers so users can drop this module into\n\t * `@Module({ imports: [...] })`. We return a synthetic class that the\n\t * module scanner recognises.\n\t */\n\tasModule() {\n\t\tconst token = this.token;\n\t\tconst builder = () => this.build();\n\t\t// Create an ad-hoc provider class so users can import it directly.\n\t\tclass DrizzleProvider {}\n\t\tObject.defineProperty(DrizzleProvider, \"name\", {\n\t\t\tvalue: `DrizzleProvider<${token}>`,\n\t\t});\n\t\treturn DrizzleProvider;\n\t}\n\n\t/** Register the Drizzle instance into a container manually. */\n\tregisterInto(container: DIContainer): void {\n\t\tcontainer.register({\n\t\t\tprovide: this.token,\n\t\t\tuseFactory: () => this.build(),\n\t\t});\n\t}\n}\n\n/** Convenience: build a Drizzle instance directly (used in tests and CLI). */\nexport async function getDb<Schema extends Record<string, any> = any>(\n\tconfig: DrizzleConfig<Schema>,\n): Promise<DrizzleLike<Schema>> {\n\tif (config.instance) return config.instance;\n\tif (config.driver && config.schema) {\n\t\treturn config.driver({ schema: config.schema, client: config.client });\n\t}\n\tthrow new Error(\n\t\t\"getDb requires either `instance` or `driver` + `schema` configuration.\",\n\t);\n}\n",
|
|
47
|
+
"/**\n * Runtime adapter barrel.\n *\n * These adapters are dynamic-imported by the server because they target\n * different runtimes; importing all of them at startup would pull in\n * Node-specific modules (http, etc.) on Cloudflare Workers, which fail.\n */\nexport * from \"./bun.js\";\nexport * from \"./node.js\";\nexport * from \"./cloudflare.js\";\n",
|
|
48
|
+
"/**\n * Nexus framework — public entry point.\n *\n * Re-exports the public surface of every core module so users can\n * `import { ... } from 'nexusjs'` without reaching into subpaths.\n *\n * Public surface intentionally stays small; advanced users can deep-import\n * from `nexusjs/core/<module>` for sub-paths.\n */\n\n// Decorators\nexport * from \"./decorators/index.js\";\n\n// DI\nexport * from \"./di/index.js\";\n\n// HTTP\nexport * from \"./http/index.js\";\n\n// Validation\nexport * from \"./validation/index.js\";\n\n// View\nexport * from \"../view/index.js\";\n\n// ORM\nexport * from \"./orm/index.js\";\n\n// Runtime adapters\nexport * from \"./runtime/index.js\";\n\n// Application\nexport { Application, type ApplicationOptions } from \"./application.js\";\n\n// Constants and types\nexport { METADATA_KEY, PARAM_TYPES, HTTP_METHODS } from \"./constants.js\";\nexport type { MetadataKey, ParamType, HttpMethod } from \"./constants.js\";\n"
|
|
49
|
+
],
|
|
50
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA;AAAA;AAGO,MAAM,aAAoC;AAAA,EACvC,OAAO;AAAA,EACR,QAAQ,IAAI;AAAA,EAEpB,MAAM,CACL,UACA,MACA,SACA,SACkB;AAAA,IASlB,MAAM,OAA4B,CAAC;AAAA,IACnC,YAAY,GAAG,MAAM,OAAO,QAAQ,IAAI,GAAG;AAAA,MAC1C,KAAK,KAAK,OAAO,MAAM,WAAW,IAAI,KAAK,OAAO,KAAK,OAAO,CAAC;AAAA,IAChE;AAAA,IACA,MAAM,SAAS,KAAK,UAAU,MAAM,SAAS,OAAO;AAAA,IACpD,OAAO,KAAK,YAAY,UAAU,OAAO,EAAE,MAAM;AAAA;AAAA,EAGlD,OAAO,CAAC,UAAkB,SAAuB;AAAA,IAChD,MAAM,WAAW,KAAK,YAAY,UAAU,OAAO;AAAA,IACnD,OAAO,CAAC,SAA8B,SAAS,IAAI;AAAA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A,EACnC,IAAI,OAAO,UAAU,OAAO,QAAQ;AAAA,IACnC,OAAO,OAAO,OAAO,EAAE,QAAQ,OAAO,QAAQ,QAAQ,OAAO,OAAO,CAAC;AAAA,EACtE;AAAA,EACA,MAAM,IAAI,MACT,wEACD;AAAA;;AC3GD;;;ACwBA;AAGA;;;AZvBA;AACA,IAAe;",
|
|
51
|
+
"debugId": "ABDC5E0F1A95E8AD64756E2164756E21",
|
|
52
|
+
"names": []
|
|
53
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `DrizzleRateLimitStorage` — rate-limit state in any Drizzle-backed DB.
|
|
3
|
+
*
|
|
4
|
+
* import { DrizzleService } from 'nexusjs/drizzle';
|
|
5
|
+
* import { DrizzleRateLimitStorage } from 'nexusjs/limiter';
|
|
6
|
+
*
|
|
7
|
+
* const db = new DrizzleService({ dialect: 'postgres', connection: { ... } });
|
|
8
|
+
* await db.open();
|
|
9
|
+
* const storage = new DrizzleRateLimitStorage(db, { tableName: 'nexus_rate_limits' });
|
|
10
|
+
*
|
|
11
|
+
* LimiterModule.forRoot({ storage, rules: [...] });
|
|
12
|
+
*
|
|
13
|
+
* Schema:
|
|
14
|
+
* CREATE TABLE nexus_rate_limits (
|
|
15
|
+
* key TEXT PRIMARY KEY,
|
|
16
|
+
* strategy TEXT NOT NULL,
|
|
17
|
+
* limit INTEGER NOT NULL,
|
|
18
|
+
* points INTEGER NOT NULL DEFAULT 0,
|
|
19
|
+
* reset_at TIMESTAMP NOT NULL,
|
|
20
|
+
* log JSONB
|
|
21
|
+
* );
|
|
22
|
+
*
|
|
23
|
+
* Atomicity: each `consume()` runs inside a transaction. The
|
|
24
|
+
* counter-update + log-trim happens as a single SQL statement
|
|
25
|
+
* (UPDATE with `WHERE` guard) so concurrent callers are safe.
|
|
26
|
+
*/
|
|
27
|
+
import type { DrizzleService } from "../../drizzle/drizzle.service.js";
|
|
28
|
+
import type { RateLimitKey, RateLimitResult, RateLimitStorage, RateLimitStrategy } from "../types.js";
|
|
29
|
+
export interface DrizzleRateLimitOptions {
|
|
30
|
+
db: DrizzleService;
|
|
31
|
+
tableName?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare class DrizzleRateLimitStorage implements RateLimitStorage {
|
|
34
|
+
#private;
|
|
35
|
+
readonly kind: "drizzle";
|
|
36
|
+
constructor(db: DrizzleService, options?: Omit<DrizzleRateLimitOptions, "db">);
|
|
37
|
+
consume(key: RateLimitKey, points: number, limit: number, durationMs: number, strategy?: RateLimitStrategy): Promise<RateLimitResult>;
|
|
38
|
+
reset(key: RateLimitKey): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=drizzle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drizzle.d.ts","sourceRoot":"","sources":["../../../src/limiter/backends/drizzle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EACX,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,uBAAuB;IACvC,EAAE,EAAE,cAAc,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAYD,qBAAa,uBAAwB,YAAW,gBAAgB;;IAC/D,QAAQ,CAAC,IAAI,EAAG,SAAS,CAAU;gBAMlC,EAAE,EAAE,cAAc,EAClB,OAAO,GAAE,IAAI,CAAC,uBAAuB,EAAE,IAAI,CAAM;IAM5C,OAAO,CACZ,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,iBAAoC,GAC5C,OAAO,CAAC,eAAe,CAAC;IAiDrB,KAAK,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CAwF7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/limiter/backends/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACN,uBAAuB,EACvB,KAAK,uBAAuB,GAC5B,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory rate-limit storage. Sliding-window log by default.
|
|
3
|
+
*
|
|
4
|
+
* - `fixed-window`: counter reset every `durationMs` ms.
|
|
5
|
+
* - `sliding-window`: counts requests in the trailing `durationMs` window.
|
|
6
|
+
* - `token-bucket`: refills at `points / durationMs` tokens per ms.
|
|
7
|
+
*
|
|
8
|
+
* Not cluster-safe. For multi-pod deployments use `RedisStorage`.
|
|
9
|
+
*/
|
|
10
|
+
import type { RateLimitStorage, RateLimitKey, RateLimitStrategy } from "../types.js";
|
|
11
|
+
export declare class MemoryRateLimitStorage implements RateLimitStorage {
|
|
12
|
+
readonly kind: "memory";
|
|
13
|
+
private fixed;
|
|
14
|
+
private sliding;
|
|
15
|
+
private token;
|
|
16
|
+
consume(key: RateLimitKey, points: number, limit: number, durationMs: number, strategy?: RateLimitStrategy): Promise<{
|
|
17
|
+
allowed: boolean;
|
|
18
|
+
remaining: number;
|
|
19
|
+
limit: number;
|
|
20
|
+
resetAt: number;
|
|
21
|
+
retryAfter: number;
|
|
22
|
+
}>;
|
|
23
|
+
reset(key: RateLimitKey): Promise<void>;
|
|
24
|
+
private consumeFixed;
|
|
25
|
+
private consumeSliding;
|
|
26
|
+
private consumeToken;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/limiter/backends/memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EACX,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,MAAM,aAAa,CAAC;AAgBrB,qBAAa,sBAAuB,YAAW,gBAAgB;IAC9D,QAAQ,CAAC,IAAI,EAAG,QAAQ,CAAU;IAClC,OAAO,CAAC,KAAK,CAAwC;IACrD,OAAO,CAAC,OAAO,CAAuC;IACtD,OAAO,CAAC,KAAK,CAAwC;IAE/C,OAAO,CACZ,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,iBAAoC;;;;;;;IAkBzC,KAAK,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAM7C,OAAO,CAAC,YAAY;IAuBpB,OAAO,CAAC,cAAc;IA8BtB,OAAO,CAAC,YAAY;CA6BpB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point for `nexusjs/limiter`.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
export { MemoryRateLimitStorage } from "./backends/index.js";
|
|
6
|
+
export { LimiterService } from "./limiter.service.js";
|
|
7
|
+
export { LimiterMiddleware } from "./limiter.middleware.js";
|
|
8
|
+
export { LimiterModule } from "./limiter.module.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/limiter/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
|