exisjs 0.7.6 → 0.7.8
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/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +12 -0
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/clean.d.ts +5 -0
- package/dist/cli/commands/clean.d.ts.map +1 -0
- package/dist/cli/commands/clean.js +30 -0
- package/dist/cli/commands/clean.js.map +1 -0
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/dev.js +15 -1
- package/dist/cli/commands/dev.js.map +1 -1
- package/dist/cli/commands/generate.d.ts +6 -1
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +57 -2
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/index.js +16 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/manifest.d.ts +1 -0
- package/dist/cli/manifest.d.ts.map +1 -1
- package/dist/cli/manifest.js +161 -23
- package/dist/cli/manifest.js.map +1 -1
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +9 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/types.d.ts +4 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/cron/expressions.d.ts +45 -0
- package/dist/cron/expressions.d.ts.map +1 -0
- package/dist/cron/expressions.js +87 -0
- package/dist/cron/expressions.js.map +1 -0
- package/dist/cron/index.d.ts +6 -0
- package/dist/cron/index.d.ts.map +1 -0
- package/dist/cron/index.js +22 -0
- package/dist/cron/index.js.map +1 -0
- package/dist/cron/job.d.ts +50 -0
- package/dist/cron/job.d.ts.map +1 -0
- package/dist/cron/job.js +247 -0
- package/dist/cron/job.js.map +1 -0
- package/dist/cron/manager.d.ts +105 -0
- package/dist/cron/manager.d.ts.map +1 -0
- package/dist/cron/manager.js +245 -0
- package/dist/cron/manager.js.map +1 -0
- package/dist/cron/parser.d.ts +22 -0
- package/dist/cron/parser.d.ts.map +1 -0
- package/dist/cron/parser.js +269 -0
- package/dist/cron/parser.js.map +1 -0
- package/dist/cron/types.d.ts +76 -0
- package/dist/cron/types.d.ts.map +1 -0
- package/dist/cron/types.js +3 -0
- package/dist/cron/types.js.map +1 -0
- package/dist/decorators/constants.d.ts +2 -0
- package/dist/decorators/constants.d.ts.map +1 -1
- package/dist/decorators/constants.js +3 -1
- package/dist/decorators/constants.js.map +1 -1
- package/dist/decorators/core.d.ts +29 -11
- package/dist/decorators/core.d.ts.map +1 -1
- package/dist/decorators/core.js +49 -11
- package/dist/decorators/core.js.map +1 -1
- package/dist/decorators/cron.d.ts +57 -0
- package/dist/decorators/cron.d.ts.map +1 -0
- package/dist/decorators/cron.js +143 -0
- package/dist/decorators/cron.js.map +1 -0
- package/dist/decorators/index.d.ts +2 -0
- package/dist/decorators/index.d.ts.map +1 -1
- package/dist/decorators/index.js +2 -0
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/params.d.ts +97 -2
- package/dist/decorators/params.d.ts.map +1 -1
- package/dist/decorators/params.js +94 -2
- package/dist/decorators/params.js.map +1 -1
- package/dist/decorators/routing.d.ts +81 -16
- package/dist/decorators/routing.d.ts.map +1 -1
- package/dist/decorators/routing.js +81 -16
- package/dist/decorators/routing.js.map +1 -1
- package/dist/docs/content/cron.mdx +196 -0
- package/dist/docs/content/errors.mdx +58 -9
- package/dist/docs/content/structure.mdx +1 -1
- package/dist/docs/content/swagger.mdx +289 -0
- package/dist/docs/reference/cron.mdx +300 -0
- package/dist/docs/reference/decorators.mdx +8 -0
- package/dist/docs/reference/error.mdx +44 -0
- package/dist/docs/reference/swagger.mdx +226 -0
- package/dist/docs/reference/validator.mdx +1 -1
- package/dist/router/boundary.d.ts +24 -2
- package/dist/router/boundary.d.ts.map +1 -1
- package/dist/router/boundary.js +24 -2
- package/dist/router/boundary.js.map +1 -1
- package/dist/router/controller-registrar.d.ts.map +1 -1
- package/dist/router/controller-registrar.js +52 -3
- package/dist/router/controller-registrar.js.map +1 -1
- package/dist/router/route-builder.d.ts +196 -33
- package/dist/router/route-builder.d.ts.map +1 -1
- package/dist/router/route-builder.js +171 -11
- package/dist/router/route-builder.js.map +1 -1
- package/dist/router/route-scanner.d.ts +6 -0
- package/dist/router/route-scanner.d.ts.map +1 -1
- package/dist/router/route-scanner.js +69 -812
- package/dist/router/route-scanner.js.map +1 -1
- package/dist/router/router.d.ts.map +1 -1
- package/dist/router/router.js +27 -0
- package/dist/router/router.js.map +1 -1
- package/dist/router/scanner/boundary-loader.d.ts +18 -0
- package/dist/router/scanner/boundary-loader.d.ts.map +1 -0
- package/dist/router/scanner/boundary-loader.js +539 -0
- package/dist/router/scanner/boundary-loader.js.map +1 -0
- package/dist/router/scanner/cron-mounter.d.ts +15 -0
- package/dist/router/scanner/cron-mounter.d.ts.map +1 -0
- package/dist/router/scanner/cron-mounter.js +216 -0
- package/dist/router/scanner/cron-mounter.js.map +1 -0
- package/dist/router/scanner/error-mounter.d.ts +14 -0
- package/dist/router/scanner/error-mounter.d.ts.map +1 -0
- package/dist/router/scanner/error-mounter.js +200 -0
- package/dist/router/scanner/error-mounter.js.map +1 -0
- package/dist/router/scanner/fs-scanner.d.ts +25 -0
- package/dist/router/scanner/fs-scanner.d.ts.map +1 -0
- package/dist/router/scanner/fs-scanner.js +115 -0
- package/dist/router/scanner/fs-scanner.js.map +1 -0
- package/dist/router/scanner/functional-compiler.d.ts +9 -0
- package/dist/router/scanner/functional-compiler.d.ts.map +1 -0
- package/dist/router/scanner/functional-compiler.js +233 -0
- package/dist/router/scanner/functional-compiler.js.map +1 -0
- package/dist/router/scanner/index.d.ts +9 -0
- package/dist/router/scanner/index.d.ts.map +1 -0
- package/dist/router/scanner/index.js +19 -0
- package/dist/router/scanner/index.js.map +1 -0
- package/dist/router/types.d.ts +15 -0
- package/dist/router/types.d.ts.map +1 -1
- package/dist/server/app.d.ts +2 -0
- package/dist/server/app.d.ts.map +1 -1
- package/dist/server/app.js +3 -0
- package/dist/server/app.js.map +1 -1
- package/dist/server/helpers/body-parser.d.ts +18 -0
- package/dist/server/helpers/body-parser.d.ts.map +1 -0
- package/dist/server/helpers/body-parser.js +246 -0
- package/dist/server/helpers/body-parser.js.map +1 -0
- package/dist/server/helpers/cookie.d.ts +4 -0
- package/dist/server/helpers/cookie.d.ts.map +1 -0
- package/dist/server/helpers/cookie.js +61 -0
- package/dist/server/helpers/cookie.js.map +1 -0
- package/dist/server/helpers/etag.d.ts +3 -0
- package/dist/server/helpers/etag.d.ts.map +1 -0
- package/dist/server/helpers/etag.js +25 -0
- package/dist/server/helpers/etag.js.map +1 -0
- package/dist/server/helpers/index.d.ts +6 -0
- package/dist/server/helpers/index.d.ts.map +1 -0
- package/dist/server/helpers/index.js +21 -0
- package/dist/server/helpers/index.js.map +1 -0
- package/dist/server/helpers/ip.d.ts +9 -0
- package/dist/server/helpers/ip.d.ts.map +1 -0
- package/dist/server/helpers/ip.js +62 -0
- package/dist/server/helpers/ip.js.map +1 -0
- package/dist/server/helpers/stream.d.ts +4 -0
- package/dist/server/helpers/stream.d.ts.map +1 -0
- package/dist/server/helpers/stream.js +193 -0
- package/dist/server/helpers/stream.js.map +1 -0
- package/dist/server/request.d.ts +1 -139
- package/dist/server/request.d.ts.map +1 -1
- package/dist/server/request.js +19 -433
- package/dist/server/request.js.map +1 -1
- package/dist/server/response.d.ts +105 -158
- package/dist/server/response.d.ts.map +1 -1
- package/dist/server/response.js +121 -423
- package/dist/server/response.js.map +1 -1
- package/dist/swagger/decorators.d.ts +81 -0
- package/dist/swagger/decorators.d.ts.map +1 -0
- package/dist/swagger/decorators.js +172 -0
- package/dist/swagger/decorators.js.map +1 -0
- package/dist/swagger/generator.d.ts +19 -0
- package/dist/swagger/generator.d.ts.map +1 -0
- package/dist/swagger/generator.js +344 -0
- package/dist/swagger/generator.js.map +1 -0
- package/dist/swagger/index.d.ts +31 -0
- package/dist/swagger/index.d.ts.map +1 -0
- package/dist/swagger/index.js +53 -0
- package/dist/swagger/index.js.map +1 -0
- package/dist/swagger/mounter.d.ts +7 -0
- package/dist/swagger/mounter.d.ts.map +1 -0
- package/dist/swagger/mounter.js +56 -0
- package/dist/swagger/mounter.js.map +1 -0
- package/dist/swagger/types.d.ts +190 -0
- package/dist/swagger/types.d.ts.map +1 -0
- package/dist/swagger/types.js +3 -0
- package/dist/swagger/types.js.map +1 -0
- package/dist/swagger/ui.d.ts +6 -0
- package/dist/swagger/ui.d.ts.map +1 -0
- package/dist/swagger/ui.js +118 -0
- package/dist/swagger/ui.js.map +1 -0
- package/dist/validator/builder.d.ts +223 -0
- package/dist/validator/builder.d.ts.map +1 -0
- package/dist/validator/builder.js +517 -0
- package/dist/validator/builder.js.map +1 -0
- package/dist/validator/engine.d.ts +19 -0
- package/dist/validator/engine.d.ts.map +1 -0
- package/dist/validator/engine.js +568 -0
- package/dist/validator/engine.js.map +1 -0
- package/dist/validator/error.d.ts +12 -0
- package/dist/validator/error.d.ts.map +1 -0
- package/dist/validator/error.js +63 -0
- package/dist/validator/error.js.map +1 -0
- package/dist/validator/pagination.d.ts +40 -0
- package/dist/validator/pagination.d.ts.map +1 -0
- package/dist/validator/pagination.js +60 -0
- package/dist/validator/pagination.js.map +1 -0
- package/dist/validator/tex.d.ts +6 -158
- package/dist/validator/tex.d.ts.map +1 -1
- package/dist/validator/tex.js +14 -971
- package/dist/validator/tex.js.map +1 -1
- package/dist/validator/types.d.ts +83 -0
- package/dist/validator/types.d.ts.map +1 -0
- package/dist/validator/types.js +3 -0
- package/dist/validator/types.js.map +1 -0
- package/package.json +9 -1
|
@@ -1,37 +1,102 @@
|
|
|
1
1
|
import type { HttpMethod, RouteSchema } from '../types';
|
|
2
2
|
export declare function createMethodDecorator(method: HttpMethod): (path?: string, schema?: RouteSchema<any, any, any, any>) => any;
|
|
3
3
|
/**
|
|
4
|
-
* Marks a method as
|
|
4
|
+
* Marks a controller method as an HTTP GET route handler.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* @param path Optional route path relative to controller prefix
|
|
7
|
+
* @param schema Optional validation schema
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* @Controller('/users')
|
|
12
|
+
* export class UserController {
|
|
13
|
+
* @Get('/:id')
|
|
14
|
+
* getUser(@Param('id') id: string) {
|
|
15
|
+
* return { id }
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
14
19
|
*/
|
|
15
20
|
export declare const Get: (path?: string, schema?: RouteSchema<any, any, any, any>) => any;
|
|
16
21
|
/**
|
|
17
|
-
* Marks a method as
|
|
18
|
-
*
|
|
19
|
-
* Example:
|
|
22
|
+
* Marks a controller method as an HTTP POST route handler.
|
|
20
23
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
24
|
+
* @param path Optional route path relative to controller prefix
|
|
25
|
+
* @param schema Optional validation schema
|
|
23
26
|
*
|
|
24
|
-
* @
|
|
25
|
-
*
|
|
26
|
-
* @
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* @Controller('/users')
|
|
30
|
+
* export class UserController {
|
|
31
|
+
* @Post('/')
|
|
32
|
+
* createUser(@Body() body: CreateUserDto) {
|
|
33
|
+
* return { created: body.name }
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
27
37
|
*/
|
|
28
38
|
export declare const Post: (path?: string, schema?: RouteSchema<any, any, any, any>) => any;
|
|
39
|
+
/**
|
|
40
|
+
* Marks a controller method as an HTTP PUT route handler.
|
|
41
|
+
*
|
|
42
|
+
* @param path Optional route path relative to controller prefix
|
|
43
|
+
* @param schema Optional validation schema
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* @Controller('/users')
|
|
48
|
+
* export class UserController {
|
|
49
|
+
* @Put('/:id')
|
|
50
|
+
* updateUser(@Param('id') id: string, @Body() body: UpdateUserDto) {
|
|
51
|
+
* return { updated: id }
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
29
56
|
export declare const Put: (path?: string, schema?: RouteSchema<any, any, any, any>) => any;
|
|
57
|
+
/**
|
|
58
|
+
* Marks a controller method as an HTTP PATCH route handler.
|
|
59
|
+
*
|
|
60
|
+
* @param path Optional route path relative to controller prefix
|
|
61
|
+
* @param schema Optional validation schema
|
|
62
|
+
*/
|
|
30
63
|
export declare const Patch: (path?: string, schema?: RouteSchema<any, any, any, any>) => any;
|
|
64
|
+
/**
|
|
65
|
+
* Marks a controller method as an HTTP DELETE route handler.
|
|
66
|
+
*
|
|
67
|
+
* @param path Optional route path relative to controller prefix
|
|
68
|
+
* @param schema Optional validation schema
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* @Controller('/users')
|
|
73
|
+
* export class UserController {
|
|
74
|
+
* @Delete('/:id')
|
|
75
|
+
* deleteUser(@Param('id') id: string) {
|
|
76
|
+
* return { deleted: true }
|
|
77
|
+
* }
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
31
81
|
export declare const Delete: (path?: string, schema?: RouteSchema<any, any, any, any>) => any;
|
|
82
|
+
/**
|
|
83
|
+
* Marks a controller method as an HTTP OPTIONS route handler.
|
|
84
|
+
*/
|
|
32
85
|
export declare const Options: (path?: string, schema?: RouteSchema<any, any, any, any>) => any;
|
|
86
|
+
/**
|
|
87
|
+
* Marks a controller method as an HTTP HEAD route handler.
|
|
88
|
+
*/
|
|
33
89
|
export declare const Head: (path?: string, schema?: RouteSchema<any, any, any, any>) => any;
|
|
90
|
+
/**
|
|
91
|
+
* Marks a controller method to handle any HTTP method (GET, POST, PUT, DELETE, PATCH, etc.).
|
|
92
|
+
*/
|
|
34
93
|
export declare const All: (path?: string, schema?: RouteSchema<any, any, any, any>) => any;
|
|
94
|
+
/**
|
|
95
|
+
* Marks a controller method as an HTTP CONNECT route handler.
|
|
96
|
+
*/
|
|
35
97
|
export declare const Connect: (path?: string, schema?: RouteSchema<any, any, any, any>) => any;
|
|
98
|
+
/**
|
|
99
|
+
* Marks a controller method as an HTTP TRACE route handler.
|
|
100
|
+
*/
|
|
36
101
|
export declare const Trace: (path?: string, schema?: RouteSchema<any, any, any, any>) => any;
|
|
37
102
|
//# sourceMappingURL=routing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/decorators/routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAKvD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,UAAU,IACrC,aAAS,EAAE,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,GAAG,CAoC3E;AAED
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/decorators/routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAKvD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,UAAU,IACrC,aAAS,EAAE,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,GAAG,CAoC3E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,GAAG,2BAvDuB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,GAuD1B,CAAA;AAE/C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,IAAI,2BA1EsB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,GA0ExB,CAAA;AAEjD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,GAAG,2BA7FuB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,GA6F1B,CAAA;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,KAAK,2BArGqB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,GAqGtB,CAAA;AAEnD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM,2BAxHoB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,GAwHpB,CAAA;AAErD;;GAEG;AACH,eAAO,MAAM,OAAO,2BA7HmB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,GA6HlB,CAAA;AAEvD;;GAEG;AACH,eAAO,MAAM,IAAI,2BAlIsB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,GAkIxB,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,GAAG,2BAvIuB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,GAuI1B,CAAA;AAE/C;;GAEG;AACH,eAAO,MAAM,OAAO,2BA5ImB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,GA4IlB,CAAA;AAEvD;;GAEG;AACH,eAAO,MAAM,KAAK,2BAjJqB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,GAiJtB,CAAA"}
|
|
@@ -36,37 +36,102 @@ function createMethodDecorator(method) {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* Marks a method as
|
|
39
|
+
* Marks a controller method as an HTTP GET route handler.
|
|
40
40
|
*
|
|
41
|
-
*
|
|
41
|
+
* @param path Optional route path relative to controller prefix
|
|
42
|
+
* @param schema Optional validation schema
|
|
42
43
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* @Controller('/users')
|
|
47
|
+
* export class UserController {
|
|
48
|
+
* @Get('/:id')
|
|
49
|
+
* getUser(@Param('id') id: string) {
|
|
50
|
+
* return { id }
|
|
51
|
+
* }
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
49
54
|
*/
|
|
50
55
|
exports.Get = createMethodDecorator('GET');
|
|
51
56
|
/**
|
|
52
|
-
* Marks a method as
|
|
53
|
-
*
|
|
54
|
-
* Example:
|
|
57
|
+
* Marks a controller method as an HTTP POST route handler.
|
|
55
58
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
59
|
+
* @param path Optional route path relative to controller prefix
|
|
60
|
+
* @param schema Optional validation schema
|
|
58
61
|
*
|
|
59
|
-
* @
|
|
60
|
-
*
|
|
61
|
-
* @
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* @Controller('/users')
|
|
65
|
+
* export class UserController {
|
|
66
|
+
* @Post('/')
|
|
67
|
+
* createUser(@Body() body: CreateUserDto) {
|
|
68
|
+
* return { created: body.name }
|
|
69
|
+
* }
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
62
72
|
*/
|
|
63
73
|
exports.Post = createMethodDecorator('POST');
|
|
74
|
+
/**
|
|
75
|
+
* Marks a controller method as an HTTP PUT route handler.
|
|
76
|
+
*
|
|
77
|
+
* @param path Optional route path relative to controller prefix
|
|
78
|
+
* @param schema Optional validation schema
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* @Controller('/users')
|
|
83
|
+
* export class UserController {
|
|
84
|
+
* @Put('/:id')
|
|
85
|
+
* updateUser(@Param('id') id: string, @Body() body: UpdateUserDto) {
|
|
86
|
+
* return { updated: id }
|
|
87
|
+
* }
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
64
91
|
exports.Put = createMethodDecorator('PUT');
|
|
92
|
+
/**
|
|
93
|
+
* Marks a controller method as an HTTP PATCH route handler.
|
|
94
|
+
*
|
|
95
|
+
* @param path Optional route path relative to controller prefix
|
|
96
|
+
* @param schema Optional validation schema
|
|
97
|
+
*/
|
|
65
98
|
exports.Patch = createMethodDecorator('PATCH');
|
|
99
|
+
/**
|
|
100
|
+
* Marks a controller method as an HTTP DELETE route handler.
|
|
101
|
+
*
|
|
102
|
+
* @param path Optional route path relative to controller prefix
|
|
103
|
+
* @param schema Optional validation schema
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* @Controller('/users')
|
|
108
|
+
* export class UserController {
|
|
109
|
+
* @Delete('/:id')
|
|
110
|
+
* deleteUser(@Param('id') id: string) {
|
|
111
|
+
* return { deleted: true }
|
|
112
|
+
* }
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
66
116
|
exports.Delete = createMethodDecorator('DELETE');
|
|
117
|
+
/**
|
|
118
|
+
* Marks a controller method as an HTTP OPTIONS route handler.
|
|
119
|
+
*/
|
|
67
120
|
exports.Options = createMethodDecorator('OPTIONS');
|
|
121
|
+
/**
|
|
122
|
+
* Marks a controller method as an HTTP HEAD route handler.
|
|
123
|
+
*/
|
|
68
124
|
exports.Head = createMethodDecorator('HEAD');
|
|
125
|
+
/**
|
|
126
|
+
* Marks a controller method to handle any HTTP method (GET, POST, PUT, DELETE, PATCH, etc.).
|
|
127
|
+
*/
|
|
69
128
|
exports.All = createMethodDecorator('ALL');
|
|
129
|
+
/**
|
|
130
|
+
* Marks a controller method as an HTTP CONNECT route handler.
|
|
131
|
+
*/
|
|
70
132
|
exports.Connect = createMethodDecorator('CONNECT');
|
|
133
|
+
/**
|
|
134
|
+
* Marks a controller method as an HTTP TRACE route handler.
|
|
135
|
+
*/
|
|
71
136
|
exports.Trace = createMethodDecorator('TRACE');
|
|
72
137
|
//# sourceMappingURL=routing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/decorators/routing.ts"],"names":[],"mappings":";;;AAKA,sDAqCC;AAzCD,2CAAwD;AACxD,8CAAgD;AAChD,sCAAkC;AAElC,SAAgB,qBAAqB,CAAC,MAAkB;IACtD,OAAO,UAAU,IAAI,GAAG,EAAE,EAAE,MAAwC;QAClE,IAAI,MAAM,KAAK,KAAK,IAAI,MAAM,EAAE,IAAI,EAAE,CAAC;YACrC,eAAM,CAAC,IAAI,CACT,cAAc,IAAI,+DAA+D,CAClF,CAAA;QACH,CAAC;QAED,OAAO,UACL,MAAW,EACX,oBAA4C,EAC5C,UAAqC;YAErC,IACE,OAAO,oBAAoB,KAAK,QAAQ;gBACxC,oBAAoB,KAAK,IAAI;gBAC7B,MAAM,IAAI,oBAAoB,EAC9B,CAAC;gBACD,mCAAmC;gBACnC,yBAAc,CAAC,GAAG,CAAC,MAAM,EAAE,sBAAU,EAAE;oBACrC,MAAM;oBACN,IAAI;oBACJ,MAAM;iBACP,CAAC,CAAA;YACJ,CAAC;iBAAM,CAAC;gBACN,yCAAyC;gBACzC,MAAM,KAAK,GAAG,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAA;gBACtE,MAAM,IAAI,GAAG,oBAAoB,IAAI,UAAU,EAAE,IAAI,CAAA;gBACrD,yBAAc,CAAC,IAAI,CAAC,KAAK,EAAE,0BAAc,EAAE;oBACzC,MAAM;oBACN,IAAI;oBACJ,MAAM;oBACN,WAAW,EAAE,IAAI;iBAClB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC,CAAA;IACH,CAAC,CAAA;AACH,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/decorators/routing.ts"],"names":[],"mappings":";;;AAKA,sDAqCC;AAzCD,2CAAwD;AACxD,8CAAgD;AAChD,sCAAkC;AAElC,SAAgB,qBAAqB,CAAC,MAAkB;IACtD,OAAO,UAAU,IAAI,GAAG,EAAE,EAAE,MAAwC;QAClE,IAAI,MAAM,KAAK,KAAK,IAAI,MAAM,EAAE,IAAI,EAAE,CAAC;YACrC,eAAM,CAAC,IAAI,CACT,cAAc,IAAI,+DAA+D,CAClF,CAAA;QACH,CAAC;QAED,OAAO,UACL,MAAW,EACX,oBAA4C,EAC5C,UAAqC;YAErC,IACE,OAAO,oBAAoB,KAAK,QAAQ;gBACxC,oBAAoB,KAAK,IAAI;gBAC7B,MAAM,IAAI,oBAAoB,EAC9B,CAAC;gBACD,mCAAmC;gBACnC,yBAAc,CAAC,GAAG,CAAC,MAAM,EAAE,sBAAU,EAAE;oBACrC,MAAM;oBACN,IAAI;oBACJ,MAAM;iBACP,CAAC,CAAA;YACJ,CAAC;iBAAM,CAAC;gBACN,yCAAyC;gBACzC,MAAM,KAAK,GAAG,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAA;gBACtE,MAAM,IAAI,GAAG,oBAAoB,IAAI,UAAU,EAAE,IAAI,CAAA;gBACrD,yBAAc,CAAC,IAAI,CAAC,KAAK,EAAE,0BAAc,EAAE;oBACzC,MAAM;oBACN,IAAI;oBACJ,MAAM;oBACN,WAAW,EAAE,IAAI;iBAClB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC,CAAA;IACH,CAAC,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACU,QAAA,GAAG,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAA;AAE/C;;;;;;;;;;;;;;;;GAgBG;AACU,QAAA,IAAI,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAA;AAEjD;;;;;;;;;;;;;;;;GAgBG;AACU,QAAA,GAAG,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAA;AAE/C;;;;;GAKG;AACU,QAAA,KAAK,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAA;AAEnD;;;;;;;;;;;;;;;;GAgBG;AACU,QAAA,MAAM,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAA;AAErD;;GAEG;AACU,QAAA,OAAO,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAA;AAEvD;;GAEG;AACU,QAAA,IAAI,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAA;AAEjD;;GAEG;AACU,QAAA,GAAG,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAA;AAE/C;;GAEG;AACU,QAAA,OAAO,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAA;AAEvD;;GAEG;AACU,QAAA,KAAK,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAA"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
---
|
|
2
|
+
nextUrl: "/docs/queues"
|
|
3
|
+
nextTitle: "Queues & Background Jobs"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Cron & Task Scheduling
|
|
7
|
+
|
|
8
|
+
ExisJS includes a built-in Cron and Task Scheduling system designed for reliability and developer ergonomic efficiency. It resolves common Node.js scheduling challenges such as timer drift, concurrent execution overlap, unhandled exceptions crashing the process, timezone/DST inaccuracies, and zombie timers during hot reload or process shutdown.
|
|
9
|
+
|
|
10
|
+
Both **Functional** and **Class-Based (OOP)** paradigms are fully supported with complete feature parity.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## File Conventions & Auto-Discovery
|
|
15
|
+
|
|
16
|
+
ExisJS auto-mounts cron jobs using two straightforward conventions:
|
|
17
|
+
|
|
18
|
+
1. **Single-File Management (`src/http/cron.ts` or `src/http/cron.js`)**:
|
|
19
|
+
Define and manage all your scheduled tasks in a single file located at `src/http/cron.ts` (or inside route slices such as `src/http/admin/cron.ts`). Multiple jobs can be exported using named exports, a default export, or an array of jobs.
|
|
20
|
+
|
|
21
|
+
2. **Dedicated Directory (`src/cron/*`)**:
|
|
22
|
+
Organize distinct tasks into separate files inside `src/cron/` (e.g. `src/cron/sync.ts`, `src/cron/reports.ts`). Every file inside `src/cron/` is automatically registered upon application boot.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 1. Functional Paradigm (`cron`)
|
|
27
|
+
|
|
28
|
+
Import `cron` from `exisjs/cron` to define scheduled tasks.
|
|
29
|
+
|
|
30
|
+
### Single-File Multi-Job Example
|
|
31
|
+
|
|
32
|
+
Manage multiple jobs within `src/http/cron.ts`:
|
|
33
|
+
|
|
34
|
+
```typescript filename="src/http/cron.ts"
|
|
35
|
+
import { cron, CronExpression } from 'exisjs/cron'
|
|
36
|
+
|
|
37
|
+
// Job 1: Nightly synchronization
|
|
38
|
+
export const syncJob = cron({
|
|
39
|
+
name: 'nightly-sync',
|
|
40
|
+
schedule: CronExpression.EVERY_DAY_AT_MIDNIGHT,
|
|
41
|
+
timezone: 'UTC',
|
|
42
|
+
preventOverlap: true,
|
|
43
|
+
retries: 2,
|
|
44
|
+
retryDelayMs: 3000,
|
|
45
|
+
async run({ app, log }) {
|
|
46
|
+
log.info('Executing nightly sync...')
|
|
47
|
+
},
|
|
48
|
+
onError(err, { log }) {
|
|
49
|
+
log.error({ err }, 'Nightly sync failed after retries')
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
// Job 2: Frequent polling using human-readable duration
|
|
54
|
+
export const pollJob = cron.every('5 minutes', async ({ log }) => {
|
|
55
|
+
log.info('Checking external queue...')
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
// Job 3: Recurring millisecond interval
|
|
59
|
+
export const heartbeat = cron.interval(30_000, async ({ log }) => {
|
|
60
|
+
log.info('System heartbeat active')
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
// Job 4: Startup delayed task (runs 5 seconds after server boots)
|
|
64
|
+
export const warmup = cron.timeout(5_000, async ({ app, log }) => {
|
|
65
|
+
log.info('Pre-warming cache...')
|
|
66
|
+
})
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Dedicated File Example
|
|
70
|
+
|
|
71
|
+
```typescript filename="src/cron/cleanup.ts"
|
|
72
|
+
import { cron, CronExpression } from 'exisjs/cron'
|
|
73
|
+
|
|
74
|
+
export default cron({
|
|
75
|
+
name: 'db-cleanup',
|
|
76
|
+
schedule: CronExpression.EVERY_DAY_AT_2AM,
|
|
77
|
+
timezone: 'America/New_York',
|
|
78
|
+
preventOverlap: true,
|
|
79
|
+
async run({ log }) {
|
|
80
|
+
log.info('Purging stale database records...')
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 2. Class-Based (OOP) Paradigm (`@Cron`)
|
|
88
|
+
|
|
89
|
+
In the OOP paradigm, methods on any `@Injectable()` service or class can be scheduled using decorators from `exisjs/decorators` with full **Dependency Injection** support.
|
|
90
|
+
|
|
91
|
+
```typescript filename="src/cron/cleanup.ts"
|
|
92
|
+
import { Injectable, Cron, Interval, TimeoutTask, CronExpression } from 'exisjs/decorators'
|
|
93
|
+
import { DatabaseService } from '../services/database.service'
|
|
94
|
+
import { LoggerService } from '../services/logger.service'
|
|
95
|
+
|
|
96
|
+
@Injectable()
|
|
97
|
+
export default class CleanupService {
|
|
98
|
+
constructor(
|
|
99
|
+
private db: DatabaseService,
|
|
100
|
+
private logger: LoggerService
|
|
101
|
+
) {}
|
|
102
|
+
|
|
103
|
+
@Cron(CronExpression.EVERY_DAY_AT_MIDNIGHT, {
|
|
104
|
+
name: 'nightly-purge',
|
|
105
|
+
timezone: 'UTC',
|
|
106
|
+
preventOverlap: true,
|
|
107
|
+
})
|
|
108
|
+
async purgeOldSessions() {
|
|
109
|
+
this.logger.info('Purging expired user sessions...')
|
|
110
|
+
await this.db.deleteExpiredSessions()
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@Interval(60_000, { name: 'health-ping' })
|
|
114
|
+
async checkDatabaseHealth() {
|
|
115
|
+
await this.db.ping()
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@TimeoutTask(5_000, { name: 'cache-warmup' })
|
|
119
|
+
async warmupCache() {
|
|
120
|
+
this.logger.info('Pre-warming cache...')
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 3. Core Reliability Features
|
|
128
|
+
|
|
129
|
+
### Overlap Prevention (`preventOverlap: true`)
|
|
130
|
+
Standard timers trigger subsequent ticks even if the current execution is stalled, leading to connection exhaustion and database lock contention. With `preventOverlap: true` (default: `true`), ExisJS locks execution during active jobs and skips overlapping executions until the current run completes.
|
|
131
|
+
|
|
132
|
+
### Error Isolation Sandbox
|
|
133
|
+
Exceptions thrown inside cron handlers are caught within an isolated execution boundary. An error in a background task will never crash the HTTP server or stop subsequent cron triggers. Errors are logged and forwarded to an optional `onError(err, context)` hook for monitoring integration (e.g. Sentry, Datadog).
|
|
134
|
+
|
|
135
|
+
### IANA Timezones & Daylight Saving Time (DST)
|
|
136
|
+
Supports standard IANA timezones (e.g. `'America/New_York'`, `'Asia/Kolkata'`, `'Europe/London'`, `'UTC'`). Next execution dates are computed accurately across DST transitions using cached native `Intl.DateTimeFormat` evaluations.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 4. Programmatic Runtime Management (`app.cron`)
|
|
141
|
+
|
|
142
|
+
You can inspect, pause, resume, or trigger jobs dynamically at runtime via `app.cron`:
|
|
143
|
+
|
|
144
|
+
```typescript filename="src/http/admin/cron/route.ts"
|
|
145
|
+
import { controller, route } from 'exisjs/router'
|
|
146
|
+
|
|
147
|
+
export default controller({
|
|
148
|
+
// Query status and metrics of all registered jobs
|
|
149
|
+
listJobs: route.get('/', async ({ app }) => {
|
|
150
|
+
return {
|
|
151
|
+
jobs: app.cron.status()
|
|
152
|
+
}
|
|
153
|
+
}),
|
|
154
|
+
|
|
155
|
+
// Manually trigger a scheduled job on demand
|
|
156
|
+
triggerJob: route.post('/:name/trigger', async ({ app, params }) => {
|
|
157
|
+
const result = await app.cron.trigger(params.name)
|
|
158
|
+
return { success: true, result }
|
|
159
|
+
}),
|
|
160
|
+
|
|
161
|
+
// Pause a job
|
|
162
|
+
pauseJob: route.post('/:name/pause', async ({ app, params }) => {
|
|
163
|
+
app.cron.pause(params.name)
|
|
164
|
+
return { success: true, message: `Job ${params.name} paused` }
|
|
165
|
+
}),
|
|
166
|
+
|
|
167
|
+
// Resume a paused job
|
|
168
|
+
resumeJob: route.post('/:name/resume', async ({ app, params }) => {
|
|
169
|
+
app.cron.resume(params.name)
|
|
170
|
+
return { success: true, message: `Job ${params.name} resumed` }
|
|
171
|
+
}),
|
|
172
|
+
})
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## 5. Graceful Shutdown & Draining
|
|
178
|
+
|
|
179
|
+
When the application receives a shutdown signal (`SIGINT`, `SIGTERM`, or `app.close()`):
|
|
180
|
+
1. The scheduler stops scheduling future ticks immediately.
|
|
181
|
+
2. Active timers are unreferenced (`unref()`).
|
|
182
|
+
3. Running tasks are allowed to finish within the configured drain window (default: 5000ms) before the process terminates.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## 6. CLI Scaffolding
|
|
187
|
+
|
|
188
|
+
Generate cron job files using the ExisJS CLI:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
# Functional Job (generates src/cron/cleanup.ts)
|
|
192
|
+
npx exis generate cron cleanup
|
|
193
|
+
|
|
194
|
+
# Class-Based Job (generates src/cron/cleanup.ts with @Injectable & @Cron)
|
|
195
|
+
npx exis generate cron cleanup --oop
|
|
196
|
+
```
|
|
@@ -163,40 +163,89 @@ ExisJS provides mechanisms for granular and centralized error handling.
|
|
|
163
163
|
|
|
164
164
|
### 1. Framework-Level Exception Handler (`src/http/error.ts`)
|
|
165
165
|
|
|
166
|
-
Instead of writing manual `try/catch` blocks in every route or
|
|
166
|
+
Instead of writing manual `try/catch` blocks in every route or wiring `app.onError` inside `server.ts`, ExisJS provides a dedicated file convention: **`src/http/error.ts`** (or `src/http/*.error.ts`).
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
When `src/http/error.ts` is present, ExisJS automatically discovers and mounts it during application boot as the global exception interceptor. Any uncaught exception, thrown `HttpError`, or validation failure anywhere in your application is routed to this file.
|
|
169
|
+
|
|
170
|
+
#### Functional Paradigm
|
|
169
171
|
|
|
170
172
|
```typescript filename="src/http/error.ts"
|
|
171
173
|
import type { Request, Response } from 'exisjs'
|
|
174
|
+
import { isDev } from 'exisjs/config'
|
|
172
175
|
|
|
173
176
|
/**
|
|
174
|
-
* Global Exception Handler
|
|
175
|
-
* Auto-mounted at startup to intercept all unhandled exceptions.
|
|
177
|
+
* Global Framework Exception Handler
|
|
178
|
+
* Auto-mounted at startup to intercept all unhandled exceptions and validation errors.
|
|
176
179
|
*/
|
|
177
180
|
export function onError(err: any, req: Request, res: Response) {
|
|
178
181
|
const status = err.statusCode || err.status || 500
|
|
182
|
+
const isOperational = Boolean(err.isOperational || err.statusCode < 500)
|
|
183
|
+
|
|
184
|
+
// 1. Log unexpected crashes in production to external APM (Sentry, Datadog, Axiom)
|
|
185
|
+
if (!isOperational && !isDev) {
|
|
186
|
+
// e.g. Sentry.captureException(err, { extra: { path: req.path, method: req.method } })
|
|
187
|
+
req.log.error({ err }, '[Fatal] Unhandled Server Exception')
|
|
188
|
+
}
|
|
179
189
|
|
|
180
|
-
//
|
|
190
|
+
// 2. Format a unified, standard error envelope for client applications
|
|
181
191
|
res.status(status).json({
|
|
182
192
|
success: false,
|
|
183
193
|
error: {
|
|
184
|
-
code: err.code || '
|
|
194
|
+
code: err.code || (status === 500 ? 'INTERNAL_SERVER_ERROR' : 'ERROR'),
|
|
185
195
|
message: err.message || 'Internal Server Error',
|
|
196
|
+
...(err.details ? { details: err.details } : {}),
|
|
197
|
+
...(err.errors ? { errors: err.errors } : {}),
|
|
186
198
|
path: req.path,
|
|
199
|
+
timestamp: new Date().toISOString(),
|
|
187
200
|
},
|
|
188
201
|
})
|
|
189
202
|
}
|
|
190
203
|
```
|
|
191
204
|
|
|
205
|
+
#### Class-Based (OOP) Paradigm
|
|
206
|
+
|
|
207
|
+
```typescript filename="src/http/error.ts"
|
|
208
|
+
import type { Request, Response } from 'exisjs'
|
|
209
|
+
import { isDev } from 'exisjs/config'
|
|
210
|
+
|
|
211
|
+
export default class GlobalErrorHandler {
|
|
212
|
+
onError(err: any, req: Request, res: Response) {
|
|
213
|
+
const status = err.statusCode || err.status || 500
|
|
214
|
+
const isOperational = Boolean(err.isOperational || err.statusCode < 500)
|
|
215
|
+
|
|
216
|
+
if (!isOperational && !isDev) {
|
|
217
|
+
req.log.error({ err }, '[Fatal] Unhandled Server Exception')
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
res.status(status).json({
|
|
221
|
+
success: false,
|
|
222
|
+
error: {
|
|
223
|
+
code: err.code || (status === 500 ? 'INTERNAL_SERVER_ERROR' : 'ERROR'),
|
|
224
|
+
message: err.message || 'Internal Server Error',
|
|
225
|
+
...(err.details ? { details: err.details } : {}),
|
|
226
|
+
path: req.path,
|
|
227
|
+
timestamp: new Date().toISOString(),
|
|
228
|
+
},
|
|
229
|
+
})
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
192
234
|
> [!TIP]
|
|
193
|
-
> You can
|
|
235
|
+
> **Scaffold with CLI**: You can generate this file instantly using the ExisJS CLI:
|
|
194
236
|
> ```bash
|
|
195
|
-
> exis generate error
|
|
237
|
+
> npx exis generate error
|
|
196
238
|
> # or shorthand:
|
|
197
|
-
> exis g error
|
|
239
|
+
> npx exis g error
|
|
198
240
|
> ```
|
|
199
241
|
|
|
242
|
+
#### What `src/http/error.ts` Intercepts:
|
|
243
|
+
- **`HttpError` instances**: (e.g. `throw HttpError.notFound()`, `throw HttpError.unauthorized()`).
|
|
244
|
+
- **Validation failures**: Zod, Tex, or Yup validation rejections automatically pass structured `err.errors` and `err.details`.
|
|
245
|
+
- **Database / Network exceptions**: Postgres connection failures, timeout rejections, and third-party API errors.
|
|
246
|
+
- **Syntax errors**: Malformed JSON bodies or bad request payloads.
|
|
247
|
+
|
|
248
|
+
|
|
200
249
|
### 2. Exception Filters (`catchError`)
|
|
201
250
|
|
|
202
251
|
ExisJS allows you to create **Exception Filters** to globally intercept specific types of errors.
|
|
@@ -138,7 +138,7 @@ export const UserParamsSchema = tex.object({ id: tex.string() });
|
|
|
138
138
|
```
|
|
139
139
|
|
|
140
140
|
`tex` is the only validation engine. Schemas here are also the source for
|
|
141
|
-
OpenAPI generation
|
|
141
|
+
OpenAPI generation via `exisjs/swagger`.
|
|
142
142
|
|
|
143
143
|
---
|
|
144
144
|
|