@lakutata/entrypoint 3.0.0-beta.6 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -26
- package/README.zh-CN.md +182 -0
- package/dist/cjs/Entrypoint.d.ts +13 -7
- package/dist/cjs/Entrypoint.js +12 -6
- package/dist/cjs/adapter/commander/CommanderCLIEntrypoint.d.ts +3 -2
- package/dist/cjs/adapter/commander/CommanderCLIEntrypoint.js +3 -2
- package/dist/cjs/adapter/electron/ElectronIPCServiceEntrypoint.d.ts +2 -1
- package/dist/cjs/adapter/electron/ElectronIPCServiceEntrypoint.js +2 -1
- package/dist/cjs/adapter/express/ExpressHTTPEntrypoint.d.ts +3 -2
- package/dist/cjs/adapter/express/ExpressHTTPEntrypoint.js +8 -2
- package/dist/cjs/adapter/express/Responders.d.ts +2 -1
- package/dist/cjs/adapter/express/Responders.js +4 -2
- package/dist/cjs/adapter/express/StaticUI.d.ts +2 -1
- package/dist/cjs/adapter/express/StaticUI.js +2 -1
- package/dist/cjs/adapter/fastify/FastifyHTTPEntrypoint.d.ts +2 -1
- package/dist/cjs/adapter/fastify/FastifyHTTPEntrypoint.js +4 -1
- package/dist/cjs/adapter/fastify/Responders.d.ts +2 -1
- package/dist/cjs/adapter/fastify/Responders.js +4 -2
- package/dist/cjs/adapter/http/HTTPServiceEntrypoint.d.ts +4 -3
- package/dist/cjs/adapter/http/HTTPServiceEntrypoint.js +10 -22
- package/dist/cjs/adapter/http/HTTPServiceProxy.d.ts +190 -0
- package/dist/cjs/adapter/http/HTTPServiceProxy.js +371 -0
- package/dist/cjs/adapter/jsonrpc/JSONRPCServiceEntrypoint.d.ts +11 -7
- package/dist/cjs/adapter/jsonrpc/JSONRPCServiceEntrypoint.js +15 -26
- package/dist/cjs/adapter/schedule/ScheduleEntrypoint.d.ts +2 -1
- package/dist/cjs/adapter/schedule/ScheduleEntrypoint.js +12 -5
- package/dist/cjs/adapter/socket.io/SocketIOServiceEntrypoint.d.ts +2 -1
- package/dist/cjs/adapter/socket.io/SocketIOServiceEntrypoint.js +2 -1
- package/dist/cjs/channel/BuiltinChannels.js +4 -2
- package/dist/cjs/channel/EntrypointAdapter.d.ts +2 -2
- package/dist/cjs/decorators/HTTPAction.d.ts +5 -5
- package/dist/cjs/decorators/Schedule.d.ts +4 -2
- package/dist/cjs/decorators/Schedule.js +3 -2
- package/dist/cjs/decorators/ServiceAction.d.ts +12 -8
- package/dist/cjs/decorators/http/DELETE.d.ts +5 -5
- package/dist/cjs/decorators/http/GET.d.ts +7 -7
- package/dist/cjs/decorators/http/HEAD.d.ts +9 -9
- package/dist/cjs/decorators/http/OPTIONS.d.ts +8 -7
- package/dist/cjs/decorators/http/PATCH.d.ts +5 -5
- package/dist/cjs/decorators/http/POST.d.ts +5 -5
- package/dist/cjs/decorators/http/PUT.d.ts +7 -7
- package/dist/cjs/exceptions/AccessDeniedException.d.ts +7 -1
- package/dist/cjs/exceptions/AccessDeniedException.js +8 -3
- package/dist/cjs/exceptions/EntrypointStoppedException.d.ts +2 -1
- package/dist/cjs/exceptions/EntrypointStoppedException.js +2 -1
- package/dist/cjs/exceptions/InvalidActionGroupException.d.ts +4 -0
- package/dist/cjs/exceptions/InvalidActionGroupException.js +4 -0
- package/dist/cjs/exceptions/ServiceUnavailableException.d.ts +15 -0
- package/dist/cjs/exceptions/ServiceUnavailableException.js +18 -0
- package/dist/cjs/exports/Entrypoint.d.ts +3 -0
- package/dist/cjs/exports/Entrypoint.js +6 -1
- package/dist/cjs/lib/AccessControl.d.ts +2 -1
- package/dist/cjs/lib/AccessControl.js +2 -1
- package/dist/cjs/lib/AccessControlRule.d.ts +2 -1
- package/dist/cjs/lib/AccessControlRule.js +2 -1
- package/dist/cjs/lib/ExplicitStatus.d.ts +11 -0
- package/dist/cjs/lib/ExplicitStatus.js +22 -0
- package/dist/cjs/lib/Middleware.d.ts +2 -1
- package/dist/cjs/lib/Middleware.js +2 -1
- package/dist/cjs/lib/Preflight.d.ts +8 -0
- package/dist/cjs/lib/Preflight.js +13 -0
- package/dist/cjs/lib/ReadBody.d.ts +9 -0
- package/dist/cjs/lib/ReadBody.js +25 -0
- package/dist/cjs/lib/pattern/FlattenPattern.d.ts +14 -0
- package/dist/cjs/lib/pattern/FlattenPattern.js +59 -0
- package/dist/esm/Entrypoint.js +12 -6
- package/dist/esm/adapter/commander/CommanderCLIEntrypoint.js +3 -2
- package/dist/esm/adapter/electron/ElectronIPCServiceEntrypoint.js +2 -1
- package/dist/esm/adapter/express/ExpressHTTPEntrypoint.js +8 -2
- package/dist/esm/adapter/express/Responders.js +4 -2
- package/dist/esm/adapter/express/StaticUI.js +2 -1
- package/dist/esm/adapter/fastify/FastifyHTTPEntrypoint.js +4 -1
- package/dist/esm/adapter/fastify/Responders.js +4 -2
- package/dist/esm/adapter/http/HTTPServiceEntrypoint.js +9 -21
- package/dist/esm/adapter/http/HTTPServiceProxy.js +366 -0
- package/dist/esm/adapter/jsonrpc/JSONRPCServiceEntrypoint.js +14 -25
- package/dist/esm/adapter/schedule/ScheduleEntrypoint.js +12 -5
- package/dist/esm/adapter/socket.io/SocketIOServiceEntrypoint.js +2 -1
- package/dist/esm/channel/BuiltinChannels.js +4 -2
- package/dist/esm/decorators/Schedule.js +3 -2
- package/dist/esm/exceptions/AccessDeniedException.js +8 -3
- package/dist/esm/exceptions/EntrypointStoppedException.js +2 -1
- package/dist/esm/exceptions/InvalidActionGroupException.js +4 -0
- package/dist/esm/exceptions/ServiceUnavailableException.js +14 -0
- package/dist/esm/exports/Entrypoint.js +3 -0
- package/dist/esm/lib/AccessControl.js +2 -1
- package/dist/esm/lib/AccessControlRule.js +2 -1
- package/dist/esm/lib/ExplicitStatus.js +18 -0
- package/dist/esm/lib/Middleware.js +2 -1
- package/dist/esm/lib/Preflight.js +10 -0
- package/dist/esm/lib/ReadBody.js +22 -0
- package/dist/esm/lib/pattern/FlattenPattern.js +55 -0
- package/dist/types/Entrypoint.d.ts +13 -7
- package/dist/types/adapter/commander/CommanderCLIEntrypoint.d.ts +3 -2
- package/dist/types/adapter/electron/ElectronIPCServiceEntrypoint.d.ts +2 -1
- package/dist/types/adapter/express/ExpressHTTPEntrypoint.d.ts +3 -2
- package/dist/types/adapter/express/Responders.d.ts +2 -1
- package/dist/types/adapter/express/StaticUI.d.ts +2 -1
- package/dist/types/adapter/fastify/FastifyHTTPEntrypoint.d.ts +2 -1
- package/dist/types/adapter/fastify/Responders.d.ts +2 -1
- package/dist/types/adapter/http/HTTPServiceEntrypoint.d.ts +4 -3
- package/dist/types/adapter/http/HTTPServiceProxy.d.ts +190 -0
- package/dist/types/adapter/jsonrpc/JSONRPCServiceEntrypoint.d.ts +11 -7
- package/dist/types/adapter/schedule/ScheduleEntrypoint.d.ts +2 -1
- package/dist/types/adapter/socket.io/SocketIOServiceEntrypoint.d.ts +2 -1
- package/dist/types/channel/EntrypointAdapter.d.ts +2 -2
- package/dist/types/decorators/HTTPAction.d.ts +5 -5
- package/dist/types/decorators/Schedule.d.ts +4 -2
- package/dist/types/decorators/ServiceAction.d.ts +12 -8
- package/dist/types/decorators/http/DELETE.d.ts +5 -5
- package/dist/types/decorators/http/GET.d.ts +7 -7
- package/dist/types/decorators/http/HEAD.d.ts +9 -9
- package/dist/types/decorators/http/OPTIONS.d.ts +8 -7
- package/dist/types/decorators/http/PATCH.d.ts +5 -5
- package/dist/types/decorators/http/POST.d.ts +5 -5
- package/dist/types/decorators/http/PUT.d.ts +7 -7
- package/dist/types/exceptions/AccessDeniedException.d.ts +7 -1
- package/dist/types/exceptions/EntrypointStoppedException.d.ts +2 -1
- package/dist/types/exceptions/InvalidActionGroupException.d.ts +4 -0
- package/dist/types/exceptions/ServiceUnavailableException.d.ts +15 -0
- package/dist/types/exports/Entrypoint.d.ts +3 -0
- package/dist/types/lib/AccessControl.d.ts +2 -1
- package/dist/types/lib/AccessControlRule.d.ts +2 -1
- package/dist/types/lib/ExplicitStatus.d.ts +11 -0
- package/dist/types/lib/Middleware.d.ts +2 -1
- package/dist/types/lib/Preflight.d.ts +8 -0
- package/dist/types/lib/ReadBody.d.ts +9 -0
- package/dist/types/lib/pattern/FlattenPattern.d.ts +14 -0
- package/package.json +35 -4
|
@@ -5,11 +5,11 @@ import { HTTPContext } from '../../context/HTTPContext.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Expose the controller method as an HTTP DELETE action on a route, to delete a resource: the shorthand of
|
|
7
7
|
* `@HTTPAction(route, 'delete', …)`. The adapter assembles the input: by default, the query string merged with the
|
|
8
|
-
* parsed body (JSON
|
|
9
|
-
* against the DTO (the defaults applied, the unknown keys removed; without a DTO, it is accepted as it is),
|
|
10
|
-
* control runs when `acl` is set, then the method receives the validated input as a plain object. The query
|
|
11
|
-
* the route parameters are strings and the DTO schemas are strict: convert them with `.strict(false)`. The
|
|
12
|
-
* returned is answered by the adapter's responder: as JSON by default, with the status 204 for `undefined`;
|
|
8
|
+
* parsed body (JSON; URL encoded with Express), then the route parameters over them. The middlewares run, the input is
|
|
9
|
+
* validated against the DTO (the defaults applied, the unknown keys removed; without a DTO, it is accepted as it is),
|
|
10
|
+
* the access control runs when `acl` is set, then the method receives the validated input as a plain object. The query
|
|
11
|
+
* values and the route parameters are strings and the DTO schemas are strict: convert them with `.strict(false)`. The
|
|
12
|
+
* value returned is answered by the adapter's responder: as JSON by default, with the status 204 for `undefined`;
|
|
13
13
|
* `Result.status()` sets a status and headers. An error thrown is answered as `{errno, errMsg}` with the first 4xx
|
|
14
14
|
* `statusCode` along its causes (400 for an invalid input), else its own `statusCode`, else 500.
|
|
15
15
|
* @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
|
|
@@ -5,13 +5,13 @@ import { HTTPContext } from '../../context/HTTPContext.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Expose the controller method as an HTTP GET action on a route, to read a resource: the shorthand of
|
|
7
7
|
* `@HTTPAction(route, 'get', …)`. The adapter assembles the input: by default, the query string merged with the parsed
|
|
8
|
-
* body (JSON
|
|
9
|
-
* the DTO (the defaults applied, the unknown keys removed; without a DTO, it is accepted as it is),
|
|
10
|
-
* runs when `acl` is set, then the method receives the validated input as a plain object. The query
|
|
11
|
-
* route parameters are strings and the DTO schemas are strict: convert them with `.strict(false)`. The
|
|
12
|
-
* is answered by the adapter's responder: as JSON by default, with the status 204 for `undefined`;
|
|
13
|
-
* sets a status and headers. An error thrown is answered as `{errno, errMsg}` with the first 4xx
|
|
14
|
-
* causes (400 for an invalid input), else its own `statusCode`, else 500.
|
|
8
|
+
* body (JSON; URL encoded with Express), then the route parameters over them. The middlewares run, the input is
|
|
9
|
+
* validated against the DTO (the defaults applied, the unknown keys removed; without a DTO, it is accepted as it is),
|
|
10
|
+
* the access control runs when `acl` is set, then the method receives the validated input as a plain object. The query
|
|
11
|
+
* values and the route parameters are strings and the DTO schemas are strict: convert them with `.strict(false)`. The
|
|
12
|
+
* value returned is answered by the adapter's responder: as JSON by default, with the status 204 for `undefined`;
|
|
13
|
+
* `Result.status()` sets a status and headers. An error thrown is answered as `{errno, errMsg}` with the first 4xx
|
|
14
|
+
* `statusCode` along its causes (400 for an invalid input), else its own `statusCode`, else 500.
|
|
15
15
|
* @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
|
|
16
16
|
* prepended to it.
|
|
17
17
|
* @returns The method decorator.
|
|
@@ -5,14 +5,14 @@ import { HTTPContext } from '../../context/HTTPContext.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Expose the controller method as an HTTP HEAD action on a route, to answer the headers of a resource without its body:
|
|
7
7
|
* the shorthand of `@HTTPAction(route, 'head', …)`. The adapter assembles the input: by default, the query string
|
|
8
|
-
* merged with the parsed body (JSON
|
|
9
|
-
* input is validated against the DTO (the defaults applied, the unknown keys removed; without a DTO, it is
|
|
10
|
-
* it is), the access control runs when `acl` is set, then the method receives the validated input as a
|
|
11
|
-
* The query values and the route parameters are strings and the DTO schemas are strict: convert them with
|
|
8
|
+
* merged with the parsed body (JSON; URL encoded with Express), then the route parameters over them. The middlewares
|
|
9
|
+
* run, the input is validated against the DTO (the defaults applied, the unknown keys removed; without a DTO, it is
|
|
10
|
+
* accepted as it is), the access control runs when `acl` is set, then the method receives the validated input as a
|
|
11
|
+
* plain object. The query values and the route parameters are strings and the DTO schemas are strict: convert them with
|
|
12
12
|
* `.strict(false)`. The value returned is answered by the adapter's responder: as JSON by default, with the status 204
|
|
13
13
|
* for `undefined`; `Result.status()` sets a status and headers. An error thrown is answered as `{errno, errMsg}` with
|
|
14
|
-
* the first 4xx `statusCode` along its causes (400 for an invalid input), else its own `statusCode`, else 500.
|
|
15
|
-
*
|
|
14
|
+
* the first 4xx `statusCode` along its causes (400 for an invalid input), else its own `statusCode`, else 500. A GET
|
|
15
|
+
* action also answers the HEAD requests of its route, unless the route has a HEAD action.
|
|
16
16
|
* @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
|
|
17
17
|
* prepended to it.
|
|
18
18
|
* @returns The method decorator.
|
|
@@ -37,7 +37,7 @@ export declare function HEAD<ClassPrototype extends Controller, Method>(r: strin
|
|
|
37
37
|
* over them (the default of the adapters); the method receives it validated, as a plain object. The value returned is
|
|
38
38
|
* answered as JSON (204 for `undefined`), an error as `{errno, errMsg}` with its status (400 for an invalid input, else
|
|
39
39
|
* 500 by default).
|
|
40
|
-
*
|
|
40
|
+
* A GET action also answers the HEAD requests of its route, unless the route has a HEAD action.
|
|
41
41
|
* @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
|
|
42
42
|
* prepended to it.
|
|
43
43
|
* @param dtoConstructor The DTO class validating the input; the query values and the route parameters are strings,
|
|
@@ -50,7 +50,7 @@ export declare function HEAD<ClassPrototype extends Controller, Method, DTOConst
|
|
|
50
50
|
* `@HTTPAction(route, 'head', …)`. The input is the query string merged with the parsed body, then the route parameters
|
|
51
51
|
* over them (the default of the adapters), accepted as it is. The value returned is answered as JSON (204 for
|
|
52
52
|
* `undefined`), an error as `{errno, errMsg}` with its status (500 by default).
|
|
53
|
-
*
|
|
53
|
+
* A GET action also answers the HEAD requests of its route, unless the route has a HEAD action.
|
|
54
54
|
* @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
|
|
55
55
|
* prepended to it.
|
|
56
56
|
* @param actionOptions The action options: `acl` runs the access control rules (false by default); `name` (unique in the
|
|
@@ -68,7 +68,7 @@ export declare function HEAD<ClassPrototype extends Controller, Method>(r: strin
|
|
|
68
68
|
* then the route parameters over them (the default of the adapters); the method receives it validated, as a plain
|
|
69
69
|
* object. The value returned is answered as JSON (204 for `undefined`), an error as `{errno, errMsg}` with its status
|
|
70
70
|
* (400 for an invalid input, else 500 by default).
|
|
71
|
-
*
|
|
71
|
+
* A GET action also answers the HEAD requests of its route, unless the route has a HEAD action.
|
|
72
72
|
* @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
|
|
73
73
|
* prepended to it.
|
|
74
74
|
* @param dtoConstructor The DTO class validating the input; the query values and the route parameters are strings,
|
|
@@ -5,13 +5,14 @@ import { HTTPContext } from '../../context/HTTPContext.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Expose the controller method as an HTTP OPTIONS action on a route, to describe the communication options of a
|
|
7
7
|
* resource: the shorthand of `@HTTPAction(route, 'options', …)`. The adapter assembles the input: by default, the query
|
|
8
|
-
* string merged with the parsed body (JSON
|
|
9
|
-
* the input is validated against the DTO (the defaults applied, the unknown keys removed; without a
|
|
10
|
-
* as it is), the access control runs when `acl` is set, then the method receives the validated
|
|
11
|
-
* The query values and the route parameters are strings and the DTO schemas are strict:
|
|
12
|
-
* `.strict(false)`. The value returned is answered by the adapter's responder: as JSON by default,
|
|
13
|
-
* for `undefined`; `Result.status()` sets a status and headers. An error thrown is answered as
|
|
14
|
-
* the first 4xx `statusCode` along its causes (400 for an invalid input), else its own
|
|
8
|
+
* string merged with the parsed body (JSON; URL encoded with Express), then the route parameters over them. The
|
|
9
|
+
* middlewares run, the input is validated against the DTO (the defaults applied, the unknown keys removed; without a
|
|
10
|
+
* DTO, it is accepted as it is), the access control runs when `acl` is set, then the method receives the validated
|
|
11
|
+
* input as a plain object. The query values and the route parameters are strings and the DTO schemas are strict:
|
|
12
|
+
* convert them with `.strict(false)`. The value returned is answered by the adapter's responder: as JSON by default,
|
|
13
|
+
* with the status 204 for `undefined`; `Result.status()` sets a status and headers. An error thrown is answered as
|
|
14
|
+
* `{errno, errMsg}` with the first 4xx `statusCode` along its causes (400 for an invalid input), else its own
|
|
15
|
+
* `statusCode`, else 500.
|
|
15
16
|
* @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
|
|
16
17
|
* prepended to it.
|
|
17
18
|
* @returns The method decorator.
|
|
@@ -5,11 +5,11 @@ import { HTTPContext } from '../../context/HTTPContext.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Expose the controller method as an HTTP PATCH action on a route, to update a part of a resource: the shorthand of
|
|
7
7
|
* `@HTTPAction(route, 'patch', …)`. The adapter assembles the input: by default, the query string merged with the
|
|
8
|
-
* parsed body (JSON
|
|
9
|
-
* against the DTO (the defaults applied, the unknown keys removed; without a DTO, it is accepted as it is),
|
|
10
|
-
* control runs when `acl` is set, then the method receives the validated input as a plain object. The query
|
|
11
|
-
* the route parameters are strings and the DTO schemas are strict: convert them with `.strict(false)`. The
|
|
12
|
-
* returned is answered by the adapter's responder: as JSON by default, with the status 204 for `undefined`;
|
|
8
|
+
* parsed body (JSON; URL encoded with Express), then the route parameters over them. The middlewares run, the input is
|
|
9
|
+
* validated against the DTO (the defaults applied, the unknown keys removed; without a DTO, it is accepted as it is),
|
|
10
|
+
* the access control runs when `acl` is set, then the method receives the validated input as a plain object. The query
|
|
11
|
+
* values and the route parameters are strings and the DTO schemas are strict: convert them with `.strict(false)`. The
|
|
12
|
+
* value returned is answered by the adapter's responder: as JSON by default, with the status 204 for `undefined`;
|
|
13
13
|
* `Result.status()` sets a status and headers. An error thrown is answered as `{errno, errMsg}` with the first 4xx
|
|
14
14
|
* `statusCode` along its causes (400 for an invalid input), else its own `statusCode`, else 500.
|
|
15
15
|
* @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
|
|
@@ -5,11 +5,11 @@ import { HTTPContext } from '../../context/HTTPContext.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Expose the controller method as an HTTP POST action on a route, to create a resource or run a command: the shorthand
|
|
7
7
|
* of `@HTTPAction(route, 'post', …)`. The adapter assembles the input: by default, the query string merged with the
|
|
8
|
-
* parsed body (JSON
|
|
9
|
-
* against the DTO (the defaults applied, the unknown keys removed; without a DTO, it is accepted as it is),
|
|
10
|
-
* control runs when `acl` is set, then the method receives the validated input as a plain object. The query
|
|
11
|
-
* the route parameters are strings and the DTO schemas are strict: convert them with `.strict(false)`. The
|
|
12
|
-
* returned is answered by the adapter's responder: as JSON by default, with the status 204 for `undefined`;
|
|
8
|
+
* parsed body (JSON; URL encoded with Express), then the route parameters over them. The middlewares run, the input is
|
|
9
|
+
* validated against the DTO (the defaults applied, the unknown keys removed; without a DTO, it is accepted as it is),
|
|
10
|
+
* the access control runs when `acl` is set, then the method receives the validated input as a plain object. The query
|
|
11
|
+
* values and the route parameters are strings and the DTO schemas are strict: convert them with `.strict(false)`. The
|
|
12
|
+
* value returned is answered by the adapter's responder: as JSON by default, with the status 204 for `undefined`;
|
|
13
13
|
* `Result.status()` sets a status and headers. An error thrown is answered as `{errno, errMsg}` with the first 4xx
|
|
14
14
|
* `statusCode` along its causes (400 for an invalid input), else its own `statusCode`, else 500.
|
|
15
15
|
* @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
|
|
@@ -5,13 +5,13 @@ import { HTTPContext } from '../../context/HTTPContext.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Expose the controller method as an HTTP PUT action on a route, to replace a resource: the shorthand of
|
|
7
7
|
* `@HTTPAction(route, 'put', …)`. The adapter assembles the input: by default, the query string merged with the parsed
|
|
8
|
-
* body (JSON
|
|
9
|
-
* the DTO (the defaults applied, the unknown keys removed; without a DTO, it is accepted as it is),
|
|
10
|
-
* runs when `acl` is set, then the method receives the validated input as a plain object. The query
|
|
11
|
-
* route parameters are strings and the DTO schemas are strict: convert them with `.strict(false)`. The
|
|
12
|
-
* is answered by the adapter's responder: as JSON by default, with the status 204 for `undefined`;
|
|
13
|
-
* sets a status and headers. An error thrown is answered as `{errno, errMsg}` with the first 4xx
|
|
14
|
-
* causes (400 for an invalid input), else its own `statusCode`, else 500.
|
|
8
|
+
* body (JSON; URL encoded with Express), then the route parameters over them. The middlewares run, the input is
|
|
9
|
+
* validated against the DTO (the defaults applied, the unknown keys removed; without a DTO, it is accepted as it is),
|
|
10
|
+
* the access control runs when `acl` is set, then the method receives the validated input as a plain object. The query
|
|
11
|
+
* values and the route parameters are strings and the DTO schemas are strict: convert them with `.strict(false)`. The
|
|
12
|
+
* value returned is answered by the adapter's responder: as JSON by default, with the status 204 for `undefined`;
|
|
13
|
+
* `Result.status()` sets a status and headers. An error thrown is answered as `{errno, errMsg}` with the first 4xx
|
|
14
|
+
* `statusCode` along its causes (400 for an invalid input), else its own `statusCode`, else 500.
|
|
15
15
|
* @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
|
|
16
16
|
* prepended to it.
|
|
17
17
|
* @returns The method decorator.
|
|
@@ -5,6 +5,12 @@ import { Exception } from '@lakutata/core';
|
|
|
5
5
|
*/
|
|
6
6
|
export declare class AccessDeniedException extends Exception {
|
|
7
7
|
errno: string | number;
|
|
8
|
-
message: string;
|
|
9
8
|
readonly statusCode: number;
|
|
9
|
+
/**
|
|
10
|
+
* Create the exception: its message is "Access denied" unless one is given.
|
|
11
|
+
* @param template The message, or a template filled from the parameters (see `Exception`), or an error whose
|
|
12
|
+
* message it takes; "Access denied" by default.
|
|
13
|
+
* @param params The parameters of the template.
|
|
14
|
+
*/
|
|
15
|
+
constructor(template?: string | Error, ...params: any[]);
|
|
10
16
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Exception } from '@lakutata/core';
|
|
2
2
|
/**
|
|
3
3
|
* The request arrived while the entrypoint is stopping (the application exiting): it is refused, the requests in
|
|
4
|
-
* progress being waited for.
|
|
4
|
+
* progress being waited for. A request still running when the entrypoint's `shutdownTimeout` runs out is aborted with
|
|
5
|
+
* it too. Its errno is `E_ENTRYPOINT_STOPPED`, its HTTP status 503.
|
|
5
6
|
*/
|
|
6
7
|
export declare class EntrypointStoppedException extends Exception {
|
|
7
8
|
errno: string | number;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Exception } from '@lakutata/core';
|
|
2
|
+
/**
|
|
3
|
+
* An action is in a group that the `*ActionGroups` option of its channel (`httpActionGroups`, `cliActionGroups`,
|
|
4
|
+
* `serviceActionGroups`) does not declare, when the entrypoint initializes. Its errno is `E_INVALID_ACTION_GROUP`.
|
|
5
|
+
*/
|
|
2
6
|
export declare class InvalidActionGroupException extends Exception {
|
|
3
7
|
errno: string | number;
|
|
4
8
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Exception } from '@lakutata/core';
|
|
2
|
+
/**
|
|
3
|
+
* A service called by an `HTTPServiceProxy` gave no response: it could not be reached, it did not answer in time, or
|
|
4
|
+
* its answer was not a service response (the error page of a proxy in front of it…). Its `cause` is the error of the
|
|
5
|
+
* request when there is one, its `service` the address of the service. Its errno is `E_SERVICE_UNAVAILABLE`, its HTTP
|
|
6
|
+
* status 503. The failures of the actions themselves are thrown as `ServiceInvokeException`.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ServiceUnavailableException extends Exception {
|
|
9
|
+
errno: string | number;
|
|
10
|
+
readonly statusCode: number;
|
|
11
|
+
/**
|
|
12
|
+
* The address of the service called.
|
|
13
|
+
*/
|
|
14
|
+
service?: string;
|
|
15
|
+
}
|
|
@@ -3,6 +3,7 @@ export * from '../lib/Controller.js';
|
|
|
3
3
|
export * from '../lib/AccessControlRule.js';
|
|
4
4
|
export * from '../exceptions/AccessDeniedException.js';
|
|
5
5
|
export * from '../exceptions/DuplicateActionNameException.js';
|
|
6
|
+
export * from '../exceptions/InvalidActionGroupException.js';
|
|
6
7
|
export * from '../exceptions/ControllerActionNotFoundException.js';
|
|
7
8
|
export { AccessControl } from '../lib/AccessControl.js';
|
|
8
9
|
export { Middleware, type ActionInvocation, type Next, type MiddlewareHandler, type MiddlewareDefinition } from '../lib/Middleware.js';
|
|
@@ -21,4 +22,6 @@ export * from '../exceptions/EntrypointStoppedException.js';
|
|
|
21
22
|
export * from '../exceptions/ServiceInvokeException.js';
|
|
22
23
|
export { scheduleEntrypoint, type ScheduleEntrypointOptions } from '../adapter/schedule/ScheduleEntrypoint.js';
|
|
23
24
|
export { httpServiceEntrypoint, httpRequestOfContext, type HTTPServiceEntrypointOptions } from '../adapter/http/HTTPServiceEntrypoint.js';
|
|
25
|
+
export { buildHTTPServiceProxy, HTTPServiceProxy, type BuildHTTPServiceProxyOptions } from '../adapter/http/HTTPServiceProxy.js';
|
|
26
|
+
export * from '../exceptions/ServiceUnavailableException.js';
|
|
24
27
|
export { Cron, parseDuration } from '../lib/schedule/Cron.js';
|
|
@@ -39,7 +39,8 @@ import { AccessControlRule, AccessControlRuleHandler } from './AccessControlRule
|
|
|
39
39
|
* name: 'Report',
|
|
40
40
|
* components: {
|
|
41
41
|
* entrypoint: {class: AuditedEntrypoint, controllers: [ReportController]}
|
|
42
|
-
* }
|
|
42
|
+
* },
|
|
43
|
+
* bootstrap: ['entrypoint']
|
|
43
44
|
* }))
|
|
44
45
|
* ```
|
|
45
46
|
*/
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ServerResponse } from 'node:http';
|
|
2
|
+
/**
|
|
3
|
+
* Mark the status of a response as set by the action
|
|
4
|
+
* @param response
|
|
5
|
+
*/
|
|
6
|
+
export declare function markExplicitStatus(response: ServerResponse): void;
|
|
7
|
+
/**
|
|
8
|
+
* Whether the status of a response was set by the action
|
|
9
|
+
* @param response
|
|
10
|
+
*/
|
|
11
|
+
export declare function hasExplicitStatus(response: ServerResponse): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IncomingMessage, OutgoingHttpHeaders } from 'node:http';
|
|
2
|
+
/**
|
|
3
|
+
* The headers of the answer to a preflight of a browser: the headers the request asks for are allowed (Authorization,
|
|
4
|
+
* the headers of the application…), the headers of the adapter when it asks for none
|
|
5
|
+
* @param request
|
|
6
|
+
* @param headers the CORS headers of the adapter
|
|
7
|
+
*/
|
|
8
|
+
export declare function preflightHeaders(request: IncomingMessage, headers: OutgoingHttpHeaders): OutgoingHttpHeaders;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IncomingMessage } from 'node:http';
|
|
2
|
+
/**
|
|
3
|
+
* Read the body of a request, up to a limit. Over the limit, it fails with a 413 error at once, and the rest of the body
|
|
4
|
+
* is read and dropped: the connection stays usable for the next request of the client (closing it while the client
|
|
5
|
+
* still sends would fail its request, keeping it unread would fail the next one)
|
|
6
|
+
* @param request
|
|
7
|
+
* @param limit bytes
|
|
8
|
+
*/
|
|
9
|
+
export declare function readBody(request: IncomingMessage, limit: number): Promise<string>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A pattern with the properties of its nested objects as keys joined by dots (`{res: {name: 'user'}}` gives
|
|
3
|
+
* `{'res.name': 'user'}`): their values are compared one by one, not as the text of their object. An empty nested
|
|
4
|
+
* object stays a value.
|
|
5
|
+
* @param pattern
|
|
6
|
+
* @param prefix
|
|
7
|
+
*/
|
|
8
|
+
export declare function flattenPattern(pattern: Record<string, any>, prefix?: string): Record<string, any>;
|
|
9
|
+
/**
|
|
10
|
+
* A subject matched by the flattened patterns: its own properties, with the ones of its nested objects as keys joined
|
|
11
|
+
* by dots
|
|
12
|
+
* @param subject
|
|
13
|
+
*/
|
|
14
|
+
export declare function flattenSubject(subject: Record<string, any>): Record<string, any>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lakutata/entrypoint",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "The entrypoint component of the lakutata framework: controllers and the dispatch of the CLI, HTTP and service actions.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"lakutata",
|
|
7
|
+
"controller",
|
|
8
|
+
"routing",
|
|
9
|
+
"http",
|
|
10
|
+
"express",
|
|
11
|
+
"fastify",
|
|
12
|
+
"commander",
|
|
13
|
+
"cli",
|
|
14
|
+
"socket.io",
|
|
15
|
+
"websocket",
|
|
16
|
+
"json-rpc",
|
|
17
|
+
"electron",
|
|
18
|
+
"ipc",
|
|
19
|
+
"schedule",
|
|
20
|
+
"cron",
|
|
21
|
+
"middleware",
|
|
22
|
+
"typescript"
|
|
23
|
+
],
|
|
24
|
+
"homepage": "https://lakutata.com/packages/entrypoint",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/lakutata/lakutata/issues",
|
|
27
|
+
"email": "admin@lakutata.com"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/lakutata/lakutata.git",
|
|
32
|
+
"directory": "packages/entrypoint"
|
|
33
|
+
},
|
|
34
|
+
"author": "alex.ma",
|
|
35
|
+
"license": "MIT",
|
|
5
36
|
"type": "module",
|
|
6
37
|
"main": "./dist/cjs/exports/Entrypoint.js",
|
|
7
38
|
"types": "./dist/cjs/exports/Entrypoint.d.ts",
|
|
@@ -110,8 +141,8 @@
|
|
|
110
141
|
},
|
|
111
142
|
"peerDependencies": {
|
|
112
143
|
"@inquirer/prompts": "^7.0.0 || ^8.0.0",
|
|
113
|
-
"@lakutata/core": "3.
|
|
114
|
-
"@lakutata/utils": "3.
|
|
144
|
+
"@lakutata/core": "3.1.0",
|
|
145
|
+
"@lakutata/utils": "3.1.0",
|
|
115
146
|
"commander": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
|
|
116
147
|
"express": "^4.21.0 || ^5.0.0",
|
|
117
148
|
"fastify": "^5.0.0",
|
|
@@ -139,7 +170,7 @@
|
|
|
139
170
|
}
|
|
140
171
|
},
|
|
141
172
|
"engines": {
|
|
142
|
-
"node": ">=
|
|
173
|
+
"node": "^22.13.0 || >=24.11.0"
|
|
143
174
|
},
|
|
144
175
|
"files": [
|
|
145
176
|
"dist",
|