exisjs 0.6.1 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +2 -8
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/dev.js +33 -44
- package/dist/cli/commands/dev.js.map +1 -1
- package/dist/cli/commands/exports.d.ts.map +1 -1
- package/dist/cli/commands/exports.js +5 -32
- package/dist/cli/commands/exports.js.map +1 -1
- package/dist/cli/commands/generate.d.ts +2 -13
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +27 -60
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +4 -4
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +2 -6
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/index.js +11 -23
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/routes.d.ts.map +1 -1
- package/dist/cli/routes.js +20 -8
- package/dist/cli/routes.js.map +1 -1
- package/dist/config/config.d.ts +2 -1
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +7 -5
- package/dist/config/config.js.map +1 -1
- package/dist/config/env.d.ts.map +1 -1
- package/dist/config/env.js +3 -2
- package/dist/config/env.js.map +1 -1
- package/dist/config/types.d.ts +7 -2
- package/dist/config/types.d.ts.map +1 -1
- package/dist/decorators/constants.d.ts +9 -2
- package/dist/decorators/constants.d.ts.map +1 -1
- package/dist/decorators/constants.js +3 -2
- package/dist/decorators/constants.js.map +1 -1
- package/dist/decorators/core/metadata.d.ts +31 -0
- package/dist/decorators/core/metadata.d.ts.map +1 -1
- package/dist/decorators/core/metadata.js +110 -1
- package/dist/decorators/core/metadata.js.map +1 -1
- package/dist/decorators/core.d.ts +19 -4
- package/dist/decorators/core.d.ts.map +1 -1
- package/dist/decorators/core.js +29 -4
- package/dist/decorators/core.js.map +1 -1
- package/dist/decorators/middleware.d.ts +17 -17
- package/dist/decorators/middleware.d.ts.map +1 -1
- package/dist/decorators/middleware.js +111 -208
- package/dist/decorators/middleware.js.map +1 -1
- package/dist/decorators/params.d.ts +54 -12
- package/dist/decorators/params.d.ts.map +1 -1
- package/dist/decorators/params.js +40 -20
- package/dist/decorators/params.js.map +1 -1
- package/dist/decorators/routing.d.ts +0 -2
- package/dist/decorators/routing.d.ts.map +1 -1
- package/dist/decorators/routing.js +3 -4
- package/dist/decorators/routing.js.map +1 -1
- package/dist/di/container.d.ts +5 -1
- package/dist/di/container.d.ts.map +1 -1
- package/dist/di/container.js +56 -8
- package/dist/di/container.js.map +1 -1
- package/dist/di/decorators.d.ts +30 -0
- package/dist/di/decorators.d.ts.map +1 -0
- package/dist/di/decorators.js +59 -0
- package/dist/di/decorators.js.map +1 -0
- package/dist/di/index.d.ts +1 -0
- package/dist/di/index.d.ts.map +1 -1
- package/dist/di/index.js +4 -1
- package/dist/di/index.js.map +1 -1
- package/dist/docs/ARCHITECTURE.md +46 -285
- package/dist/docs/BENCHMARKS.md +5 -5
- package/dist/docs/README.md +8 -11
- package/dist/docs/content/boundaries.mdx +151 -0
- package/dist/docs/content/cli/commands.mdx +66 -104
- package/dist/docs/content/cli/overview.mdx +37 -47
- package/dist/docs/content/cli/usage.mdx +29 -15
- package/dist/docs/content/decorators.mdx +142 -81
- package/dist/docs/content/installation.mdx +20 -1
- package/dist/docs/content/middleware.mdx +65 -291
- package/dist/docs/content/modules.mdx +22 -1
- package/dist/docs/content/providers.mdx +33 -1
- package/dist/docs/content/security.mdx +44 -246
- package/dist/docs/content/structure.mdx +227 -100
- package/dist/docs/content/validation.mdx +0 -17
- package/dist/docs/reference/decorators.mdx +34 -216
- package/dist/docs/reference/di.mdx +35 -11
- package/dist/docs/reference/logger.mdx +100 -0
- package/dist/docs/reference/middleware.mdx +41 -217
- package/dist/docs/reference/router.mdx +9 -9
- package/dist/docs/reference/validator.mdx +2 -5
- package/dist/error/errors.d.ts.map +1 -1
- package/dist/error/errors.js +19 -5
- package/dist/error/errors.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/start-server.js +10 -0
- package/dist/lib/start-server.js.map +1 -1
- package/dist/logger/index.d.ts +81 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +142 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/middleware/dedupe.d.ts +1 -1
- package/dist/middleware/dedupe.js +1 -1
- package/dist/middleware/middleware.d.ts +3 -5
- package/dist/middleware/middleware.d.ts.map +1 -1
- package/dist/middleware/middleware.js +2 -6
- package/dist/middleware/middleware.js.map +1 -1
- package/dist/middleware/rate-limit.d.ts +0 -2
- package/dist/middleware/rate-limit.d.ts.map +1 -1
- package/dist/middleware/rate-limit.js +2 -14
- package/dist/middleware/rate-limit.js.map +1 -1
- package/dist/module/index.d.ts +2 -0
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +3 -1
- package/dist/module/index.js.map +1 -1
- package/dist/plugin/manager.d.ts +1 -1
- package/dist/plugin/manager.d.ts.map +1 -1
- package/dist/plugin/manager.js +47 -0
- package/dist/plugin/manager.js.map +1 -1
- package/dist/router/{gateway.d.ts → boundary.d.ts} +21 -13
- package/dist/router/boundary.d.ts.map +1 -0
- package/dist/router/boundary.js +11 -0
- package/dist/router/boundary.js.map +1 -0
- package/dist/router/controller-registrar.d.ts.map +1 -1
- package/dist/router/controller-registrar.js +33 -6
- package/dist/router/controller-registrar.js.map +1 -1
- package/dist/router/index.d.ts +3 -6
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +3 -7
- package/dist/router/index.js.map +1 -1
- package/dist/router/route-builder.d.ts +0 -28
- package/dist/router/route-builder.d.ts.map +1 -1
- package/dist/router/route-builder.js +2 -5
- package/dist/router/route-builder.js.map +1 -1
- package/dist/router/route-scanner.d.ts +1 -2
- package/dist/router/route-scanner.d.ts.map +1 -1
- package/dist/router/route-scanner.js +225 -203
- package/dist/router/route-scanner.js.map +1 -1
- package/dist/router/router.d.ts +4 -6
- package/dist/router/router.d.ts.map +1 -1
- package/dist/router/router.js +36 -72
- package/dist/router/router.js.map +1 -1
- package/dist/router/types.d.ts +2 -6
- package/dist/router/types.d.ts.map +1 -1
- package/dist/server/{bun-adapter.d.ts → adapters/bun-adapter.d.ts} +1 -1
- package/dist/server/adapters/bun-adapter.d.ts.map +1 -0
- package/dist/server/{bun-adapter.js → adapters/bun-adapter.js} +2 -24
- package/dist/server/adapters/bun-adapter.js.map +1 -0
- package/dist/server/{uws-adapter.d.ts → adapters/uws-adapter.d.ts} +1 -1
- package/dist/server/adapters/uws-adapter.d.ts.map +1 -0
- package/dist/server/{uws-adapter.js → adapters/uws-adapter.js} +1 -28
- package/dist/server/adapters/uws-adapter.js.map +1 -0
- package/dist/server/app.d.ts +10 -31
- package/dist/server/app.d.ts.map +1 -1
- package/dist/server/app.js +20 -135
- package/dist/server/app.js.map +1 -1
- package/dist/server/bootstrapper.d.ts +4 -15
- package/dist/server/bootstrapper.d.ts.map +1 -1
- package/dist/server/bootstrapper.js +30 -229
- package/dist/server/bootstrapper.js.map +1 -1
- package/dist/server/define.d.ts +2 -2
- package/dist/server/define.d.ts.map +1 -1
- package/dist/server/define.js +3 -3
- package/dist/server/define.js.map +1 -1
- package/dist/server/engines/bun-engine.d.ts +16 -0
- package/dist/server/engines/bun-engine.d.ts.map +1 -0
- package/dist/server/engines/bun-engine.js +41 -0
- package/dist/server/engines/bun-engine.js.map +1 -0
- package/dist/server/engines/engine.d.ts +16 -0
- package/dist/server/engines/engine.d.ts.map +1 -0
- package/dist/{queue/types.js → server/engines/engine.js} +1 -1
- package/dist/server/engines/engine.js.map +1 -0
- package/dist/server/engines/node-engine.d.ts +22 -0
- package/dist/server/engines/node-engine.d.ts.map +1 -0
- package/dist/server/engines/node-engine.js +130 -0
- package/dist/server/engines/node-engine.js.map +1 -0
- package/dist/server/engines/uws-engine.d.ts +16 -0
- package/dist/server/engines/uws-engine.d.ts.map +1 -0
- package/dist/server/engines/uws-engine.js +48 -0
- package/dist/server/engines/uws-engine.js.map +1 -0
- package/dist/server/request-handler.d.ts +0 -1
- package/dist/server/request-handler.d.ts.map +1 -1
- package/dist/server/request-handler.js +74 -48
- package/dist/server/request-handler.js.map +1 -1
- package/dist/server/request.d.ts +0 -8
- package/dist/server/request.d.ts.map +1 -1
- package/dist/server/request.js +0 -16
- package/dist/server/request.js.map +1 -1
- package/dist/server/response.d.ts.map +1 -1
- package/dist/server/response.js +2 -1
- package/dist/server/response.js.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +0 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/time.d.ts +6 -0
- package/dist/utils/time.d.ts.map +1 -0
- package/dist/utils/time.js +15 -0
- package/dist/utils/time.js.map +1 -0
- package/dist/validator/index.d.ts +1 -7
- package/dist/validator/index.d.ts.map +1 -1
- package/dist/validator/index.js +1 -5
- package/dist/validator/index.js.map +1 -1
- package/dist/validator/tex-types.d.ts +15 -2
- package/dist/validator/tex-types.d.ts.map +1 -1
- package/dist/validator/tex-types.js +8 -0
- package/dist/validator/tex-types.js.map +1 -1
- package/dist/validator/tex.d.ts.map +1 -1
- package/dist/validator/tex.js +21 -2
- package/dist/validator/tex.js.map +1 -1
- package/package.json +9 -151
- package/dist/adapters/aws-lambda.d.ts +0 -21
- package/dist/adapters/aws-lambda.d.ts.map +0 -1
- package/dist/adapters/aws-lambda.js +0 -125
- package/dist/adapters/aws-lambda.js.map +0 -1
- package/dist/adapters/bun.d.ts +0 -9
- package/dist/adapters/bun.d.ts.map +0 -1
- package/dist/adapters/bun.js +0 -23
- package/dist/adapters/bun.js.map +0 -1
- package/dist/adapters/cloudflare.d.ts +0 -10
- package/dist/adapters/cloudflare.d.ts.map +0 -1
- package/dist/adapters/cloudflare.js +0 -22
- package/dist/adapters/cloudflare.js.map +0 -1
- package/dist/adapters/deno.d.ts +0 -7
- package/dist/adapters/deno.d.ts.map +0 -1
- package/dist/adapters/deno.js +0 -21
- package/dist/adapters/deno.js.map +0 -1
- package/dist/adapters/fastly.d.ts +0 -6
- package/dist/adapters/fastly.d.ts.map +0 -1
- package/dist/adapters/fastly.js +0 -20
- package/dist/adapters/fastly.js.map +0 -1
- package/dist/adapters/fetch.d.ts +0 -30
- package/dist/adapters/fetch.d.ts.map +0 -1
- package/dist/adapters/fetch.js +0 -119
- package/dist/adapters/fetch.js.map +0 -1
- package/dist/adapters/index.d.ts +0 -9
- package/dist/adapters/index.d.ts.map +0 -1
- package/dist/adapters/index.js +0 -28
- package/dist/adapters/index.js.map +0 -1
- package/dist/adapters/netlify.d.ts +0 -8
- package/dist/adapters/netlify.d.ts.map +0 -1
- package/dist/adapters/netlify.js +0 -20
- package/dist/adapters/netlify.js.map +0 -1
- package/dist/adapters/vercel.d.ts +0 -17
- package/dist/adapters/vercel.d.ts.map +0 -1
- package/dist/adapters/vercel.js +0 -23
- package/dist/adapters/vercel.js.map +0 -1
- package/dist/auth/index.d.ts +0 -8
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js +0 -49
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/jwt.d.ts +0 -20
- package/dist/auth/jwt.d.ts.map +0 -1
- package/dist/auth/jwt.js +0 -59
- package/dist/auth/jwt.js.map +0 -1
- package/dist/auth/oauth/core.d.ts +0 -96
- package/dist/auth/oauth/core.d.ts.map +0 -1
- package/dist/auth/oauth/core.js +0 -203
- package/dist/auth/oauth/core.js.map +0 -1
- package/dist/auth/oauth/index.d.ts +0 -45
- package/dist/auth/oauth/index.d.ts.map +0 -1
- package/dist/auth/oauth/index.js +0 -64
- package/dist/auth/oauth/index.js.map +0 -1
- package/dist/auth/oauth/middleware.d.ts +0 -63
- package/dist/auth/oauth/middleware.d.ts.map +0 -1
- package/dist/auth/oauth/middleware.js +0 -164
- package/dist/auth/oauth/middleware.js.map +0 -1
- package/dist/auth/oauth/providers/custom.d.ts +0 -41
- package/dist/auth/oauth/providers/custom.d.ts.map +0 -1
- package/dist/auth/oauth/providers/custom.js +0 -204
- package/dist/auth/oauth/providers/custom.js.map +0 -1
- package/dist/auth/oauth/providers/discord.d.ts +0 -23
- package/dist/auth/oauth/providers/discord.d.ts.map +0 -1
- package/dist/auth/oauth/providers/discord.js +0 -130
- package/dist/auth/oauth/providers/discord.js.map +0 -1
- package/dist/auth/oauth/providers/facebook.d.ts +0 -28
- package/dist/auth/oauth/providers/facebook.d.ts.map +0 -1
- package/dist/auth/oauth/providers/facebook.js +0 -124
- package/dist/auth/oauth/providers/facebook.js.map +0 -1
- package/dist/auth/oauth/providers/github.d.ts +0 -25
- package/dist/auth/oauth/providers/github.d.ts.map +0 -1
- package/dist/auth/oauth/providers/github.js +0 -132
- package/dist/auth/oauth/providers/github.js.map +0 -1
- package/dist/auth/oauth/providers/google.d.ts +0 -23
- package/dist/auth/oauth/providers/google.d.ts.map +0 -1
- package/dist/auth/oauth/providers/google.js +0 -134
- package/dist/auth/oauth/providers/google.js.map +0 -1
- package/dist/auth/oauth/providers/microsoft.d.ts +0 -28
- package/dist/auth/oauth/providers/microsoft.d.ts.map +0 -1
- package/dist/auth/oauth/providers/microsoft.js +0 -136
- package/dist/auth/oauth/providers/microsoft.js.map +0 -1
- package/dist/auth/oauth/types.d.ts +0 -158
- package/dist/auth/oauth/types.d.ts.map +0 -1
- package/dist/auth/oauth/types.js +0 -4
- package/dist/auth/oauth/types.js.map +0 -1
- package/dist/auth/password.d.ts +0 -25
- package/dist/auth/password.d.ts.map +0 -1
- package/dist/auth/password.js +0 -93
- package/dist/auth/password.js.map +0 -1
- package/dist/auth/rbac.d.ts +0 -10
- package/dist/auth/rbac.d.ts.map +0 -1
- package/dist/auth/rbac.js +0 -34
- package/dist/auth/rbac.js.map +0 -1
- package/dist/auth/session.d.ts +0 -26
- package/dist/auth/session.d.ts.map +0 -1
- package/dist/auth/session.js +0 -134
- package/dist/auth/session.js.map +0 -1
- package/dist/cache/index.d.ts +0 -4
- package/dist/cache/index.d.ts.map +0 -1
- package/dist/cache/index.js +0 -25
- package/dist/cache/index.js.map +0 -1
- package/dist/cache/store.d.ts +0 -58
- package/dist/cache/store.d.ts.map +0 -1
- package/dist/cache/store.js +0 -298
- package/dist/cache/store.js.map +0 -1
- package/dist/cron/parser.d.ts +0 -2
- package/dist/cron/parser.d.ts.map +0 -1
- package/dist/cron/parser.js +0 -52
- package/dist/cron/parser.js.map +0 -1
- package/dist/cron/scheduler.d.ts +0 -23
- package/dist/cron/scheduler.d.ts.map +0 -1
- package/dist/cron/scheduler.js +0 -114
- package/dist/cron/scheduler.js.map +0 -1
- package/dist/database/adapters/mongodb.d.ts +0 -58
- package/dist/database/adapters/mongodb.d.ts.map +0 -1
- package/dist/database/adapters/mongodb.js +0 -264
- package/dist/database/adapters/mongodb.js.map +0 -1
- package/dist/database/adapters/mysql.d.ts +0 -27
- package/dist/database/adapters/mysql.d.ts.map +0 -1
- package/dist/database/adapters/mysql.js +0 -188
- package/dist/database/adapters/mysql.js.map +0 -1
- package/dist/database/adapters/postgres.d.ts +0 -28
- package/dist/database/adapters/postgres.d.ts.map +0 -1
- package/dist/database/adapters/postgres.js +0 -174
- package/dist/database/adapters/postgres.js.map +0 -1
- package/dist/database/adapters/sqlite.d.ts +0 -27
- package/dist/database/adapters/sqlite.d.ts.map +0 -1
- package/dist/database/adapters/sqlite.js +0 -149
- package/dist/database/adapters/sqlite.js.map +0 -1
- package/dist/database/index.d.ts +0 -42
- package/dist/database/index.d.ts.map +0 -1
- package/dist/database/index.js +0 -58
- package/dist/database/index.js.map +0 -1
- package/dist/database/manager.d.ts +0 -141
- package/dist/database/manager.d.ts.map +0 -1
- package/dist/database/manager.js +0 -337
- package/dist/database/manager.js.map +0 -1
- package/dist/database/migration.d.ts +0 -57
- package/dist/database/migration.d.ts.map +0 -1
- package/dist/database/migration.js +0 -329
- package/dist/database/migration.js.map +0 -1
- package/dist/database/query-builder.d.ts +0 -95
- package/dist/database/query-builder.d.ts.map +0 -1
- package/dist/database/query-builder.js +0 -404
- package/dist/database/query-builder.js.map +0 -1
- package/dist/database/sql/index.d.ts +0 -18
- package/dist/database/sql/index.d.ts.map +0 -1
- package/dist/database/sql/index.js +0 -74
- package/dist/database/sql/index.js.map +0 -1
- package/dist/database/sql/schema.d.ts +0 -38
- package/dist/database/sql/schema.d.ts.map +0 -1
- package/dist/database/sql/schema.js +0 -80
- package/dist/database/sql/schema.js.map +0 -1
- package/dist/database/synchronizer.d.ts +0 -12
- package/dist/database/synchronizer.d.ts.map +0 -1
- package/dist/database/synchronizer.js +0 -82
- package/dist/database/synchronizer.js.map +0 -1
- package/dist/database/types.d.ts +0 -184
- package/dist/database/types.d.ts.map +0 -1
- package/dist/database/types.js +0 -4
- package/dist/database/types.js.map +0 -1
- package/dist/dataloader/dataloader.d.ts +0 -23
- package/dist/dataloader/dataloader.d.ts.map +0 -1
- package/dist/dataloader/dataloader.js +0 -98
- package/dist/dataloader/dataloader.js.map +0 -1
- package/dist/dataloader/index.d.ts +0 -3
- package/dist/dataloader/index.d.ts.map +0 -1
- package/dist/dataloader/index.js +0 -19
- package/dist/dataloader/index.js.map +0 -1
- package/dist/dataloader/registry.d.ts +0 -17
- package/dist/dataloader/registry.d.ts.map +0 -1
- package/dist/dataloader/registry.js +0 -47
- package/dist/dataloader/registry.js.map +0 -1
- package/dist/dev/dep-graph.d.ts +0 -2
- package/dist/dev/dep-graph.d.ts.map +0 -1
- package/dist/dev/dep-graph.js +0 -111
- package/dist/dev/dep-graph.js.map +0 -1
- package/dist/dev/hot-reload.d.ts +0 -30
- package/dist/dev/hot-reload.d.ts.map +0 -1
- package/dist/dev/hot-reload.js +0 -262
- package/dist/dev/hot-reload.js.map +0 -1
- package/dist/docs/content/adapters.mdx +0 -199
- package/dist/docs/content/cache.mdx +0 -239
- package/dist/docs/content/circuit-breaker.mdx +0 -130
- package/dist/docs/content/cron.mdx +0 -109
- package/dist/docs/content/database.mdx +0 -278
- package/dist/docs/content/gateways.mdx +0 -376
- package/dist/docs/content/oauth.mdx +0 -179
- package/dist/docs/content/queues.mdx +0 -177
- package/dist/docs/content/rpc.mdx +0 -146
- package/dist/docs/content/sse.mdx +0 -159
- package/dist/docs/content/websockets.mdx +0 -289
- package/dist/docs/integrations/README.md +0 -23
- package/dist/docs/integrations/jwt.mdx +0 -151
- package/dist/docs/integrations/mongo.mdx +0 -183
- package/dist/docs/integrations/observability.mdx +0 -125
- package/dist/docs/integrations/openai.mdx +0 -108
- package/dist/docs/integrations/postgres.mdx +0 -190
- package/dist/docs/integrations/posthog.mdx +0 -122
- package/dist/docs/integrations/redis.mdx +0 -141
- package/dist/docs/integrations/resend.mdx +0 -117
- package/dist/docs/integrations/s3.mdx +0 -122
- package/dist/docs/integrations/swagger.mdx +0 -113
- package/dist/docs/reference/adapters.mdx +0 -130
- package/dist/docs/reference/auth.mdx +0 -183
- package/dist/docs/reference/cache.mdx +0 -132
- package/dist/docs/reference/circuit-breaker.mdx +0 -71
- package/dist/docs/reference/queue.mdx +0 -155
- package/dist/docs/reference/storage.mdx +0 -116
- package/dist/docs/reference/swagger.mdx +0 -132
- package/dist/integrations/drizzle.d.ts +0 -10
- package/dist/integrations/drizzle.d.ts.map +0 -1
- package/dist/integrations/drizzle.js +0 -34
- package/dist/integrations/drizzle.js.map +0 -1
- package/dist/integrations/jwt.d.ts +0 -12
- package/dist/integrations/jwt.d.ts.map +0 -1
- package/dist/integrations/jwt.js +0 -29
- package/dist/integrations/jwt.js.map +0 -1
- package/dist/integrations/mongodb.d.ts +0 -13
- package/dist/integrations/mongodb.d.ts.map +0 -1
- package/dist/integrations/mongodb.js +0 -48
- package/dist/integrations/mongodb.js.map +0 -1
- package/dist/integrations/mongoose.d.ts +0 -13
- package/dist/integrations/mongoose.d.ts.map +0 -1
- package/dist/integrations/mongoose.js +0 -84
- package/dist/integrations/mongoose.js.map +0 -1
- package/dist/integrations/openai.d.ts +0 -12
- package/dist/integrations/openai.d.ts.map +0 -1
- package/dist/integrations/openai.js +0 -47
- package/dist/integrations/openai.js.map +0 -1
- package/dist/integrations/postgres.d.ts +0 -13
- package/dist/integrations/postgres.d.ts.map +0 -1
- package/dist/integrations/postgres.js +0 -55
- package/dist/integrations/postgres.js.map +0 -1
- package/dist/integrations/posthog.d.ts +0 -13
- package/dist/integrations/posthog.d.ts.map +0 -1
- package/dist/integrations/posthog.js +0 -49
- package/dist/integrations/posthog.js.map +0 -1
- package/dist/integrations/prisma.d.ts +0 -10
- package/dist/integrations/prisma.d.ts.map +0 -1
- package/dist/integrations/prisma.js +0 -39
- package/dist/integrations/prisma.js.map +0 -1
- package/dist/integrations/redis.d.ts +0 -12
- package/dist/integrations/redis.d.ts.map +0 -1
- package/dist/integrations/redis.js +0 -48
- package/dist/integrations/redis.js.map +0 -1
- package/dist/integrations/resend.d.ts +0 -12
- package/dist/integrations/resend.d.ts.map +0 -1
- package/dist/integrations/resend.js +0 -47
- package/dist/integrations/resend.js.map +0 -1
- package/dist/integrations/s3.d.ts +0 -15
- package/dist/integrations/s3.d.ts.map +0 -1
- package/dist/integrations/s3.js +0 -60
- package/dist/integrations/s3.js.map +0 -1
- package/dist/integrations/supabase.d.ts +0 -13
- package/dist/integrations/supabase.d.ts.map +0 -1
- package/dist/integrations/supabase.js +0 -51
- package/dist/integrations/supabase.js.map +0 -1
- package/dist/middleware/cache.d.ts +0 -21
- package/dist/middleware/cache.d.ts.map +0 -1
- package/dist/middleware/cache.js +0 -156
- package/dist/middleware/cache.js.map +0 -1
- package/dist/observability/health.d.ts +0 -23
- package/dist/observability/health.d.ts.map +0 -1
- package/dist/observability/health.js +0 -49
- package/dist/observability/health.js.map +0 -1
- package/dist/observability/index.d.ts +0 -4
- package/dist/observability/index.d.ts.map +0 -1
- package/dist/observability/index.js +0 -10
- package/dist/observability/index.js.map +0 -1
- package/dist/observability/metrics.d.ts +0 -6
- package/dist/observability/metrics.d.ts.map +0 -1
- package/dist/observability/metrics.js +0 -60
- package/dist/observability/metrics.js.map +0 -1
- package/dist/observability/otel.d.ts +0 -27
- package/dist/observability/otel.d.ts.map +0 -1
- package/dist/observability/otel.js +0 -45
- package/dist/observability/otel.js.map +0 -1
- package/dist/observability/prometheus.d.ts +0 -30
- package/dist/observability/prometheus.d.ts.map +0 -1
- package/dist/observability/prometheus.js +0 -31
- package/dist/observability/prometheus.js.map +0 -1
- package/dist/queue/client.d.ts +0 -13
- package/dist/queue/client.d.ts.map +0 -1
- package/dist/queue/client.js +0 -83
- package/dist/queue/client.js.map +0 -1
- package/dist/queue/drivers/MemoryDriver.d.ts +0 -21
- package/dist/queue/drivers/MemoryDriver.d.ts.map +0 -1
- package/dist/queue/drivers/MemoryDriver.js +0 -176
- package/dist/queue/drivers/MemoryDriver.js.map +0 -1
- package/dist/queue/drivers/RedisDriver.d.ts +0 -19
- package/dist/queue/drivers/RedisDriver.d.ts.map +0 -1
- package/dist/queue/drivers/RedisDriver.js +0 -130
- package/dist/queue/drivers/RedisDriver.js.map +0 -1
- package/dist/queue/index.d.ts +0 -18
- package/dist/queue/index.d.ts.map +0 -1
- package/dist/queue/index.js +0 -37
- package/dist/queue/index.js.map +0 -1
- package/dist/queue/manager.d.ts +0 -18
- package/dist/queue/manager.d.ts.map +0 -1
- package/dist/queue/manager.js +0 -59
- package/dist/queue/manager.js.map +0 -1
- package/dist/queue/types.d.ts +0 -55
- package/dist/queue/types.d.ts.map +0 -1
- package/dist/queue/types.js.map +0 -1
- package/dist/queue/worker.d.ts +0 -18
- package/dist/queue/worker.d.ts.map +0 -1
- package/dist/queue/worker.js +0 -176
- package/dist/queue/worker.js.map +0 -1
- package/dist/router/gateway.d.ts.map +0 -1
- package/dist/router/gateway.js +0 -11
- package/dist/router/gateway.js.map +0 -1
- package/dist/server/bun-adapter.d.ts.map +0 -1
- package/dist/server/bun-adapter.js.map +0 -1
- package/dist/server/sse.d.ts +0 -16
- package/dist/server/sse.d.ts.map +0 -1
- package/dist/server/sse.js +0 -51
- package/dist/server/sse.js.map +0 -1
- package/dist/server/uws-adapter.d.ts.map +0 -1
- package/dist/server/uws-adapter.js.map +0 -1
- package/dist/storage/index.d.ts +0 -15
- package/dist/storage/index.d.ts.map +0 -1
- package/dist/storage/index.js +0 -7
- package/dist/storage/index.js.map +0 -1
- package/dist/swagger/index.d.ts +0 -9
- package/dist/swagger/index.d.ts.map +0 -1
- package/dist/swagger/index.js +0 -165
- package/dist/swagger/index.js.map +0 -1
- package/dist/threads/pool.d.ts +0 -14
- package/dist/threads/pool.d.ts.map +0 -1
- package/dist/threads/pool.js +0 -93
- package/dist/threads/pool.js.map +0 -1
- package/dist/threads/worker-runner.d.ts +0 -2
- package/dist/threads/worker-runner.d.ts.map +0 -1
- package/dist/threads/worker-runner.js +0 -71
- package/dist/threads/worker-runner.js.map +0 -1
- package/dist/validator/validator.d.ts +0 -360
- package/dist/validator/validator.d.ts.map +0 -1
- package/dist/validator/validator.js +0 -931
- package/dist/validator/validator.js.map +0 -1
- package/dist/websocket/orchestrator.d.ts +0 -11
- package/dist/websocket/orchestrator.d.ts.map +0 -1
- package/dist/websocket/orchestrator.js +0 -238
- package/dist/websocket/orchestrator.js.map +0 -1
- package/dist/websocket/server.d.ts +0 -66
- package/dist/websocket/server.d.ts.map +0 -1
- package/dist/websocket/server.js +0 -158
- package/dist/websocket/server.js.map +0 -1
- package/dist/websocket/socket.d.ts +0 -119
- package/dist/websocket/socket.d.ts.map +0 -1
- package/dist/websocket/socket.js +0 -242
- package/dist/websocket/socket.js.map +0 -1
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Caching"
|
|
3
|
-
description: "API Reference for ExisJS Caching and Revalidation (`exisjs/cache`)."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Caching (`exisjs/cache`)
|
|
7
|
-
|
|
8
|
-
ExisJS comes with a highly sophisticated built-in caching system that natively supports **stale-while-revalidate** semantics, intelligent `tags`-based cache invalidation, and multiple backing stores (Memory, FileSystem, and Redis).
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## `cacheMiddleware(options)`
|
|
13
|
-
|
|
14
|
-
The primary way to use the cache is by attaching the `cacheMiddleware` directly to your GET routes. It intercepts responses, stores them in the cache, and serves them efficiently on subsequent identical requests.
|
|
15
|
-
|
|
16
|
-
ExisJS automatically injects an `X-Exis-Cache: HIT` or `X-Exis-Cache: MISS` header into the HTTP response so you can debug your cache behavior instantly!
|
|
17
|
-
|
|
18
|
-
**Class-Based (OOP)**
|
|
19
|
-
```typescript filename="src/http/stats/route.ts"
|
|
20
|
-
import { Controller, Get, Use } from 'exisjs/decorators'
|
|
21
|
-
import { cacheMiddleware } from 'exisjs/cache'
|
|
22
|
-
|
|
23
|
-
@Controller('/stats')
|
|
24
|
-
export default class StatsController {
|
|
25
|
-
|
|
26
|
-
@Get('/')
|
|
27
|
-
@Use(
|
|
28
|
-
cacheMiddleware({
|
|
29
|
-
ttlMs: 60 * 1000, // 60 seconds
|
|
30
|
-
keyGenerator: (req) => `stats:${req.query.period || 'all'}`
|
|
31
|
-
})
|
|
32
|
-
)
|
|
33
|
-
async getStats() {
|
|
34
|
-
return db.queryHeavyStats()
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
**Functional**
|
|
40
|
-
```typescript filename="src/http/stats/route.ts"
|
|
41
|
-
import { controller, route } from 'exisjs/router'
|
|
42
|
-
import { cacheMiddleware } from 'exisjs/cache'
|
|
43
|
-
|
|
44
|
-
export default controller({
|
|
45
|
-
getStats: route.get('/', {
|
|
46
|
-
middleware: [
|
|
47
|
-
cacheMiddleware({
|
|
48
|
-
ttlMs: 60 * 1000, // 60 seconds
|
|
49
|
-
|
|
50
|
-
// You MUST provide a keyGenerator to prevent data leaking between users!
|
|
51
|
-
keyGenerator: (req) => `stats:${req.query.period || 'all'}`
|
|
52
|
-
})
|
|
53
|
-
],
|
|
54
|
-
async handle() {
|
|
55
|
-
// This heavy query only runs once every 60 seconds per period
|
|
56
|
-
return db.queryHeavyStats()
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### Options
|
|
63
|
-
|
|
64
|
-
- **`keyGenerator`** `(req => string)`: **Required.** Generates a unique cache key for the request. Never use a static key if the response varies by User ID or Query Parameters.
|
|
65
|
-
- **`ttlMs`** `(number)`: Time to live in milliseconds. If omitted, the cache never inherently expires based on time (relies on manual tags instead).
|
|
66
|
-
- **`tags`** `(string[] | function)`: A list of tags to associate with this cache entry, used for Next.js-style on-demand revalidation.
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
## Tag-Based Cache Invalidation
|
|
71
|
-
|
|
72
|
-
Instead of waiting for a TTL to expire, you can invalidate caches instantly using tags. This is exactly how Next.js App Router caching works.
|
|
73
|
-
|
|
74
|
-
When you cache a route, assign it a tag:
|
|
75
|
-
|
|
76
|
-
```typescript filename="src/http/products/route.ts"
|
|
77
|
-
import { cacheMiddleware } from 'exisjs/cache'
|
|
78
|
-
|
|
79
|
-
route.get('/:id', {
|
|
80
|
-
middleware: [
|
|
81
|
-
cacheMiddleware({
|
|
82
|
-
// We tag this cache entry with the specific product ID
|
|
83
|
-
tags: (req) => [`product-${req.params.id}`, 'all-products'],
|
|
84
|
-
keyGenerator: (req) => `product:${req.params.id}`
|
|
85
|
-
})
|
|
86
|
-
],
|
|
87
|
-
async handle(ctx) {
|
|
88
|
-
return db.products.find(ctx.params.id)
|
|
89
|
-
}
|
|
90
|
-
})
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Later, when a user updates the product via a `POST` or `PUT` route, you can instantly bust all caches tied to that tag using `revalidateTag()`!
|
|
94
|
-
|
|
95
|
-
```typescript filename="src/http/products/route.ts"
|
|
96
|
-
import { revalidateTag } from 'exisjs/cache'
|
|
97
|
-
|
|
98
|
-
route.put('/:id', {
|
|
99
|
-
async handle(ctx) {
|
|
100
|
-
await db.products.update(ctx.params.id, ctx.body)
|
|
101
|
-
|
|
102
|
-
// Instantly purge the cache across the entire cluster!
|
|
103
|
-
await revalidateTag(`product-${ctx.params.id}`)
|
|
104
|
-
|
|
105
|
-
return { success: true }
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
## Cache Drivers
|
|
113
|
-
|
|
114
|
-
ExisJS natively provides three driver implementations:
|
|
115
|
-
|
|
116
|
-
1. **`FileSystemCacheStore`**: (Default). Writes cache data to `.exis/cache/*.json` on the disk. Extremely fast for static data and survives server reboots.
|
|
117
|
-
2. **`MemoryCacheStore`**: Keeps caches purely in RAM. Perfect for development or extremely high-throughput, short-TTL data. (Includes automatic broadcast sync if running in an ExisJS Cluster).
|
|
118
|
-
3. **`RedisCacheStore`**: The standard for production. Uses a minimal Redis client to handle distributed caching across massive fleets of servers.
|
|
119
|
-
|
|
120
|
-
### Switching Stores Globally
|
|
121
|
-
|
|
122
|
-
While you can pass a `store` option directly into `cacheMiddleware()`, it is usually better to set the global cache store during application boot:
|
|
123
|
-
|
|
124
|
-
```typescript filename="src/server.ts"
|
|
125
|
-
import { exis } from 'exisjs'
|
|
126
|
-
import { setCacheStore, RedisCacheStore } from 'exisjs/cache'
|
|
127
|
-
|
|
128
|
-
const app = exis()
|
|
129
|
-
|
|
130
|
-
// Use Redis instead of the default FileSystem cache
|
|
131
|
-
setCacheStore(new RedisCacheStore(myRedisClient))
|
|
132
|
-
```
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Circuit Breaker"
|
|
3
|
-
description: "Strict API Reference for the Circuit Breaker resilience utility."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Circuit Breaker (`exisjs/app`)
|
|
7
|
-
|
|
8
|
-
This document provides the strict API signatures and TypeScript interfaces exported for the `CircuitBreaker` utility. For high-level resilience guides, see the [Circuit Breaker Guide](/docs/circuit-breaker).
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## `CircuitBreaker` Class
|
|
13
|
-
|
|
14
|
-
The `CircuitBreaker` class is a state machine that monitors the execution of async actions to prevent cascading failures.
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
import { CircuitBreaker } from 'exisjs/app'
|
|
18
|
-
|
|
19
|
-
class CircuitBreaker {
|
|
20
|
-
constructor(options?: CircuitBreakerOptions)
|
|
21
|
-
|
|
22
|
-
// The current state of the breaker
|
|
23
|
-
public state: CircuitState
|
|
24
|
-
|
|
25
|
-
// Executes the provided async action through the breaker
|
|
26
|
-
fire<T>(action: () => Promise<T>): Promise<T>
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### `CircuitBreakerOptions`
|
|
31
|
-
|
|
32
|
-
```typescript
|
|
33
|
-
interface CircuitBreakerOptions {
|
|
34
|
-
/** Maximum number of sequential failures before the breaker transitions to OPEN */
|
|
35
|
-
failureThreshold?: number // Default: 5
|
|
36
|
-
|
|
37
|
-
/** Time to wait (in ms) before transitioning from OPEN to HALF_OPEN to test recovery */
|
|
38
|
-
resetTimeoutMs?: number // Default: 10000 (10 seconds)
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## `CircuitState` Enum
|
|
45
|
-
|
|
46
|
-
The circuit breaker operates in one of three states.
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
enum CircuitState {
|
|
50
|
-
// Normal operation, all requests pass
|
|
51
|
-
CLOSED = 'CLOSED',
|
|
52
|
-
|
|
53
|
-
// Failing, all requests are instantly rejected
|
|
54
|
-
OPEN = 'OPEN',
|
|
55
|
-
|
|
56
|
-
// Testing recovery, exactly ONE request is allowed through
|
|
57
|
-
HALF_OPEN = 'HALF_OPEN',
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
## `CircuitBreakerError`
|
|
64
|
-
|
|
65
|
-
If `fire()` is called while the breaker is `OPEN` (or if it is `HALF_OPEN` and a probe is already in flight), the breaker will instantly reject the promise with a `CircuitBreakerError`.
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
class CircuitBreakerError extends Error {
|
|
69
|
-
constructor(message: string)
|
|
70
|
-
}
|
|
71
|
-
```
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Queues"
|
|
3
|
-
description: "API Reference for ExisJS Background Queues (`exisjs/queue`)."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Queues (`exisjs/queue`)
|
|
7
|
-
|
|
8
|
-
ExisJS ships with a highly robust, Redis-backed background job queue mechanism. It supports strict payload validation, exponential backoff, delayed execution, and lifecycle observability hooks, seamlessly integrated right into the core framework.
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## Configuration (`exis.config.ts`)
|
|
13
|
-
|
|
14
|
-
Before using the queue system, you must configure your driver (either `memory` for local development or `redis` for production). This is defined globally in your `exis.config.ts` file.
|
|
15
|
-
|
|
16
|
-
```typescript filename="exis.config.ts"
|
|
17
|
-
import { defineConfig } from 'exisjs/config'
|
|
18
|
-
|
|
19
|
-
export default async (phase: string) => {
|
|
20
|
-
return defineConfig({
|
|
21
|
-
queue: {
|
|
22
|
-
driver: phase === 'development' ? 'memory' : 'redis',
|
|
23
|
-
redisUrl: process.env.REDIS_URL,
|
|
24
|
-
maxConcurrent: 100, // Maximum active workers
|
|
25
|
-
maxQueue: 1000 // Maximum waiting jobs
|
|
26
|
-
}
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Defining Jobs (File-Based Routing)
|
|
34
|
-
|
|
35
|
-
ExisJS uses highly intuitive **File-Based Job Routing**.
|
|
36
|
-
|
|
37
|
-
To create a new background job, simply create a file in the `src/jobs/` directory and `export default defineJob(...)`. The framework will automatically discover, load, and bind the job queue on boot!
|
|
38
|
-
|
|
39
|
-
```typescript filename="src/jobs/SendEmailJob.ts"
|
|
40
|
-
import { defineJob } from 'exisjs/queue'
|
|
41
|
-
import { tex } from 'exisjs/validator'
|
|
42
|
-
|
|
43
|
-
export default defineJob({
|
|
44
|
-
name: 'send-email',
|
|
45
|
-
|
|
46
|
-
// ExisJS will automatically validate incoming queue payloads against this schema!
|
|
47
|
-
schema: tex.object({
|
|
48
|
-
to: tex.email(),
|
|
49
|
-
subject: tex.string(),
|
|
50
|
-
html: tex.string()
|
|
51
|
-
}),
|
|
52
|
-
|
|
53
|
-
// Set default retry and backoff behavior
|
|
54
|
-
defaultOptions: {
|
|
55
|
-
attempts: 3,
|
|
56
|
-
backoff: {
|
|
57
|
-
type: 'exponential',
|
|
58
|
-
delay: 5000 // 5s, 25s, 125s...
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
// Observability Hooks
|
|
63
|
-
onJobFailed(payload, err) {
|
|
64
|
-
console.error(`Job failed on attempt ${payload.attemptsMade}`, err)
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
onJobFailedPermanently(payload, err) {
|
|
68
|
-
// Alert Sentry or Slack!
|
|
69
|
-
console.error(`Job fatally died after all retries!`, err)
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
// The actual background execution logic
|
|
73
|
-
async handler(job) {
|
|
74
|
-
// job.data is completely type-safe and strictly validated by the schema!
|
|
75
|
-
const { to, subject, html } = job.data
|
|
76
|
-
|
|
77
|
-
await mailer.send({ to, subject, html })
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### Job Definition Properties
|
|
83
|
-
- **`name`** *(string)*: Unique identifier for the queue.
|
|
84
|
-
- **`schema`** *(Validator)*: An ExisJS validator object to validate the payload structure.
|
|
85
|
-
- **`handler`** *(function)*: The logic to execute (optional if using file-based job routing).
|
|
86
|
-
- **`defaultOptions`** *(JobOptions)*: Global options for retry counts and delays.
|
|
87
|
-
- **`cron`** *(string)*: A cron expression (e.g. `'0 * * * *'`) for scheduling the job recursively.
|
|
88
|
-
- **Hooks**: `onJobStart`, `onJobSuccess`, `onJobFailed`, `onJobFailedPermanently`.
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## Enqueuing Jobs
|
|
93
|
-
|
|
94
|
-
You can dispatch a job from anywhere in your application (Controllers, Gateways, Services) using the `enqueue` function.
|
|
95
|
-
|
|
96
|
-
```typescript filename="src/http/users/route.ts"
|
|
97
|
-
import { controller, route } from 'exisjs/router'
|
|
98
|
-
import { enqueue } from 'exisjs/queue'
|
|
99
|
-
import { SendEmailJob } from '../../jobs/SendEmailJob'
|
|
100
|
-
|
|
101
|
-
export default controller({
|
|
102
|
-
register: route.post('/register', {
|
|
103
|
-
async handle(ctx) {
|
|
104
|
-
const user = await db.users.create(ctx.body)
|
|
105
|
-
|
|
106
|
-
// Dispatch the job to the background queue!
|
|
107
|
-
await enqueue('send-email', {
|
|
108
|
-
to: user.email,
|
|
109
|
-
subject: 'Welcome to ExisJS!',
|
|
110
|
-
html: '<h1>Welcome aboard!</h1>'
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
return { success: true }
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
})
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### Delaying Execution
|
|
120
|
-
You can override the `defaultOptions` on a per-dispatch basis. For example, to delay a job by 15 minutes:
|
|
121
|
-
|
|
122
|
-
```typescript
|
|
123
|
-
await enqueue('send-email', payload, {
|
|
124
|
-
delay: 15 * 60 * 1000, // 15 minutes in milliseconds
|
|
125
|
-
attempts: 5
|
|
126
|
-
})
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
---
|
|
130
|
-
|
|
131
|
-
### Cron / Scheduled Jobs
|
|
132
|
-
|
|
133
|
-
Because ExisJS uses file-based routing for jobs, implementing recurring Cron jobs is completely trivial. Just add a `cron` property to your `defineJob` config!
|
|
134
|
-
|
|
135
|
-
```typescript filename="src/jobs/CleanupJob.ts"
|
|
136
|
-
import { defineJob } from 'exisjs/queue'
|
|
137
|
-
|
|
138
|
-
export default defineJob({
|
|
139
|
-
name: 'cleanup-stale-sessions',
|
|
140
|
-
cron: '0 0 * * *', // Run every day at midnight
|
|
141
|
-
|
|
142
|
-
async handler() {
|
|
143
|
-
await db.query('DELETE FROM sessions WHERE expiresAt < NOW()')
|
|
144
|
-
}
|
|
145
|
-
})
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### The `JobPayload` Object
|
|
149
|
-
|
|
150
|
-
When your handler executes, it receives a `JobPayload` containing the following properties:
|
|
151
|
-
- **`id`**: The unique generated UUID for this specific job execution.
|
|
152
|
-
- **`name`**: The name of the queue.
|
|
153
|
-
- **`data`**: The raw, strongly-typed, validated payload.
|
|
154
|
-
- **`attemptsMade`**: How many times this specific job has failed and retried.
|
|
155
|
-
- **`opts`**: The options (delays, backoff strategy) this job is running under.
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Storage & Uploads"
|
|
3
|
-
description: "API Reference for ExisJS Storage and File Uploads (`exisjs/storage`)."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Storage & Uploads (`exisjs/storage`)
|
|
7
|
-
|
|
8
|
-
ExisJS provides native, extremely memory-efficient support for handling `multipart/form-data` file uploads.
|
|
9
|
-
|
|
10
|
-
Instead of buffering large files into RAM (which can easily crash Node.js servers under heavy load), ExisJS streams file chunks directly from the network socket into the disk using a highly optimized Busboy integration.
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## How it Works
|
|
15
|
-
|
|
16
|
-
When you invoke `streamUpload`, ExisJS takes over the raw socket stream. As bytes come in from the network, they are instantly piped to the disk.
|
|
17
|
-
|
|
18
|
-
Because ExisJS parses the multipart stream on the fly:
|
|
19
|
-
1. Your Node.js RAM footprint stays incredibly flat, even when users upload massive 10GB video files.
|
|
20
|
-
2. Form text fields are extracted in real-time. Once the upload finishes, ExisJS automatically merges all text fields directly into `req.body` so your subsequent logic (or validators) can treat them like a normal JSON payload!
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## 1. Functional Example (`streamUpload`)
|
|
25
|
-
|
|
26
|
-
If you are using the Functional architecture, import the `streamUpload` helper from `exisjs/storage` and pass it your request context.
|
|
27
|
-
|
|
28
|
-
### Example Usage
|
|
29
|
-
|
|
30
|
-
```typescript filename="src/http/upload/route.ts"
|
|
31
|
-
import { controller, route } from 'exisjs/router'
|
|
32
|
-
import { streamUpload } from 'exisjs/storage'
|
|
33
|
-
import { HttpError } from 'exisjs/error'
|
|
34
|
-
|
|
35
|
-
export default controller({
|
|
36
|
-
uploadAvatar: route.post('/avatar', {
|
|
37
|
-
async handle(ctx) {
|
|
38
|
-
try {
|
|
39
|
-
const { files, fields } = await streamUpload(ctx.req, {
|
|
40
|
-
dest: './storage/avatars'
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
if (files.length === 0) {
|
|
44
|
-
throw HttpError.badRequest('No file provided')
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const uploadedFile = files[0]
|
|
48
|
-
|
|
49
|
-
// Log the fields submitted with the form
|
|
50
|
-
console.log('User ID associated with upload:', fields.userId)
|
|
51
|
-
|
|
52
|
-
return {
|
|
53
|
-
success: true,
|
|
54
|
-
filename: uploadedFile.filename,
|
|
55
|
-
savedAt: uploadedFile.destPath,
|
|
56
|
-
size: uploadedFile.size,
|
|
57
|
-
mimetype: uploadedFile.mimetype
|
|
58
|
-
}
|
|
59
|
-
} catch (err) {
|
|
60
|
-
// streamUpload throws HttpErrors if the request isn't valid multipart/form-data
|
|
61
|
-
throw err
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
})
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### Return Value
|
|
69
|
-
|
|
70
|
-
`streamUpload` resolves a Promise containing an object with two properties:
|
|
71
|
-
|
|
72
|
-
#### 1. `fields` (`Record<string, string>`)
|
|
73
|
-
An object containing all the non-file text fields submitted in the `multipart/form-data` payload. Note that `streamUpload` automatically populates `ctx.req.body` with these fields as well upon completion.
|
|
74
|
-
|
|
75
|
-
#### 2. `files` (`Array<object>`)
|
|
76
|
-
An array of successfully streamed files. Each object contains:
|
|
77
|
-
- **`fieldname`**: The name of the HTML form field (e.g., `avatar`).
|
|
78
|
-
- **`filename`**: The original name of the file uploaded by the user.
|
|
79
|
-
- **`mimetype`**: The MIME type of the file (e.g., `image/png`).
|
|
80
|
-
- **`destPath`**: The absolute path on your server's disk where the file was safely saved. *Note: ExisJS appends a randomized unique suffix to the filename to prevent overwrites.*
|
|
81
|
-
- **`size`**: The total file size in bytes.
|
|
82
|
-
|
|
83
|
-
---
|
|
84
|
-
|
|
85
|
-
## 2. Class-Based Example (`req.streamUpload`)
|
|
86
|
-
|
|
87
|
-
If you are using Object-Oriented `@Controller` classes, ExisJS natively extends the Request object. You do not even need to import `streamUpload`!
|
|
88
|
-
|
|
89
|
-
Simply inject the Request object via the `@Req()` decorator and call `req.streamUpload(dest)` directly.
|
|
90
|
-
|
|
91
|
-
```typescript filename="src/http/upload/route.ts"
|
|
92
|
-
import { Controller, Post, Req } from 'exisjs/decorators'
|
|
93
|
-
import type { Request } from 'exisjs'
|
|
94
|
-
import { HttpError } from 'exisjs/error'
|
|
95
|
-
|
|
96
|
-
@Controller('/upload')
|
|
97
|
-
export default class UploadController {
|
|
98
|
-
|
|
99
|
-
@Post('/avatar')
|
|
100
|
-
async handleUpload(@Req() req: Request) {
|
|
101
|
-
// Exactly identical to streamUpload(req, { dest: ... })
|
|
102
|
-
// We pass the destination path directly into the Request method
|
|
103
|
-
const { files, fields } = await req.streamUpload('./storage/avatars')
|
|
104
|
-
|
|
105
|
-
if (!files.length) throw HttpError.badRequest('Missing file')
|
|
106
|
-
|
|
107
|
-
// Remember: fields are also populated into req.body!
|
|
108
|
-
console.log(req.body.userId === fields.userId) // true!
|
|
109
|
-
|
|
110
|
-
return {
|
|
111
|
-
message: 'Upload successful',
|
|
112
|
-
files
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
```
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Swagger & OpenAPI"
|
|
3
|
-
description: "API Reference for ExisJS auto-generated Swagger UI (`exisjs/swagger`)."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Swagger / OpenAPI (`exisjs/swagger`)
|
|
7
|
-
|
|
8
|
-
ExisJS ships with native, zero-configuration OpenAPI 3.0 generation.
|
|
9
|
-
|
|
10
|
-
Because ExisJS routes strongly integrate with `exisjs/validator`, the framework automatically introspects your validators (`tex.object`, `tex.string`, etc.) across all controllers and automatically generates a fully interactive Swagger UI!
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## 1. Global Setup (`exis.config.ts`)
|
|
15
|
-
|
|
16
|
-
Because the Swagger engine needs to read all registered routes at boot time, you mount it globally using a Plugin.
|
|
17
|
-
|
|
18
|
-
Create a new file in your `plugins` directory:
|
|
19
|
-
|
|
20
|
-
```typescript filename="src/plugins/swagger.ts"
|
|
21
|
-
import { definePlugin } from 'exisjs/plugin'
|
|
22
|
-
import { serveSwagger } from 'exisjs/swagger'
|
|
23
|
-
|
|
24
|
-
export const swaggerPlugin = definePlugin({
|
|
25
|
-
name: 'swagger-ui',
|
|
26
|
-
register(app) {
|
|
27
|
-
serveSwagger(app, {
|
|
28
|
-
path: '/docs', // The URL where the UI will be served
|
|
29
|
-
title: 'My ExisJS API',
|
|
30
|
-
version: '1.0.0',
|
|
31
|
-
|
|
32
|
-
// Optionally attach global OpenAPI components (like Bearer Auth definitions)
|
|
33
|
-
components: {
|
|
34
|
-
securitySchemes: {
|
|
35
|
-
bearerAuth: {
|
|
36
|
-
type: 'http',
|
|
37
|
-
scheme: 'bearer',
|
|
38
|
-
bearerFormat: 'JWT',
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
Then, natively register your plugin in `exis.config.ts`:
|
|
48
|
-
|
|
49
|
-
```typescript filename="exis.config.ts"
|
|
50
|
-
import { defineConfig } from 'exisjs/config'
|
|
51
|
-
import { swaggerPlugin } from './src/plugins/swagger'
|
|
52
|
-
|
|
53
|
-
export default defineConfig({
|
|
54
|
-
plugins: [
|
|
55
|
-
swaggerPlugin()
|
|
56
|
-
]
|
|
57
|
-
})
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
|
|
62
|
-
## 2. Automatic Schema Inference
|
|
63
|
-
|
|
64
|
-
You do not need to write YAML files or manually define your request bodies in Swagger. ExisJS reads the schemas directly from your code!
|
|
65
|
-
|
|
66
|
-
### Functional Architecture
|
|
67
|
-
|
|
68
|
-
When using the `route.*` functions, anything you pass to `schema.body`, `schema.query`, or `schema.response` is instantly injected into the Swagger documentation.
|
|
69
|
-
|
|
70
|
-
```typescript filename="src/http/users/route.ts"
|
|
71
|
-
import { controller, route } from 'exisjs/router'
|
|
72
|
-
import { tex } from 'exisjs/validator'
|
|
73
|
-
|
|
74
|
-
export default controller({
|
|
75
|
-
createUser: route.post('/', {
|
|
76
|
-
schema: {
|
|
77
|
-
// ExisJS automatically builds an OpenAPI schema from this validator!
|
|
78
|
-
body: tex.object({
|
|
79
|
-
email: tex.email(),
|
|
80
|
-
age: tex.number({ min: 18 })
|
|
81
|
-
}),
|
|
82
|
-
response: tex.object({
|
|
83
|
-
id: tex.string(),
|
|
84
|
-
success: tex.boolean()
|
|
85
|
-
})
|
|
86
|
-
},
|
|
87
|
-
async handle(ctx) {
|
|
88
|
-
return { id: '123', success: true }
|
|
89
|
-
}
|
|
90
|
-
})
|
|
91
|
-
})
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Class-Based (OOP) Architecture
|
|
95
|
-
|
|
96
|
-
If you are using OOP Decorators, ExisJS achieves the exact same result by reading your `@Body()`, `@Query()`, and `@Returns()` decorators.
|
|
97
|
-
|
|
98
|
-
```typescript filename="src/http/users/route.ts"
|
|
99
|
-
import { Controller, Post, Body, Returns } from 'exisjs/decorators'
|
|
100
|
-
import { tex } from 'exisjs/validator'
|
|
101
|
-
|
|
102
|
-
const CreateUserSchema = tex.object({
|
|
103
|
-
email: tex.email(),
|
|
104
|
-
age: tex.number({ min: 18 })
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
const ResponseSchema = tex.object({
|
|
108
|
-
id: tex.string(),
|
|
109
|
-
success: tex.boolean()
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
@Controller('/users')
|
|
113
|
-
export default class UserController {
|
|
114
|
-
|
|
115
|
-
@Post('/')
|
|
116
|
-
@Returns(ResponseSchema)
|
|
117
|
-
async createUser(@Body(CreateUserSchema) body: any) {
|
|
118
|
-
return { id: '123', success: true }
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
---
|
|
124
|
-
|
|
125
|
-
## 3. Accessing the UI
|
|
126
|
-
|
|
127
|
-
Once you boot your application, simply navigate to the `path` you defined in your plugin:
|
|
128
|
-
|
|
129
|
-
- **Swagger UI**: `http://localhost:4000/docs`
|
|
130
|
-
- **Raw OpenAPI JSON**: `http://localhost:4000/docs/json`
|
|
131
|
-
|
|
132
|
-
The generated Swagger UI is fully interactive, meaning you can authenticate and test your API directly from the browser!
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zero-config Drizzle ORM Integration.
|
|
3
|
-
*
|
|
4
|
-
* Automatically initializes Drizzle using `process.env.DATABASE_URL`.
|
|
5
|
-
*
|
|
6
|
-
* Peer Dependencies required:
|
|
7
|
-
* npm install drizzle-orm postgres
|
|
8
|
-
*/
|
|
9
|
-
export declare function drizzle<TSchema extends Record<string, unknown>>(schema: TSchema): any;
|
|
10
|
-
//# sourceMappingURL=drizzle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"drizzle.d.ts","sourceRoot":"","sources":["../../src/integrations/drizzle.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,wBAAgB,OAAO,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7D,MAAM,EAAE,OAAO,OA6BhB"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Zero-config Drizzle ORM Integration.
|
|
4
|
-
*
|
|
5
|
-
* Automatically initializes Drizzle using `process.env.DATABASE_URL`.
|
|
6
|
-
*
|
|
7
|
-
* Peer Dependencies required:
|
|
8
|
-
* npm install drizzle-orm postgres
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.drizzle = drizzle;
|
|
12
|
-
function drizzle(schema) {
|
|
13
|
-
const url = process.env.DATABASE_URL;
|
|
14
|
-
if (!url) {
|
|
15
|
-
throw new Error('process.env.DATABASE_URL is missing. Cannot initialize Drizzle.');
|
|
16
|
-
}
|
|
17
|
-
// Dynamic require to avoid bloating the core framework bundle if Drizzle isn't used.
|
|
18
|
-
let postgres;
|
|
19
|
-
let drizzleOrm;
|
|
20
|
-
try {
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
22
|
-
postgres = require('postgres');
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
24
|
-
drizzleOrm = require('drizzle-orm/postgres-js');
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
throw new Error('Missing dependencies. Please run: npm install drizzle-orm postgres');
|
|
28
|
-
}
|
|
29
|
-
// Initialize the connection pool
|
|
30
|
-
const sql = postgres(url, { max: 10 });
|
|
31
|
-
// Return the drizzle client
|
|
32
|
-
return drizzleOrm.drizzle(sql, { schema });
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=drizzle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"drizzle.js","sourceRoot":"","sources":["../../src/integrations/drizzle.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAEH,0BA8BC;AA9BD,SAAgB,OAAO,CACrB,MAAe;IAEf,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAA;IACpC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAA;IACH,CAAC;IAED,qFAAqF;IACrF,IAAI,QAAa,CAAA;IACjB,IAAI,UAAe,CAAA;IAEnB,IAAI,CAAC;QACH,iEAAiE;QACjE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;QAC9B,iEAAiE;QACjE,UAAU,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAA;IACjD,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAA;IACH,CAAC;IAED,iCAAiC;IACjC,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAA;IAEtC,4BAA4B;IAC5B,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;AAC5C,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type JWTOptions } from '../auth/jwt';
|
|
2
|
-
export declare const jwt: {
|
|
3
|
-
/**
|
|
4
|
-
* Automatically signs a JWT token using `process.env.JWT_SECRET`.
|
|
5
|
-
*/
|
|
6
|
-
sign(payload: Record<string, unknown>, options?: JWTOptions): string;
|
|
7
|
-
/**
|
|
8
|
-
* Automatically verifies a JWT token using `process.env.JWT_SECRET`.
|
|
9
|
-
*/
|
|
10
|
-
verify<T = unknown>(token: string): T;
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=jwt.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/integrations/jwt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,UAAU,EAAE,MAAM,aAAa,CAAA;AAEjE,eAAO,MAAM,GAAG;IACd;;OAEG;kBACW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,UAAU,GAAG,MAAM;IASpE;;OAEG;WACI,CAAC,mBAAmB,MAAM,GAAG,CAAC;CAQtC,CAAA"}
|