@aeriajs/http 0.0.40 → 0.0.41
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/routing.d.ts +2 -2
- package/dist/routing.js +5 -5
- package/dist/routing.mjs +2 -2
- package/package.json +11 -11
package/dist/routing.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type Middleware = (context: RouteContext) => any;
|
|
|
8
8
|
export type RouteGroupOptions = {
|
|
9
9
|
base?: RouteUri;
|
|
10
10
|
};
|
|
11
|
-
type TypedContext<TContractWithRoles extends ContractWithRoles> = RouteContext & {
|
|
11
|
+
type TypedContext<TContractWithRoles extends ContractWithRoles> = RouteContext<number extends keyof TContractWithRoles['roles'] ? TContractWithRoles['roles'][number] : string> & {
|
|
12
12
|
request: Omit<RouteContext['request'], 'payload' | 'query'> & {
|
|
13
13
|
payload: TContractWithRoles extends {
|
|
14
14
|
payload: infer Payload;
|
|
@@ -33,7 +33,7 @@ export declare const wrapRouteExecution: (res: GenericResponse, cb: () => any |
|
|
|
33
33
|
export declare const createRouter: (options?: Partial<RouterOptions>) => ProxiedRouter<{
|
|
34
34
|
route: <const TContractWithRoles extends ContractWithRoles, TCallback extends (TContractWithRoles extends {
|
|
35
35
|
response: infer Response;
|
|
36
|
-
} ? InferResponse<Response> : any) extends infer Response_1 ? TContractWithRoles["roles"] extends unknown[] ? TContractWithRoles["roles"][number] extends infer Role ? "guest" extends Role ? (context: TypedContext<TContractWithRoles>) => Response_1 : (context: RouteContext & {
|
|
36
|
+
} ? InferResponse<Response> : any) extends infer Response_1 ? TContractWithRoles["roles"] extends unknown[] ? TContractWithRoles["roles"][number] extends infer Role ? "guest" extends Role ? (context: TypedContext<TContractWithRoles>) => Response_1 : (context: RouteContext<number extends keyof TContractWithRoles["roles"] ? TContractWithRoles["roles"][keyof TContractWithRoles["roles"] & number] : string> & {
|
|
37
37
|
request: Omit<GenericRequest, "payload" | "query"> & {
|
|
38
38
|
payload: TContractWithRoles extends {
|
|
39
39
|
payload: infer Payload;
|
package/dist/routing.js
CHANGED
|
@@ -24,10 +24,10 @@ const unsufficientRoles = (context) => {
|
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
const matches = (req, method, exp, options, config) => {
|
|
27
|
-
const base = config?.
|
|
27
|
+
const base = config?.baseUrl && config.baseUrl !== '/'
|
|
28
28
|
? options.base
|
|
29
|
-
? `${config.
|
|
30
|
-
: config.
|
|
29
|
+
? `${config.baseUrl}${options.base}`
|
|
30
|
+
: config.baseUrl
|
|
31
31
|
: options.base
|
|
32
32
|
? options.base
|
|
33
33
|
: '';
|
|
@@ -174,9 +174,9 @@ const createRouter = (options = {}) => {
|
|
|
174
174
|
newOptions.base = base && base !== '/'
|
|
175
175
|
? `${base}${exp}`
|
|
176
176
|
: exp;
|
|
177
|
-
const match = (0, exports.matches)(context.request, null, config.
|
|
177
|
+
const match = (0, exports.matches)(context.request, null, config.baseUrl === '/'
|
|
178
178
|
? new RegExp(`^${newOptions.base}/`)
|
|
179
|
-
: new RegExp(`^${config.
|
|
179
|
+
: new RegExp(`^${config.baseUrl}${newOptions.base}/`), newOptions);
|
|
180
180
|
if (match) {
|
|
181
181
|
if (middleware) {
|
|
182
182
|
const result = await middleware(context);
|
package/dist/routing.mjs
CHANGED
|
@@ -22,7 +22,7 @@ const unsufficientRoles = (context) => {
|
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
export const matches = (req, method, exp, options, config) => {
|
|
25
|
-
const base = config?.
|
|
25
|
+
const base = config?.baseUrl && config.baseUrl !== "/" ? options.base ? `${config.baseUrl}${options.base}` : config.baseUrl : options.base ? options.base : "";
|
|
26
26
|
if (method && method !== req.method) {
|
|
27
27
|
if (!Array.isArray(method) || !method.includes(req.method)) {
|
|
28
28
|
return;
|
|
@@ -169,7 +169,7 @@ export const createRouter = (options = {}) => {
|
|
|
169
169
|
const match = matches(
|
|
170
170
|
context.request,
|
|
171
171
|
null,
|
|
172
|
-
config.
|
|
172
|
+
config.baseUrl === "/" ? new RegExp(`^${newOptions.base}/`) : new RegExp(`^${config.baseUrl}${newOptions.base}/`),
|
|
173
173
|
newOptions
|
|
174
174
|
);
|
|
175
175
|
if (match) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/http",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.41",
|
|
4
4
|
"description": "## Installation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -22,18 +22,18 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@aeriajs/access-control": "^0.0.
|
|
26
|
-
"@aeriajs/common": "^0.0.
|
|
27
|
-
"@aeriajs/entrypoint": "^0.0.
|
|
28
|
-
"@aeriajs/types": "^0.0.
|
|
29
|
-
"@aeriajs/validation": "^0.0.
|
|
25
|
+
"@aeriajs/access-control": "^0.0.33",
|
|
26
|
+
"@aeriajs/common": "^0.0.33",
|
|
27
|
+
"@aeriajs/entrypoint": "^0.0.33",
|
|
28
|
+
"@aeriajs/types": "^0.0.30",
|
|
29
|
+
"@aeriajs/validation": "^0.0.36"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@aeriajs/access-control": "^0.0.
|
|
33
|
-
"@aeriajs/common": "^0.0.
|
|
34
|
-
"@aeriajs/entrypoint": "^0.0.
|
|
35
|
-
"@aeriajs/types": "^0.0.
|
|
36
|
-
"@aeriajs/validation": "^0.0.
|
|
32
|
+
"@aeriajs/access-control": "^0.0.33",
|
|
33
|
+
"@aeriajs/common": "^0.0.33",
|
|
34
|
+
"@aeriajs/entrypoint": "^0.0.33",
|
|
35
|
+
"@aeriajs/types": "^0.0.30",
|
|
36
|
+
"@aeriajs/validation": "^0.0.36"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"test": "echo skipping",
|