@buenojs/bueno 0.8.5 → 0.8.7
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/.claude/settings.local.json +9 -0
- package/README.md +259 -15
- package/dist/cache/index.d.ts +187 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cli/bin.d.ts +8 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +484 -156
- package/dist/cli/commands/add-frontend.d.ts +7 -0
- package/dist/cli/commands/add-frontend.d.ts.map +1 -0
- package/dist/cli/commands/build.d.ts +7 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/dev.d.ts +7 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/generate.d.ts +7 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/help.d.ts +7 -0
- package/dist/cli/commands/help.d.ts.map +1 -0
- package/dist/cli/commands/index.d.ts +59 -0
- package/dist/cli/commands/index.d.ts.map +1 -0
- package/dist/cli/commands/migration.d.ts +7 -0
- package/dist/cli/commands/migration.d.ts.map +1 -0
- package/dist/cli/commands/new.d.ts +7 -0
- package/dist/cli/commands/new.d.ts.map +1 -0
- package/dist/cli/commands/start.d.ts +7 -0
- package/dist/cli/commands/start.d.ts.map +1 -0
- package/dist/cli/core/args.d.ts +61 -0
- package/dist/cli/core/args.d.ts.map +1 -0
- package/dist/cli/core/console.d.ts +135 -0
- package/dist/cli/core/console.d.ts.map +1 -0
- package/dist/cli/core/index.d.ts +10 -0
- package/dist/cli/core/index.d.ts.map +1 -0
- package/dist/cli/core/prompt.d.ts +63 -0
- package/dist/cli/core/prompt.d.ts.map +1 -0
- package/dist/cli/core/spinner.d.ts +111 -0
- package/dist/cli/core/spinner.d.ts.map +1 -0
- package/dist/cli/index.d.ts +47 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/templates/database/index.d.ts +24 -0
- package/dist/cli/templates/database/index.d.ts.map +1 -0
- package/dist/cli/templates/database/mysql.d.ts +6 -0
- package/dist/cli/templates/database/mysql.d.ts.map +1 -0
- package/dist/cli/templates/database/none.d.ts +8 -0
- package/dist/cli/templates/database/none.d.ts.map +1 -0
- package/dist/cli/templates/database/postgresql.d.ts +6 -0
- package/dist/cli/templates/database/postgresql.d.ts.map +1 -0
- package/dist/cli/templates/database/sqlite.d.ts +6 -0
- package/dist/cli/templates/database/sqlite.d.ts.map +1 -0
- package/dist/cli/templates/deploy.d.ts +41 -0
- package/dist/cli/templates/deploy.d.ts.map +1 -0
- package/dist/cli/templates/docker.d.ts +30 -0
- package/dist/cli/templates/docker.d.ts.map +1 -0
- package/dist/cli/templates/frontend/index.d.ts +25 -0
- package/dist/cli/templates/frontend/index.d.ts.map +1 -0
- package/dist/cli/templates/frontend/none.d.ts +8 -0
- package/dist/cli/templates/frontend/none.d.ts.map +1 -0
- package/dist/cli/templates/frontend/react.d.ts +6 -0
- package/dist/cli/templates/frontend/react.d.ts.map +1 -0
- package/dist/cli/templates/frontend/solid.d.ts +6 -0
- package/dist/cli/templates/frontend/solid.d.ts.map +1 -0
- package/dist/cli/templates/frontend/svelte.d.ts +6 -0
- package/dist/cli/templates/frontend/svelte.d.ts.map +1 -0
- package/dist/cli/templates/frontend/vue.d.ts +6 -0
- package/dist/cli/templates/frontend/vue.d.ts.map +1 -0
- package/dist/cli/templates/generators/index.d.ts +29 -0
- package/dist/cli/templates/generators/index.d.ts.map +1 -0
- package/dist/cli/templates/generators/types.d.ts +32 -0
- package/dist/cli/templates/generators/types.d.ts.map +1 -0
- package/dist/cli/templates/index.d.ts +12 -0
- package/dist/cli/templates/index.d.ts.map +1 -0
- package/dist/cli/templates/project/api.d.ts +6 -0
- package/dist/cli/templates/project/api.d.ts.map +1 -0
- package/dist/cli/templates/project/default.d.ts +6 -0
- package/dist/cli/templates/project/default.d.ts.map +1 -0
- package/dist/cli/templates/project/fullstack.d.ts +14 -0
- package/dist/cli/templates/project/fullstack.d.ts.map +1 -0
- package/dist/cli/templates/project/index.d.ts +26 -0
- package/dist/cli/templates/project/index.d.ts.map +1 -0
- package/dist/cli/templates/project/minimal.d.ts +6 -0
- package/dist/cli/templates/project/minimal.d.ts.map +1 -0
- package/dist/cli/templates/project/types.d.ts +80 -0
- package/dist/cli/templates/project/types.d.ts.map +1 -0
- package/dist/cli/templates/project/website.d.ts +8 -0
- package/dist/cli/templates/project/website.d.ts.map +1 -0
- package/dist/cli/utils/fs.d.ts +137 -0
- package/dist/cli/utils/fs.d.ts.map +1 -0
- package/dist/cli/utils/index.d.ts +9 -0
- package/dist/cli/utils/index.d.ts.map +1 -0
- package/dist/cli/utils/strings.d.ts +86 -0
- package/dist/cli/utils/strings.d.ts.map +1 -0
- package/dist/cli/utils/version.d.ts +15 -0
- package/dist/cli/utils/version.d.ts.map +1 -0
- package/dist/config/env-validation.d.ts +49 -0
- package/dist/config/env-validation.d.ts.map +1 -0
- package/dist/config/env.d.ts +167 -0
- package/dist/config/env.d.ts.map +1 -0
- package/dist/config/index.d.ts +168 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/loader.d.ts +81 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/merge.d.ts +66 -0
- package/dist/config/merge.d.ts.map +1 -0
- package/dist/config/types.d.ts +322 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/validation.d.ts +100 -0
- package/dist/config/validation.d.ts.map +1 -0
- package/dist/container/forward-ref.d.ts +116 -0
- package/dist/container/forward-ref.d.ts.map +1 -0
- package/dist/container/index.d.ts +95 -0
- package/dist/container/index.d.ts.map +1 -0
- package/dist/container/index.js +26 -3
- package/dist/context/index.d.ts +143 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/database/index.d.ts +219 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/migrations/index.d.ts +146 -0
- package/dist/database/migrations/index.d.ts.map +1 -0
- package/dist/database/orm/builder.d.ts +122 -0
- package/dist/database/orm/builder.d.ts.map +1 -0
- package/dist/database/orm/casts/index.d.ts +16 -0
- package/dist/database/orm/casts/index.d.ts.map +1 -0
- package/dist/database/orm/casts/types.d.ts +16 -0
- package/dist/database/orm/casts/types.d.ts.map +1 -0
- package/dist/database/orm/compiler.d.ts +90 -0
- package/dist/database/orm/compiler.d.ts.map +1 -0
- package/dist/database/orm/hooks/index.d.ts +53 -0
- package/dist/database/orm/hooks/index.d.ts.map +1 -0
- package/dist/database/orm/index.d.ts +21 -0
- package/dist/database/orm/index.d.ts.map +1 -0
- package/dist/database/orm/model-registry.d.ts +33 -0
- package/dist/database/orm/model-registry.d.ts.map +1 -0
- package/dist/database/orm/model.d.ts +245 -0
- package/dist/database/orm/model.d.ts.map +1 -0
- package/dist/database/orm/relationships/base.d.ts +69 -0
- package/dist/database/orm/relationships/base.d.ts.map +1 -0
- package/dist/database/orm/relationships/belongs-to-many.d.ts +47 -0
- package/dist/database/orm/relationships/belongs-to-many.d.ts.map +1 -0
- package/dist/database/orm/relationships/belongs-to.d.ts +17 -0
- package/dist/database/orm/relationships/belongs-to.d.ts.map +1 -0
- package/dist/database/orm/relationships/has-many.d.ts +14 -0
- package/dist/database/orm/relationships/has-many.d.ts.map +1 -0
- package/dist/database/orm/relationships/has-one.d.ts +14 -0
- package/dist/database/orm/relationships/has-one.d.ts.map +1 -0
- package/dist/database/orm/relationships/index.d.ts +10 -0
- package/dist/database/orm/relationships/index.d.ts.map +1 -0
- package/dist/database/orm/scopes/index.d.ts +36 -0
- package/dist/database/orm/scopes/index.d.ts.map +1 -0
- package/dist/database/schema/index.d.ts +155 -0
- package/dist/database/schema/index.d.ts.map +1 -0
- package/dist/events/__tests__/event-system.test.d.ts +2 -0
- package/dist/events/__tests__/event-system.test.d.ts.map +1 -0
- package/dist/events/config.d.ts +16 -0
- package/dist/events/config.d.ts.map +1 -0
- package/dist/events/example-usage.d.ts +12 -0
- package/dist/events/example-usage.d.ts.map +1 -0
- package/dist/events/index.d.ts +27 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/manager.d.ts +33 -0
- package/dist/events/manager.d.ts.map +1 -0
- package/dist/events/registry.d.ts +31 -0
- package/dist/events/registry.d.ts.map +1 -0
- package/dist/events/types.d.ts +105 -0
- package/dist/events/types.d.ts.map +1 -0
- package/dist/frontend/api-routes.d.ts +189 -0
- package/dist/frontend/api-routes.d.ts.map +1 -0
- package/dist/frontend/bundler.d.ts +99 -0
- package/dist/frontend/bundler.d.ts.map +1 -0
- package/dist/frontend/console-client.d.ts +11 -0
- package/dist/frontend/console-client.d.ts.map +1 -0
- package/dist/frontend/console-stream.d.ts +138 -0
- package/dist/frontend/console-stream.d.ts.map +1 -0
- package/dist/frontend/dev-server.d.ts +174 -0
- package/dist/frontend/dev-server.d.ts.map +1 -0
- package/dist/frontend/file-router.d.ts +170 -0
- package/dist/frontend/file-router.d.ts.map +1 -0
- package/dist/frontend/frameworks/index.d.ts +41 -0
- package/dist/frontend/frameworks/index.d.ts.map +1 -0
- package/dist/frontend/frameworks/react.d.ts +32 -0
- package/dist/frontend/frameworks/react.d.ts.map +1 -0
- package/dist/frontend/frameworks/solid.d.ts +42 -0
- package/dist/frontend/frameworks/solid.d.ts.map +1 -0
- package/dist/frontend/frameworks/svelte.d.ts +57 -0
- package/dist/frontend/frameworks/svelte.d.ts.map +1 -0
- package/dist/frontend/frameworks/vue.d.ts +36 -0
- package/dist/frontend/frameworks/vue.d.ts.map +1 -0
- package/dist/frontend/hmr-client.d.ts +22 -0
- package/dist/frontend/hmr-client.d.ts.map +1 -0
- package/dist/frontend/hmr.d.ts +185 -0
- package/dist/frontend/hmr.d.ts.map +1 -0
- package/dist/frontend/index.d.ts +34 -0
- package/dist/frontend/index.d.ts.map +1 -0
- package/dist/frontend/islands.d.ts +135 -0
- package/dist/frontend/islands.d.ts.map +1 -0
- package/dist/frontend/isr.d.ts +143 -0
- package/dist/frontend/isr.d.ts.map +1 -0
- package/dist/frontend/layout.d.ts +140 -0
- package/dist/frontend/layout.d.ts.map +1 -0
- package/dist/frontend/ssr/react.d.ts +118 -0
- package/dist/frontend/ssr/react.d.ts.map +1 -0
- package/dist/frontend/ssr/solid.d.ts +141 -0
- package/dist/frontend/ssr/solid.d.ts.map +1 -0
- package/dist/frontend/ssr/svelte.d.ts +158 -0
- package/dist/frontend/ssr/svelte.d.ts.map +1 -0
- package/dist/frontend/ssr/vue.d.ts +161 -0
- package/dist/frontend/ssr/vue.d.ts.map +1 -0
- package/dist/frontend/ssr.d.ts +147 -0
- package/dist/frontend/ssr.d.ts.map +1 -0
- package/dist/frontend/types.d.ts +1902 -0
- package/dist/frontend/types.d.ts.map +1 -0
- package/dist/graphql/built-in-engine.d.ts +36 -0
- package/dist/graphql/built-in-engine.d.ts.map +1 -0
- package/dist/graphql/context-builder.d.ts +44 -0
- package/dist/graphql/context-builder.d.ts.map +1 -0
- package/dist/graphql/decorators.d.ts +162 -0
- package/dist/graphql/decorators.d.ts.map +1 -0
- package/dist/graphql/execution-pipeline.d.ts +67 -0
- package/dist/graphql/execution-pipeline.d.ts.map +1 -0
- package/dist/graphql/graphql-module.d.ts +70 -0
- package/dist/graphql/graphql-module.d.ts.map +1 -0
- package/dist/graphql/index.d.ts +48 -0
- package/dist/graphql/index.d.ts.map +1 -0
- package/dist/graphql/index.js +2156 -0
- package/dist/graphql/metadata.d.ts +37 -0
- package/dist/graphql/metadata.d.ts.map +1 -0
- package/dist/graphql/schema-builder.d.ts +34 -0
- package/dist/graphql/schema-builder.d.ts.map +1 -0
- package/dist/graphql/subscription-handler.d.ts +47 -0
- package/dist/graphql/subscription-handler.d.ts.map +1 -0
- package/dist/graphql/types.d.ts +252 -0
- package/dist/graphql/types.d.ts.map +1 -0
- package/dist/health/index.d.ts +176 -0
- package/dist/health/index.d.ts.map +1 -0
- package/dist/i18n/engine.d.ts +105 -0
- package/dist/i18n/engine.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +13 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/loader.d.ts +79 -0
- package/dist/i18n/loader.d.ts.map +1 -0
- package/dist/i18n/middleware.d.ts +96 -0
- package/dist/i18n/middleware.d.ts.map +1 -0
- package/dist/i18n/negotiator.d.ts +84 -0
- package/dist/i18n/negotiator.d.ts.map +1 -0
- package/dist/i18n/types.d.ts +129 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +520 -434
- package/dist/jobs/drivers/memory.d.ts +38 -0
- package/dist/jobs/drivers/memory.d.ts.map +1 -0
- package/dist/jobs/drivers/redis.d.ts +34 -0
- package/dist/jobs/drivers/redis.d.ts.map +1 -0
- package/dist/jobs/index.d.ts +12 -0
- package/dist/jobs/index.d.ts.map +1 -0
- package/dist/jobs/queue.d.ts +93 -0
- package/dist/jobs/queue.d.ts.map +1 -0
- package/dist/jobs/types.d.ts +193 -0
- package/dist/jobs/types.d.ts.map +1 -0
- package/dist/jobs/worker.d.ts +91 -0
- package/dist/jobs/worker.d.ts.map +1 -0
- package/dist/lock/index.d.ts +141 -0
- package/dist/lock/index.d.ts.map +1 -0
- package/dist/logger/index.d.ts +156 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/transports/index.d.ts +371 -0
- package/dist/logger/transports/index.d.ts.map +1 -0
- package/dist/metrics/index.d.ts +163 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/middleware/built-in.d.ts +50 -0
- package/dist/middleware/built-in.d.ts.map +1 -0
- package/dist/middleware/index.d.ts +40 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/migrations/index.d.ts +10 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/modules/filters.d.ts +150 -0
- package/dist/modules/filters.d.ts.map +1 -0
- package/dist/modules/guards.d.ts +188 -0
- package/dist/modules/guards.d.ts.map +1 -0
- package/dist/modules/index.d.ts +266 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js +514 -449
- package/dist/modules/interceptors.d.ts +242 -0
- package/dist/modules/interceptors.d.ts.map +1 -0
- package/dist/modules/lazy.d.ts +187 -0
- package/dist/modules/lazy.d.ts.map +1 -0
- package/dist/modules/lifecycle.d.ts +221 -0
- package/dist/modules/lifecycle.d.ts.map +1 -0
- package/dist/modules/metadata.d.ts +32 -0
- package/dist/modules/metadata.d.ts.map +1 -0
- package/dist/modules/pipes.d.ts +287 -0
- package/dist/modules/pipes.d.ts.map +1 -0
- package/dist/notification/channels/base.d.ts +32 -0
- package/dist/notification/channels/base.d.ts.map +1 -0
- package/dist/notification/channels/email.d.ts +37 -0
- package/dist/notification/channels/email.d.ts.map +1 -0
- package/dist/notification/channels/push.d.ts +37 -0
- package/dist/notification/channels/push.d.ts.map +1 -0
- package/dist/notification/channels/sms.d.ts +37 -0
- package/dist/notification/channels/sms.d.ts.map +1 -0
- package/dist/notification/channels/whatsapp.d.ts +37 -0
- package/dist/notification/channels/whatsapp.d.ts.map +1 -0
- package/dist/notification/index.d.ts +15 -0
- package/dist/notification/index.d.ts.map +1 -0
- package/dist/notification/service.d.ts +100 -0
- package/dist/notification/service.d.ts.map +1 -0
- package/dist/notification/types.d.ts +253 -0
- package/dist/notification/types.d.ts.map +1 -0
- package/dist/observability/__tests__/observability.test.d.ts +2 -0
- package/dist/observability/__tests__/observability.test.d.ts.map +1 -0
- package/dist/observability/breadcrumbs.d.ts +48 -0
- package/dist/observability/breadcrumbs.d.ts.map +1 -0
- package/dist/observability/index.d.ts +95 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/interceptor.d.ts +19 -0
- package/dist/observability/interceptor.d.ts.map +1 -0
- package/dist/observability/service.d.ts +101 -0
- package/dist/observability/service.d.ts.map +1 -0
- package/dist/observability/trace.d.ts +21 -0
- package/dist/observability/trace.d.ts.map +1 -0
- package/dist/observability/types.d.ts +172 -0
- package/dist/observability/types.d.ts.map +1 -0
- package/dist/openapi/__tests__/decorators.test.d.ts +2 -0
- package/dist/openapi/__tests__/decorators.test.d.ts.map +1 -0
- package/dist/openapi/__tests__/document-builder.test.d.ts +2 -0
- package/dist/openapi/__tests__/document-builder.test.d.ts.map +1 -0
- package/dist/openapi/__tests__/route-scanner.test.d.ts +2 -0
- package/dist/openapi/__tests__/route-scanner.test.d.ts.map +1 -0
- package/dist/openapi/__tests__/schema-generator.test.d.ts +2 -0
- package/dist/openapi/__tests__/schema-generator.test.d.ts.map +1 -0
- package/dist/openapi/decorators.d.ts +173 -0
- package/dist/openapi/decorators.d.ts.map +1 -0
- package/dist/openapi/document-builder.d.ts +82 -0
- package/dist/openapi/document-builder.d.ts.map +1 -0
- package/dist/openapi/index.d.ts +48 -0
- package/dist/openapi/index.d.ts.map +1 -0
- package/dist/openapi/index.js +59 -40
- package/dist/openapi/metadata.d.ts +36 -0
- package/dist/openapi/metadata.d.ts.map +1 -0
- package/dist/openapi/route-scanner.d.ts +34 -0
- package/dist/openapi/route-scanner.d.ts.map +1 -0
- package/dist/openapi/schema-generator.d.ts +53 -0
- package/dist/openapi/schema-generator.d.ts.map +1 -0
- package/dist/openapi/swagger-module.d.ts +57 -0
- package/dist/openapi/swagger-module.d.ts.map +1 -0
- package/dist/openapi/types.d.ts +344 -0
- package/dist/openapi/types.d.ts.map +1 -0
- package/dist/orm/index.d.ts +10 -0
- package/dist/orm/index.d.ts.map +1 -0
- package/dist/router/index.d.ts +73 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/linear.d.ts +54 -0
- package/dist/router/linear.d.ts.map +1 -0
- package/dist/router/regex.d.ts +49 -0
- package/dist/router/regex.d.ts.map +1 -0
- package/dist/router/tree.d.ts +112 -0
- package/dist/router/tree.d.ts.map +1 -0
- package/dist/rpc/index.d.ts +321 -0
- package/dist/rpc/index.d.ts.map +1 -0
- package/dist/schema/index.d.ts +10 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/security/index.d.ts +126 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/ssg/index.d.ts +73 -0
- package/dist/ssg/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +99 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/telemetry/index.d.ts +376 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/template/index.d.ts +7 -0
- package/dist/template/index.d.ts.map +1 -0
- package/dist/templates/engine.d.ts +60 -0
- package/dist/templates/engine.d.ts.map +1 -0
- package/dist/templates/index.d.ts +9 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/loader.d.ts +45 -0
- package/dist/templates/loader.d.ts.map +1 -0
- package/dist/templates/renderers/markdown.d.ts +46 -0
- package/dist/templates/renderers/markdown.d.ts.map +1 -0
- package/dist/templates/renderers/simple.d.ts +35 -0
- package/dist/templates/renderers/simple.d.ts.map +1 -0
- package/dist/templates/types.d.ts +138 -0
- package/dist/templates/types.d.ts.map +1 -0
- package/dist/testing/index.d.ts +539 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +116 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/validation/index.d.ts +89 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/schemas.d.ts +243 -0
- package/dist/validation/schemas.d.ts.map +1 -0
- package/dist/websocket/index.d.ts +252 -0
- package/dist/websocket/index.d.ts.map +1 -0
- package/llms.txt +231 -0
- package/package.json +6 -2
- package/src/cli/ARCHITECTURE.md +3 -3
- package/src/cli/commands/add-frontend.ts +444 -0
- package/src/cli/commands/new.ts +23 -0
- package/src/cli/index.ts +1 -0
- package/src/cli/templates/frontend/react.ts +2 -1
- package/src/cli/templates/frontend/solid.ts +2 -1
- package/src/cli/templates/frontend/svelte.ts +2 -1
- package/src/cli/templates/frontend/vue.ts +2 -1
- package/src/cli/templates/project/api.ts +1 -1
- package/src/cli/templates/project/default.ts +1 -1
- package/src/cli/templates/project/fullstack.ts +14 -104
- package/src/cli/templates/project/website.ts +63 -12
- package/src/config/types.ts +21 -0
- package/src/graphql/built-in-engine.ts +598 -0
- package/src/graphql/context-builder.ts +110 -0
- package/src/graphql/decorators.ts +358 -0
- package/src/graphql/execution-pipeline.ts +227 -0
- package/src/graphql/graphql-module.ts +563 -0
- package/src/graphql/index.ts +101 -0
- package/src/graphql/metadata.ts +237 -0
- package/src/graphql/schema-builder.ts +319 -0
- package/src/graphql/subscription-handler.ts +283 -0
- package/src/graphql/types.ts +324 -0
- package/src/index.ts +3 -0
- package/src/modules/index.ts +48 -1
- package/tests/integration/cli.test.ts +19 -19
- package/tests/unit/cli.test.ts +1 -1
- package/tests/unit/graphql.test.ts +991 -0
- package/tsconfig.declaration.json +14 -0
package/dist/modules/index.js
CHANGED
|
@@ -26,6 +26,237 @@ var __legacyMetadataTS = (k, v) => {
|
|
|
26
26
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
27
27
|
var __require = import.meta.require;
|
|
28
28
|
|
|
29
|
+
// src/container/forward-ref.ts
|
|
30
|
+
function forwardRef(fn) {
|
|
31
|
+
return {
|
|
32
|
+
__forwardRef: FORWARD_REF_SYMBOL,
|
|
33
|
+
forwardRef: fn
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function isForwardRef(value) {
|
|
37
|
+
return typeof value === "object" && value !== null && "__forwardRef" in value && "forwardRef" in value && typeof value.forwardRef === "function";
|
|
38
|
+
}
|
|
39
|
+
function resolveForwardRef(ref) {
|
|
40
|
+
if (isForwardRef(ref)) {
|
|
41
|
+
return ref.forwardRef();
|
|
42
|
+
}
|
|
43
|
+
return ref;
|
|
44
|
+
}
|
|
45
|
+
var FORWARD_REF_SYMBOL;
|
|
46
|
+
var init_forward_ref = __esm(() => {
|
|
47
|
+
FORWARD_REF_SYMBOL = Symbol.for("buno.forwardRef");
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// src/container/index.ts
|
|
51
|
+
var exports_container = {};
|
|
52
|
+
__export(exports_container, {
|
|
53
|
+
setContainerMetadata: () => setContainerMetadata,
|
|
54
|
+
resolveForwardRef: () => resolveForwardRef,
|
|
55
|
+
isForwardRef: () => isForwardRef,
|
|
56
|
+
getInjectTokens: () => getContainerMetadata,
|
|
57
|
+
getContainerMetadata: () => getContainerMetadata,
|
|
58
|
+
forwardRef: () => forwardRef,
|
|
59
|
+
createToken: () => createToken,
|
|
60
|
+
Token: () => Token,
|
|
61
|
+
Injectable: () => Injectable,
|
|
62
|
+
Inject: () => Inject,
|
|
63
|
+
Container: () => Container2
|
|
64
|
+
});
|
|
65
|
+
function createToken(description) {
|
|
66
|
+
return Symbol(description);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
class ResolutionStack {
|
|
70
|
+
stack = new Set;
|
|
71
|
+
lazyResolutions = new Map;
|
|
72
|
+
push(token) {
|
|
73
|
+
if (this.stack.has(token)) {
|
|
74
|
+
throw new Error("Circular dependency detected: Token already in resolution stack");
|
|
75
|
+
}
|
|
76
|
+
this.stack.add(token);
|
|
77
|
+
}
|
|
78
|
+
pop(token) {
|
|
79
|
+
this.stack.delete(token);
|
|
80
|
+
}
|
|
81
|
+
has(token) {
|
|
82
|
+
return this.stack.has(token);
|
|
83
|
+
}
|
|
84
|
+
markLazy(token, placeholder) {
|
|
85
|
+
this.lazyResolutions.set(token, placeholder);
|
|
86
|
+
}
|
|
87
|
+
hasLazy(token) {
|
|
88
|
+
return this.lazyResolutions.has(token);
|
|
89
|
+
}
|
|
90
|
+
getLazy(token) {
|
|
91
|
+
return this.lazyResolutions.get(token);
|
|
92
|
+
}
|
|
93
|
+
clearLazy(token) {
|
|
94
|
+
this.lazyResolutions.delete(token);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
class Container2 {
|
|
99
|
+
providers = new Map;
|
|
100
|
+
resolutionStack = new ResolutionStack;
|
|
101
|
+
register(provider) {
|
|
102
|
+
if (this.providers.has(provider.token)) {
|
|
103
|
+
throw new Error(`Provider already registered for token: ${String(provider.token)}`);
|
|
104
|
+
}
|
|
105
|
+
this.providers.set(provider.token, {
|
|
106
|
+
provider: {
|
|
107
|
+
...provider,
|
|
108
|
+
scope: provider.scope ?? "singleton"
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
registerAll(providers) {
|
|
113
|
+
for (const provider of providers) {
|
|
114
|
+
this.register(provider);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
has(token) {
|
|
118
|
+
return this.providers.has(token);
|
|
119
|
+
}
|
|
120
|
+
resolve(token) {
|
|
121
|
+
const resolved = this.providers.get(token);
|
|
122
|
+
if (!resolved) {
|
|
123
|
+
throw new Error(`No provider registered for token: ${String(token)}`);
|
|
124
|
+
}
|
|
125
|
+
const { provider } = resolved;
|
|
126
|
+
if (this.resolutionStack.has(token)) {
|
|
127
|
+
return this.createLazyProxy(token, resolved);
|
|
128
|
+
}
|
|
129
|
+
if (provider.scope === "singleton" && resolved.instance !== undefined) {
|
|
130
|
+
return resolved.instance;
|
|
131
|
+
}
|
|
132
|
+
this.resolutionStack.push(token);
|
|
133
|
+
try {
|
|
134
|
+
const instance = this.createInstance(provider);
|
|
135
|
+
if (provider.scope === "singleton") {
|
|
136
|
+
resolved.instance = instance;
|
|
137
|
+
}
|
|
138
|
+
return instance;
|
|
139
|
+
} finally {
|
|
140
|
+
this.resolutionStack.pop(token);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
createLazyProxy(token, resolved) {
|
|
144
|
+
const existingLazy = this.resolutionStack.getLazy(token);
|
|
145
|
+
if (existingLazy && existingLazy.instance) {
|
|
146
|
+
return existingLazy.instance;
|
|
147
|
+
}
|
|
148
|
+
const placeholder = {
|
|
149
|
+
resolved: false
|
|
150
|
+
};
|
|
151
|
+
this.resolutionStack.markLazy(token, placeholder);
|
|
152
|
+
const proxy = new Proxy({}, {
|
|
153
|
+
get: (target, prop) => {
|
|
154
|
+
if (placeholder.resolved && placeholder.instance) {
|
|
155
|
+
const value = placeholder.instance[prop];
|
|
156
|
+
return typeof value === "function" ? value.bind(placeholder.instance) : value;
|
|
157
|
+
}
|
|
158
|
+
if (resolved.instance !== undefined) {
|
|
159
|
+
placeholder.instance = resolved.instance;
|
|
160
|
+
placeholder.resolved = true;
|
|
161
|
+
} else {
|
|
162
|
+
if (prop === "then") {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (placeholder.instance) {
|
|
167
|
+
const value = placeholder.instance[prop];
|
|
168
|
+
return typeof value === "function" ? value.bind(placeholder.instance) : value;
|
|
169
|
+
}
|
|
170
|
+
return () => {
|
|
171
|
+
return;
|
|
172
|
+
};
|
|
173
|
+
},
|
|
174
|
+
set: (target, prop, value) => {
|
|
175
|
+
if (placeholder.instance) {
|
|
176
|
+
placeholder.instance[prop] = value;
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
return false;
|
|
180
|
+
},
|
|
181
|
+
has: (target, prop) => {
|
|
182
|
+
if (placeholder.instance) {
|
|
183
|
+
return prop in placeholder.instance;
|
|
184
|
+
}
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
placeholder.instance = proxy;
|
|
189
|
+
return proxy;
|
|
190
|
+
}
|
|
191
|
+
createInstance(provider) {
|
|
192
|
+
if (provider.useValue !== undefined) {
|
|
193
|
+
return provider.useValue;
|
|
194
|
+
}
|
|
195
|
+
if (provider.useFactory) {
|
|
196
|
+
const deps = this.resolveDeps(provider.inject ?? []);
|
|
197
|
+
return provider.useFactory(...deps);
|
|
198
|
+
}
|
|
199
|
+
if (provider.useClass) {
|
|
200
|
+
const deps = this.resolveDeps(provider.inject ?? []);
|
|
201
|
+
return new provider.useClass(...deps);
|
|
202
|
+
}
|
|
203
|
+
throw new Error(`Invalid provider configuration for token: ${String(provider.token)}`);
|
|
204
|
+
}
|
|
205
|
+
resolveDeps(tokens) {
|
|
206
|
+
return tokens.map((tokenOrRef) => {
|
|
207
|
+
const token = resolveForwardRef(tokenOrRef);
|
|
208
|
+
return this.resolve(token);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
clear() {
|
|
212
|
+
this.providers.clear();
|
|
213
|
+
}
|
|
214
|
+
getTokens() {
|
|
215
|
+
return Array.from(this.providers.keys());
|
|
216
|
+
}
|
|
217
|
+
createChild() {
|
|
218
|
+
const child = new Container2;
|
|
219
|
+
for (const [token, resolved] of this.providers) {
|
|
220
|
+
if (resolved.provider.scope === "singleton") {
|
|
221
|
+
child.providers.set(token, resolved);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return child;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function setContainerMetadata(target, key, value) {
|
|
228
|
+
if (!containerMetadata.has(target)) {
|
|
229
|
+
containerMetadata.set(target, new Map);
|
|
230
|
+
}
|
|
231
|
+
containerMetadata.get(target)?.set(key, value);
|
|
232
|
+
}
|
|
233
|
+
function getContainerMetadata(target, key) {
|
|
234
|
+
return containerMetadata.get(target)?.get(key);
|
|
235
|
+
}
|
|
236
|
+
function Injectable(token) {
|
|
237
|
+
return (target) => {
|
|
238
|
+
setContainerMetadata(target, "injectable", true);
|
|
239
|
+
if (token) {
|
|
240
|
+
setContainerMetadata(target, "token", token);
|
|
241
|
+
}
|
|
242
|
+
return target;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function Inject(token) {
|
|
246
|
+
return (target, propertyKey, parameterIndex) => {
|
|
247
|
+
const targetObj = target;
|
|
248
|
+
const existingTokens = getContainerMetadata(targetObj, "inject:tokens") ?? [];
|
|
249
|
+
existingTokens[parameterIndex] = token;
|
|
250
|
+
setContainerMetadata(targetObj, "inject:tokens", existingTokens);
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
var Token, containerMetadata;
|
|
254
|
+
var init_container = __esm(() => {
|
|
255
|
+
init_forward_ref();
|
|
256
|
+
Token = createToken;
|
|
257
|
+
containerMetadata = new WeakMap;
|
|
258
|
+
});
|
|
259
|
+
|
|
29
260
|
// src/context/index.ts
|
|
30
261
|
var exports_context = {};
|
|
31
262
|
__export(exports_context, {
|
|
@@ -259,369 +490,304 @@ function createPipeline() {
|
|
|
259
490
|
return new Pipeline;
|
|
260
491
|
}
|
|
261
492
|
|
|
262
|
-
// src/
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
{
|
|
278
|
-
message: error instanceof Error ? error.message : "Validation failed"
|
|
279
|
-
}
|
|
280
|
-
]
|
|
281
|
-
};
|
|
282
|
-
}
|
|
493
|
+
// src/modules/guards.ts
|
|
494
|
+
var exports_guards = {};
|
|
495
|
+
__export(exports_guards, {
|
|
496
|
+
getMethodRoles: () => getMethodRoles,
|
|
497
|
+
getMethodGuards: () => getMethodGuards,
|
|
498
|
+
getClassGuards: () => getClassGuards,
|
|
499
|
+
executeGuards: () => executeGuards,
|
|
500
|
+
createForbiddenResponse: () => createForbiddenResponse,
|
|
501
|
+
UseGuards: () => UseGuards,
|
|
502
|
+
RolesGuard: () => RolesGuard,
|
|
503
|
+
Roles: () => Roles,
|
|
504
|
+
AuthGuard: () => AuthGuard
|
|
505
|
+
});
|
|
506
|
+
function setClassGuards(target, guards) {
|
|
507
|
+
guardsClassMetadata.set(target, guards);
|
|
283
508
|
}
|
|
284
|
-
function
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
return { success: true, data: result.value };
|
|
509
|
+
function getClassGuards(target) {
|
|
510
|
+
return guardsClassMetadata.get(target);
|
|
511
|
+
}
|
|
512
|
+
function setMethodGuards(target, propertyKey, guards) {
|
|
513
|
+
if (!guardsMethodMetadata.has(target)) {
|
|
514
|
+
guardsMethodMetadata.set(target, new Map);
|
|
291
515
|
}
|
|
292
|
-
|
|
516
|
+
guardsMethodMetadata.get(target)?.set(propertyKey, guards);
|
|
293
517
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
const body = await context.body();
|
|
297
|
-
return validate(schema, body);
|
|
298
|
-
} catch (error) {
|
|
299
|
-
return {
|
|
300
|
-
success: false,
|
|
301
|
-
issues: [{ message: "Failed to parse request body" }]
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
function validateQuery(context, schema) {
|
|
306
|
-
return validateSync(schema, context.query);
|
|
307
|
-
}
|
|
308
|
-
function validateParams(context, schema) {
|
|
309
|
-
return validateSync(schema, context.params);
|
|
310
|
-
}
|
|
311
|
-
function validateHeaders(context, schema) {
|
|
312
|
-
const headers = {};
|
|
313
|
-
context.req.headers.forEach((value, key) => {
|
|
314
|
-
headers[key] = value;
|
|
315
|
-
});
|
|
316
|
-
return validateSync(schema, headers);
|
|
518
|
+
function getMethodGuards(target, propertyKey) {
|
|
519
|
+
return guardsMethodMetadata.get(target)?.get(propertyKey);
|
|
317
520
|
}
|
|
318
|
-
function
|
|
319
|
-
|
|
320
|
-
if (
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
if (!result.success) {
|
|
330
|
-
return context.status(400).json({ error: "Validation failed", issues: result.issues });
|
|
331
|
-
}
|
|
332
|
-
context.set("validatedQuery", result.data);
|
|
333
|
-
}
|
|
334
|
-
if (options.params) {
|
|
335
|
-
const result = validateParams(context, options.params);
|
|
336
|
-
if (!result.success) {
|
|
337
|
-
return context.status(400).json({ error: "Validation failed", issues: result.issues });
|
|
338
|
-
}
|
|
339
|
-
context.set("validatedParams", result.data);
|
|
340
|
-
}
|
|
341
|
-
if (options.headers) {
|
|
342
|
-
const result = validateHeaders(context, options.headers);
|
|
343
|
-
if (!result.success) {
|
|
344
|
-
return context.status(400).json({ error: "Validation failed", issues: result.issues });
|
|
345
|
-
}
|
|
346
|
-
context.set("validatedHeaders", result.data);
|
|
521
|
+
function UseGuards(...guards) {
|
|
522
|
+
const decorator = (target, propertyKey, descriptor) => {
|
|
523
|
+
if (propertyKey !== undefined && descriptor !== undefined) {
|
|
524
|
+
const targetObj = target;
|
|
525
|
+
const existingGuards = getMethodGuards(targetObj, propertyKey) ?? [];
|
|
526
|
+
setMethodGuards(targetObj, propertyKey, [...existingGuards, ...guards]);
|
|
527
|
+
return descriptor;
|
|
528
|
+
} else {
|
|
529
|
+
const targetClass = target;
|
|
530
|
+
const existingGuards = getClassGuards(targetClass) ?? [];
|
|
531
|
+
setClassGuards(targetClass, [...existingGuards, ...guards]);
|
|
347
532
|
}
|
|
348
|
-
return next();
|
|
349
533
|
};
|
|
534
|
+
return decorator;
|
|
350
535
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
return context.status(400).json({ error: "Validation failed", issues: result.issues });
|
|
358
|
-
}
|
|
359
|
-
context.set("body", result.data);
|
|
360
|
-
return original.call(this, context);
|
|
361
|
-
};
|
|
362
|
-
return descriptor;
|
|
363
|
-
};
|
|
536
|
+
|
|
537
|
+
class AuthGuard {
|
|
538
|
+
canActivate(context) {
|
|
539
|
+
const authHeader = context.req.headers.get("Authorization");
|
|
540
|
+
return authHeader !== null && authHeader.length > 0;
|
|
541
|
+
}
|
|
364
542
|
}
|
|
365
|
-
function
|
|
543
|
+
function setMethodRoles(target, propertyKey, roles) {
|
|
544
|
+
if (!rolesMethodMetadata.has(target)) {
|
|
545
|
+
rolesMethodMetadata.set(target, new Map);
|
|
546
|
+
}
|
|
547
|
+
rolesMethodMetadata.get(target)?.set(propertyKey, roles);
|
|
548
|
+
}
|
|
549
|
+
function getMethodRoles(target, propertyKey) {
|
|
550
|
+
return rolesMethodMetadata.get(target)?.get(propertyKey);
|
|
551
|
+
}
|
|
552
|
+
function Roles(...roles) {
|
|
366
553
|
return (target, propertyKey, descriptor) => {
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
const result = validateQuery(context, schema);
|
|
370
|
-
if (!result.success) {
|
|
371
|
-
return context.status(400).json({ error: "Validation failed", issues: result.issues });
|
|
372
|
-
}
|
|
373
|
-
context.set("query", result.data);
|
|
374
|
-
return original.call(this, context);
|
|
375
|
-
};
|
|
554
|
+
const targetObj = target;
|
|
555
|
+
setMethodRoles(targetObj, propertyKey, roles);
|
|
376
556
|
return descriptor;
|
|
377
557
|
};
|
|
378
558
|
}
|
|
379
|
-
|
|
380
|
-
|
|
559
|
+
|
|
560
|
+
class RolesGuard {
|
|
561
|
+
canActivate(context) {
|
|
562
|
+
const requiredRoles = context.requiredRoles;
|
|
563
|
+
if (!requiredRoles || requiredRoles.length === 0) {
|
|
564
|
+
return true;
|
|
565
|
+
}
|
|
566
|
+
const user = context.user;
|
|
567
|
+
if (!user || !user.roles) {
|
|
568
|
+
return false;
|
|
569
|
+
}
|
|
570
|
+
return requiredRoles.some((role) => user.roles?.includes(role));
|
|
571
|
+
}
|
|
381
572
|
}
|
|
382
|
-
function
|
|
383
|
-
|
|
384
|
-
|
|
573
|
+
async function executeGuards(context, options) {
|
|
574
|
+
const {
|
|
575
|
+
globalGuards = [],
|
|
576
|
+
classGuards = [],
|
|
577
|
+
methodGuards = [],
|
|
578
|
+
resolveGuard
|
|
579
|
+
} = options;
|
|
580
|
+
const allGuards = [...globalGuards, ...classGuards, ...methodGuards];
|
|
581
|
+
for (const guard of allGuards) {
|
|
582
|
+
let guardInstance = null;
|
|
583
|
+
if (typeof guard === "function") {
|
|
584
|
+
const funcGuard = guard;
|
|
585
|
+
if (funcGuard.prototype && typeof funcGuard.prototype === "object" && "canActivate" in funcGuard.prototype) {
|
|
586
|
+
guardInstance = resolveGuard ? resolveGuard(guard) : null;
|
|
587
|
+
if (!guardInstance) {
|
|
588
|
+
const GuardClass = guard;
|
|
589
|
+
guardInstance = new GuardClass;
|
|
590
|
+
}
|
|
591
|
+
} else {
|
|
592
|
+
guardInstance = guard;
|
|
593
|
+
}
|
|
594
|
+
} else if (typeof guard === "object" && guard !== null) {
|
|
595
|
+
const objGuard = guard;
|
|
596
|
+
if ("canActivate" in objGuard && typeof objGuard.canActivate === "function") {
|
|
597
|
+
guardInstance = guard;
|
|
598
|
+
} else {
|
|
599
|
+
guardInstance = resolveGuard ? resolveGuard(guard) : null;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
if (!guardInstance) {
|
|
603
|
+
console.warn("Guard could not be resolved:", guard);
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
606
|
+
let result;
|
|
607
|
+
if (typeof guardInstance === "function") {
|
|
608
|
+
result = await guardInstance(context);
|
|
609
|
+
} else {
|
|
610
|
+
result = await guardInstance.canActivate(context);
|
|
611
|
+
}
|
|
612
|
+
if (!result) {
|
|
613
|
+
return false;
|
|
614
|
+
}
|
|
385
615
|
}
|
|
616
|
+
return true;
|
|
386
617
|
}
|
|
387
|
-
function
|
|
618
|
+
function createForbiddenResponse() {
|
|
619
|
+
return new Response(JSON.stringify({
|
|
620
|
+
statusCode: 403,
|
|
621
|
+
error: "Forbidden",
|
|
622
|
+
message: "Access denied"
|
|
623
|
+
}), {
|
|
624
|
+
status: 403,
|
|
625
|
+
headers: {
|
|
626
|
+
"Content-Type": "application/json"
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
var guardsClassMetadata, guardsMethodMetadata, rolesMethodMetadata;
|
|
631
|
+
var init_guards = __esm(() => {
|
|
632
|
+
guardsClassMetadata = new WeakMap;
|
|
633
|
+
guardsMethodMetadata = new WeakMap;
|
|
634
|
+
rolesMethodMetadata = new WeakMap;
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
// src/validation/index.ts
|
|
638
|
+
async function validate(schema, data) {
|
|
388
639
|
try {
|
|
389
|
-
const result =
|
|
390
|
-
if (
|
|
391
|
-
|
|
392
|
-
const path = issue.path?.join(".") || "root";
|
|
393
|
-
return {
|
|
394
|
-
...issue,
|
|
395
|
-
message: `Environment variable validation failed for ${path}: ${issue.message}`
|
|
396
|
-
};
|
|
397
|
-
});
|
|
398
|
-
return {
|
|
399
|
-
success: false,
|
|
400
|
-
issues: formattedIssues
|
|
401
|
-
};
|
|
640
|
+
const result = await Promise.resolve(schema["~standard"].validate(data));
|
|
641
|
+
if ("value" in result) {
|
|
642
|
+
return { success: true, data: result.value };
|
|
402
643
|
}
|
|
403
|
-
return
|
|
644
|
+
return {
|
|
645
|
+
success: false,
|
|
646
|
+
issues: [...result.issues]
|
|
647
|
+
};
|
|
404
648
|
} catch (error) {
|
|
405
649
|
return {
|
|
406
650
|
success: false,
|
|
407
651
|
issues: [
|
|
408
652
|
{
|
|
409
|
-
message:
|
|
653
|
+
message: error instanceof Error ? error.message : "Validation failed"
|
|
410
654
|
}
|
|
411
655
|
]
|
|
412
656
|
};
|
|
413
657
|
}
|
|
414
658
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
function isForwardRef(value) {
|
|
425
|
-
return typeof value === "object" && value !== null && "__forwardRef" in value && "forwardRef" in value && typeof value.forwardRef === "function";
|
|
659
|
+
function validateSync(schema, data) {
|
|
660
|
+
const result = schema["~standard"].validate(data);
|
|
661
|
+
if (result instanceof Promise) {
|
|
662
|
+
throw new Error("Schema uses async validation. Use validate() instead.");
|
|
663
|
+
}
|
|
664
|
+
if ("value" in result) {
|
|
665
|
+
return { success: true, data: result.value };
|
|
666
|
+
}
|
|
667
|
+
return { success: false, issues: [...result.issues] };
|
|
426
668
|
}
|
|
427
|
-
function
|
|
428
|
-
|
|
429
|
-
|
|
669
|
+
async function validateBody(context, schema) {
|
|
670
|
+
try {
|
|
671
|
+
const body = await context.body();
|
|
672
|
+
return validate(schema, body);
|
|
673
|
+
} catch (error) {
|
|
674
|
+
return {
|
|
675
|
+
success: false,
|
|
676
|
+
issues: [{ message: "Failed to parse request body" }]
|
|
677
|
+
};
|
|
430
678
|
}
|
|
431
|
-
return ref;
|
|
432
679
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
function createToken(description) {
|
|
436
|
-
return Symbol(description);
|
|
680
|
+
function validateQuery(context, schema) {
|
|
681
|
+
return validateSync(schema, context.query);
|
|
437
682
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
class ResolutionStack {
|
|
441
|
-
stack = new Set;
|
|
442
|
-
lazyResolutions = new Map;
|
|
443
|
-
push(token) {
|
|
444
|
-
if (this.stack.has(token)) {
|
|
445
|
-
throw new Error("Circular dependency detected: Token already in resolution stack");
|
|
446
|
-
}
|
|
447
|
-
this.stack.add(token);
|
|
448
|
-
}
|
|
449
|
-
pop(token) {
|
|
450
|
-
this.stack.delete(token);
|
|
451
|
-
}
|
|
452
|
-
has(token) {
|
|
453
|
-
return this.stack.has(token);
|
|
454
|
-
}
|
|
455
|
-
markLazy(token, placeholder) {
|
|
456
|
-
this.lazyResolutions.set(token, placeholder);
|
|
457
|
-
}
|
|
458
|
-
hasLazy(token) {
|
|
459
|
-
return this.lazyResolutions.has(token);
|
|
460
|
-
}
|
|
461
|
-
getLazy(token) {
|
|
462
|
-
return this.lazyResolutions.get(token);
|
|
463
|
-
}
|
|
464
|
-
clearLazy(token) {
|
|
465
|
-
this.lazyResolutions.delete(token);
|
|
466
|
-
}
|
|
683
|
+
function validateParams(context, schema) {
|
|
684
|
+
return validateSync(schema, context.params);
|
|
467
685
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
registerAll(providers) {
|
|
484
|
-
for (const provider of providers) {
|
|
485
|
-
this.register(provider);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
has(token) {
|
|
489
|
-
return this.providers.has(token);
|
|
490
|
-
}
|
|
491
|
-
resolve(token) {
|
|
492
|
-
const resolved = this.providers.get(token);
|
|
493
|
-
if (!resolved) {
|
|
494
|
-
throw new Error(`No provider registered for token: ${String(token)}`);
|
|
495
|
-
}
|
|
496
|
-
const { provider } = resolved;
|
|
497
|
-
if (this.resolutionStack.has(token)) {
|
|
498
|
-
return this.createLazyProxy(token, resolved);
|
|
499
|
-
}
|
|
500
|
-
if (provider.scope === "singleton" && resolved.instance !== undefined) {
|
|
501
|
-
return resolved.instance;
|
|
502
|
-
}
|
|
503
|
-
this.resolutionStack.push(token);
|
|
504
|
-
try {
|
|
505
|
-
const instance = this.createInstance(provider);
|
|
506
|
-
if (provider.scope === "singleton") {
|
|
507
|
-
resolved.instance = instance;
|
|
508
|
-
}
|
|
509
|
-
return instance;
|
|
510
|
-
} finally {
|
|
511
|
-
this.resolutionStack.pop(token);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
createLazyProxy(token, resolved) {
|
|
515
|
-
const existingLazy = this.resolutionStack.getLazy(token);
|
|
516
|
-
if (existingLazy && existingLazy.instance) {
|
|
517
|
-
return existingLazy.instance;
|
|
518
|
-
}
|
|
519
|
-
const placeholder = {
|
|
520
|
-
resolved: false
|
|
521
|
-
};
|
|
522
|
-
this.resolutionStack.markLazy(token, placeholder);
|
|
523
|
-
const proxy = new Proxy({}, {
|
|
524
|
-
get: (target, prop) => {
|
|
525
|
-
if (placeholder.resolved && placeholder.instance) {
|
|
526
|
-
const value = placeholder.instance[prop];
|
|
527
|
-
return typeof value === "function" ? value.bind(placeholder.instance) : value;
|
|
528
|
-
}
|
|
529
|
-
if (resolved.instance !== undefined) {
|
|
530
|
-
placeholder.instance = resolved.instance;
|
|
531
|
-
placeholder.resolved = true;
|
|
532
|
-
} else {
|
|
533
|
-
if (prop === "then") {
|
|
534
|
-
return;
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
if (placeholder.instance) {
|
|
538
|
-
const value = placeholder.instance[prop];
|
|
539
|
-
return typeof value === "function" ? value.bind(placeholder.instance) : value;
|
|
540
|
-
}
|
|
541
|
-
return () => {
|
|
542
|
-
return;
|
|
543
|
-
};
|
|
544
|
-
},
|
|
545
|
-
set: (target, prop, value) => {
|
|
546
|
-
if (placeholder.instance) {
|
|
547
|
-
placeholder.instance[prop] = value;
|
|
548
|
-
return true;
|
|
549
|
-
}
|
|
550
|
-
return false;
|
|
551
|
-
},
|
|
552
|
-
has: (target, prop) => {
|
|
553
|
-
if (placeholder.instance) {
|
|
554
|
-
return prop in placeholder.instance;
|
|
555
|
-
}
|
|
556
|
-
return false;
|
|
686
|
+
function validateHeaders(context, schema) {
|
|
687
|
+
const headers = {};
|
|
688
|
+
context.req.headers.forEach((value, key) => {
|
|
689
|
+
headers[key] = value;
|
|
690
|
+
});
|
|
691
|
+
return validateSync(schema, headers);
|
|
692
|
+
}
|
|
693
|
+
function createValidator(options) {
|
|
694
|
+
return async (context, next) => {
|
|
695
|
+
if (options.body) {
|
|
696
|
+
const result = await validateBody(context, options.body);
|
|
697
|
+
if (!result.success) {
|
|
698
|
+
return context.status(400).json({ error: "Validation failed", issues: result.issues });
|
|
557
699
|
}
|
|
558
|
-
|
|
559
|
-
placeholder.instance = proxy;
|
|
560
|
-
return proxy;
|
|
561
|
-
}
|
|
562
|
-
createInstance(provider) {
|
|
563
|
-
if (provider.useValue !== undefined) {
|
|
564
|
-
return provider.useValue;
|
|
700
|
+
context.set("validatedBody", result.data);
|
|
565
701
|
}
|
|
566
|
-
if (
|
|
567
|
-
const
|
|
568
|
-
|
|
702
|
+
if (options.query) {
|
|
703
|
+
const result = validateQuery(context, options.query);
|
|
704
|
+
if (!result.success) {
|
|
705
|
+
return context.status(400).json({ error: "Validation failed", issues: result.issues });
|
|
706
|
+
}
|
|
707
|
+
context.set("validatedQuery", result.data);
|
|
569
708
|
}
|
|
570
|
-
if (
|
|
571
|
-
const
|
|
572
|
-
|
|
709
|
+
if (options.params) {
|
|
710
|
+
const result = validateParams(context, options.params);
|
|
711
|
+
if (!result.success) {
|
|
712
|
+
return context.status(400).json({ error: "Validation failed", issues: result.issues });
|
|
713
|
+
}
|
|
714
|
+
context.set("validatedParams", result.data);
|
|
573
715
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
const token = resolveForwardRef(tokenOrRef);
|
|
579
|
-
return this.resolve(token);
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
clear() {
|
|
583
|
-
this.providers.clear();
|
|
584
|
-
}
|
|
585
|
-
getTokens() {
|
|
586
|
-
return Array.from(this.providers.keys());
|
|
587
|
-
}
|
|
588
|
-
createChild() {
|
|
589
|
-
const child = new Container2;
|
|
590
|
-
for (const [token, resolved] of this.providers) {
|
|
591
|
-
if (resolved.provider.scope === "singleton") {
|
|
592
|
-
child.providers.set(token, resolved);
|
|
716
|
+
if (options.headers) {
|
|
717
|
+
const result = validateHeaders(context, options.headers);
|
|
718
|
+
if (!result.success) {
|
|
719
|
+
return context.status(400).json({ error: "Validation failed", issues: result.issues });
|
|
593
720
|
}
|
|
721
|
+
context.set("validatedHeaders", result.data);
|
|
594
722
|
}
|
|
595
|
-
return
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
var containerMetadata = new WeakMap;
|
|
599
|
-
function setContainerMetadata(target, key, value) {
|
|
600
|
-
if (!containerMetadata.has(target)) {
|
|
601
|
-
containerMetadata.set(target, new Map);
|
|
602
|
-
}
|
|
603
|
-
containerMetadata.get(target)?.set(key, value);
|
|
604
|
-
}
|
|
605
|
-
function getContainerMetadata(target, key) {
|
|
606
|
-
return containerMetadata.get(target)?.get(key);
|
|
723
|
+
return next();
|
|
724
|
+
};
|
|
607
725
|
}
|
|
608
|
-
function
|
|
609
|
-
return (target) => {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
726
|
+
function WithBody(schema) {
|
|
727
|
+
return (target, propertyKey, descriptor) => {
|
|
728
|
+
const original = descriptor.value;
|
|
729
|
+
descriptor.value = async function(context) {
|
|
730
|
+
const result = await validateBody(context, schema);
|
|
731
|
+
if (!result.success) {
|
|
732
|
+
return context.status(400).json({ error: "Validation failed", issues: result.issues });
|
|
733
|
+
}
|
|
734
|
+
context.set("body", result.data);
|
|
735
|
+
return original.call(this, context);
|
|
736
|
+
};
|
|
737
|
+
return descriptor;
|
|
615
738
|
};
|
|
616
739
|
}
|
|
617
|
-
function
|
|
618
|
-
return (target, propertyKey,
|
|
619
|
-
const
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
740
|
+
function WithQuery(schema) {
|
|
741
|
+
return (target, propertyKey, descriptor) => {
|
|
742
|
+
const original = descriptor.value;
|
|
743
|
+
descriptor.value = async function(context) {
|
|
744
|
+
const result = validateQuery(context, schema);
|
|
745
|
+
if (!result.success) {
|
|
746
|
+
return context.status(400).json({ error: "Validation failed", issues: result.issues });
|
|
747
|
+
}
|
|
748
|
+
context.set("query", result.data);
|
|
749
|
+
return original.call(this, context);
|
|
750
|
+
};
|
|
751
|
+
return descriptor;
|
|
623
752
|
};
|
|
624
753
|
}
|
|
754
|
+
function isStandardSchema(value) {
|
|
755
|
+
return typeof value === "object" && value !== null && "~standard" in value && typeof value["~standard"]?.validate === "function";
|
|
756
|
+
}
|
|
757
|
+
function assertStandardSchema(schema, name = "Schema") {
|
|
758
|
+
if (!isStandardSchema(schema)) {
|
|
759
|
+
throw new Error(`${name} must implement Standard Schema interface. Supported: Zod 4+, Valibot v1+, ArkType, Typia 7+`);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
function validateEnvSync(schema, envVars) {
|
|
763
|
+
try {
|
|
764
|
+
const result = validateSync(schema, envVars);
|
|
765
|
+
if (!result.success) {
|
|
766
|
+
const formattedIssues = result.issues.map((issue) => {
|
|
767
|
+
const path = issue.path?.join(".") || "root";
|
|
768
|
+
return {
|
|
769
|
+
...issue,
|
|
770
|
+
message: `Environment variable validation failed for ${path}: ${issue.message}`
|
|
771
|
+
};
|
|
772
|
+
});
|
|
773
|
+
return {
|
|
774
|
+
success: false,
|
|
775
|
+
issues: formattedIssues
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
return result;
|
|
779
|
+
} catch (error) {
|
|
780
|
+
return {
|
|
781
|
+
success: false,
|
|
782
|
+
issues: [
|
|
783
|
+
{
|
|
784
|
+
message: `Environment variable validation failed: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
785
|
+
}
|
|
786
|
+
]
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
|
|
625
791
|
// src/router/linear.ts
|
|
626
792
|
function patternToRegex(pattern) {
|
|
627
793
|
const paramNames = [];
|
|
@@ -1498,6 +1664,9 @@ class NotFoundError extends BuenoError {
|
|
|
1498
1664
|
}
|
|
1499
1665
|
}
|
|
1500
1666
|
|
|
1667
|
+
// src/modules/index.ts
|
|
1668
|
+
init_container();
|
|
1669
|
+
|
|
1501
1670
|
// src/modules/filters.ts
|
|
1502
1671
|
var filterMetadataStore = new WeakMap;
|
|
1503
1672
|
var catchMetadataStore = new WeakMap;
|
|
@@ -1698,134 +1867,8 @@ function createInternalErrorResponse(exception) {
|
|
|
1698
1867
|
});
|
|
1699
1868
|
}
|
|
1700
1869
|
|
|
1701
|
-
// src/modules/
|
|
1702
|
-
|
|
1703
|
-
var guardsMethodMetadata = new WeakMap;
|
|
1704
|
-
function setClassGuards(target, guards) {
|
|
1705
|
-
guardsClassMetadata.set(target, guards);
|
|
1706
|
-
}
|
|
1707
|
-
function getClassGuards(target) {
|
|
1708
|
-
return guardsClassMetadata.get(target);
|
|
1709
|
-
}
|
|
1710
|
-
function setMethodGuards(target, propertyKey, guards) {
|
|
1711
|
-
if (!guardsMethodMetadata.has(target)) {
|
|
1712
|
-
guardsMethodMetadata.set(target, new Map);
|
|
1713
|
-
}
|
|
1714
|
-
guardsMethodMetadata.get(target)?.set(propertyKey, guards);
|
|
1715
|
-
}
|
|
1716
|
-
function getMethodGuards(target, propertyKey) {
|
|
1717
|
-
return guardsMethodMetadata.get(target)?.get(propertyKey);
|
|
1718
|
-
}
|
|
1719
|
-
function UseGuards(...guards) {
|
|
1720
|
-
const decorator = (target, propertyKey, descriptor) => {
|
|
1721
|
-
if (propertyKey !== undefined && descriptor !== undefined) {
|
|
1722
|
-
const targetObj = target;
|
|
1723
|
-
const existingGuards = getMethodGuards(targetObj, propertyKey) ?? [];
|
|
1724
|
-
setMethodGuards(targetObj, propertyKey, [...existingGuards, ...guards]);
|
|
1725
|
-
return descriptor;
|
|
1726
|
-
} else {
|
|
1727
|
-
const targetClass = target;
|
|
1728
|
-
const existingGuards = getClassGuards(targetClass) ?? [];
|
|
1729
|
-
setClassGuards(targetClass, [...existingGuards, ...guards]);
|
|
1730
|
-
}
|
|
1731
|
-
};
|
|
1732
|
-
return decorator;
|
|
1733
|
-
}
|
|
1734
|
-
|
|
1735
|
-
class AuthGuard {
|
|
1736
|
-
canActivate(context) {
|
|
1737
|
-
const authHeader = context.req.headers.get("Authorization");
|
|
1738
|
-
return authHeader !== null && authHeader.length > 0;
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
var rolesMethodMetadata = new WeakMap;
|
|
1742
|
-
function setMethodRoles(target, propertyKey, roles) {
|
|
1743
|
-
if (!rolesMethodMetadata.has(target)) {
|
|
1744
|
-
rolesMethodMetadata.set(target, new Map);
|
|
1745
|
-
}
|
|
1746
|
-
rolesMethodMetadata.get(target)?.set(propertyKey, roles);
|
|
1747
|
-
}
|
|
1748
|
-
function getMethodRoles(target, propertyKey) {
|
|
1749
|
-
return rolesMethodMetadata.get(target)?.get(propertyKey);
|
|
1750
|
-
}
|
|
1751
|
-
function Roles(...roles) {
|
|
1752
|
-
return (target, propertyKey, descriptor) => {
|
|
1753
|
-
const targetObj = target;
|
|
1754
|
-
setMethodRoles(targetObj, propertyKey, roles);
|
|
1755
|
-
return descriptor;
|
|
1756
|
-
};
|
|
1757
|
-
}
|
|
1758
|
-
|
|
1759
|
-
class RolesGuard {
|
|
1760
|
-
canActivate(context) {
|
|
1761
|
-
const requiredRoles = context.requiredRoles;
|
|
1762
|
-
if (!requiredRoles || requiredRoles.length === 0) {
|
|
1763
|
-
return true;
|
|
1764
|
-
}
|
|
1765
|
-
const user = context.user;
|
|
1766
|
-
if (!user || !user.roles) {
|
|
1767
|
-
return false;
|
|
1768
|
-
}
|
|
1769
|
-
return requiredRoles.some((role) => user.roles?.includes(role));
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
async function executeGuards(context, options) {
|
|
1773
|
-
const {
|
|
1774
|
-
globalGuards = [],
|
|
1775
|
-
classGuards = [],
|
|
1776
|
-
methodGuards = [],
|
|
1777
|
-
resolveGuard
|
|
1778
|
-
} = options;
|
|
1779
|
-
const allGuards = [...globalGuards, ...classGuards, ...methodGuards];
|
|
1780
|
-
for (const guard of allGuards) {
|
|
1781
|
-
let guardInstance = null;
|
|
1782
|
-
if (typeof guard === "function") {
|
|
1783
|
-
const funcGuard = guard;
|
|
1784
|
-
if (funcGuard.prototype && typeof funcGuard.prototype === "object" && "canActivate" in funcGuard.prototype) {
|
|
1785
|
-
guardInstance = resolveGuard ? resolveGuard(guard) : null;
|
|
1786
|
-
if (!guardInstance) {
|
|
1787
|
-
const GuardClass = guard;
|
|
1788
|
-
guardInstance = new GuardClass;
|
|
1789
|
-
}
|
|
1790
|
-
} else {
|
|
1791
|
-
guardInstance = guard;
|
|
1792
|
-
}
|
|
1793
|
-
} else if (typeof guard === "object" && guard !== null) {
|
|
1794
|
-
const objGuard = guard;
|
|
1795
|
-
if ("canActivate" in objGuard && typeof objGuard.canActivate === "function") {
|
|
1796
|
-
guardInstance = guard;
|
|
1797
|
-
} else {
|
|
1798
|
-
guardInstance = resolveGuard ? resolveGuard(guard) : null;
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
if (!guardInstance) {
|
|
1802
|
-
console.warn("Guard could not be resolved:", guard);
|
|
1803
|
-
continue;
|
|
1804
|
-
}
|
|
1805
|
-
let result;
|
|
1806
|
-
if (typeof guardInstance === "function") {
|
|
1807
|
-
result = await guardInstance(context);
|
|
1808
|
-
} else {
|
|
1809
|
-
result = await guardInstance.canActivate(context);
|
|
1810
|
-
}
|
|
1811
|
-
if (!result) {
|
|
1812
|
-
return false;
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
|
-
return true;
|
|
1816
|
-
}
|
|
1817
|
-
function createForbiddenResponse() {
|
|
1818
|
-
return new Response(JSON.stringify({
|
|
1819
|
-
statusCode: 403,
|
|
1820
|
-
error: "Forbidden",
|
|
1821
|
-
message: "Access denied"
|
|
1822
|
-
}), {
|
|
1823
|
-
status: 403,
|
|
1824
|
-
headers: {
|
|
1825
|
-
"Content-Type": "application/json"
|
|
1826
|
-
}
|
|
1827
|
-
});
|
|
1828
|
-
}
|
|
1870
|
+
// src/modules/index.ts
|
|
1871
|
+
init_guards();
|
|
1829
1872
|
|
|
1830
1873
|
// src/modules/interceptors.ts
|
|
1831
1874
|
var interceptorsClassMetadata = new WeakMap;
|
|
@@ -2700,7 +2743,10 @@ function isPipeTransform(value) {
|
|
|
2700
2743
|
function isPipeFn(value) {
|
|
2701
2744
|
return typeof value === "function" && !isPipeTransform(value);
|
|
2702
2745
|
}
|
|
2746
|
+
|
|
2703
2747
|
// src/modules/index.ts
|
|
2748
|
+
init_guards();
|
|
2749
|
+
init_container();
|
|
2704
2750
|
function Inject2(token) {
|
|
2705
2751
|
return (target, propertyKey, parameterIndex) => {
|
|
2706
2752
|
const targetObj = target;
|
|
@@ -2804,6 +2850,7 @@ class Application {
|
|
|
2804
2850
|
routeInterceptorMetadata = new Map;
|
|
2805
2851
|
moduleLoader;
|
|
2806
2852
|
loadedLazyModules = new Set;
|
|
2853
|
+
websocketHandler = null;
|
|
2807
2854
|
constructor(moduleClass) {
|
|
2808
2855
|
this.container = new Container2;
|
|
2809
2856
|
this.router = new Router;
|
|
@@ -2816,6 +2863,15 @@ class Application {
|
|
|
2816
2863
|
this.globalGuards.push(...guards);
|
|
2817
2864
|
return this;
|
|
2818
2865
|
}
|
|
2866
|
+
getGlobalGuards() {
|
|
2867
|
+
return this.globalGuards;
|
|
2868
|
+
}
|
|
2869
|
+
getGlobalInterceptors() {
|
|
2870
|
+
return this.globalInterceptors;
|
|
2871
|
+
}
|
|
2872
|
+
setWebSocketHandler(handler) {
|
|
2873
|
+
this.websocketHandler = handler;
|
|
2874
|
+
}
|
|
2819
2875
|
useGlobalPipes(...pipes) {
|
|
2820
2876
|
this.globalPipes.push(...pipes);
|
|
2821
2877
|
return this;
|
|
@@ -2989,7 +3045,16 @@ class Application {
|
|
|
2989
3045
|
this.server = Bun.serve({
|
|
2990
3046
|
port,
|
|
2991
3047
|
hostname,
|
|
2992
|
-
|
|
3048
|
+
...this.websocketHandler ? { websocket: this.websocketHandler } : {},
|
|
3049
|
+
fetch: async (request, server) => {
|
|
3050
|
+
if (this.websocketHandler && request.headers.get("upgrade")?.toLowerCase() === "websocket") {
|
|
3051
|
+
const wsUpgradeHandler = this.websocketHandler.__upgradeHandler;
|
|
3052
|
+
if (wsUpgradeHandler) {
|
|
3053
|
+
const response = wsUpgradeHandler(request, server);
|
|
3054
|
+
if (response)
|
|
3055
|
+
return response;
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
2993
3058
|
if (this.isShuttingDown) {
|
|
2994
3059
|
return new Response("Service Unavailable", { status: 503 });
|
|
2995
3060
|
}
|