@adonisjs/http-server 6.1.0-0 → 6.2.0-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/build/src/request.js
CHANGED
|
@@ -5,11 +5,11 @@ import { Route } from './route.js';
|
|
|
5
5
|
import { RouteGroup } from './group.js';
|
|
6
6
|
import { BriskRoute } from './brisk.js';
|
|
7
7
|
import { RouteResource } from './resource.js';
|
|
8
|
-
import type { LazyImport } from '../types/base.js';
|
|
8
|
+
import type { Constructor, LazyImport } from '../types/base.js';
|
|
9
9
|
import { LookupStore } from './lookup_store/main.js';
|
|
10
10
|
import { RouteMatchers as Matchers } from './matchers.js';
|
|
11
11
|
import type { MiddlewareAsClass, ParsedGlobalMiddleware } from '../types/middleware.js';
|
|
12
|
-
import type { RouteFn, MatchedRoute, RouteMatcher, MakeUrlOptions, MakeSignedUrlOptions } from '../types/route.js';
|
|
12
|
+
import type { RouteFn, MatchedRoute, RouteMatcher, MakeUrlOptions, MakeSignedUrlOptions, GetControllerHandlers } from '../types/route.js';
|
|
13
13
|
export declare class Router extends LookupStore {
|
|
14
14
|
#private;
|
|
15
15
|
routes: (Route | RouteResource | RouteGroup | BriskRoute)[];
|
|
@@ -21,13 +21,13 @@ export declare class Router extends LookupStore {
|
|
|
21
21
|
name: K;
|
|
22
22
|
args: Args[0];
|
|
23
23
|
} & ParsedGlobalMiddleware; };
|
|
24
|
-
route(pattern: string, methods: string[], handler: string | RouteFn): Route
|
|
25
|
-
any(pattern: string, handler: string | RouteFn): Route
|
|
26
|
-
get(pattern: string, handler: string | RouteFn): Route
|
|
27
|
-
post(pattern: string, handler: string | RouteFn): Route
|
|
28
|
-
put(pattern: string, handler: string | RouteFn): Route
|
|
29
|
-
patch(pattern: string, handler: string | RouteFn): Route
|
|
30
|
-
delete(pattern: string, handler: string | RouteFn): Route
|
|
24
|
+
route<T extends Constructor<any>>(pattern: string, methods: string[], handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
|
|
25
|
+
any<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
|
|
26
|
+
get<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
|
|
27
|
+
post<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
|
|
28
|
+
put<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
|
|
29
|
+
patch<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
|
|
30
|
+
delete<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
|
|
31
31
|
group(callback: () => void): RouteGroup;
|
|
32
32
|
resource(resource: string, controller: string): RouteResource;
|
|
33
33
|
shallowResource(resource: string, controller: string): RouteResource;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Macroable } from '@poppinss/macroable';
|
|
2
2
|
import type { Application } from '@adonisjs/application';
|
|
3
|
+
import type { Constructor, LazyImport } from '../types/base.js';
|
|
3
4
|
import type { MiddlewareFn, ParsedNamedMiddleware, ParsedGlobalMiddleware } from '../types/middleware.js';
|
|
4
|
-
import type { RouteFn, RouteJSON, RouteMatcher, RouteMatchers, StoreRouteMiddleware } from '../types/route.js';
|
|
5
|
-
export declare class Route extends Macroable {
|
|
5
|
+
import type { GetControllerHandlers, RouteFn, RouteJSON, RouteMatcher, RouteMatchers, StoreRouteMiddleware } from '../types/route.js';
|
|
6
|
+
export declare class Route<Controller extends Constructor<any> = any> extends Macroable {
|
|
6
7
|
#private;
|
|
7
8
|
constructor(app: Application<any, any>, routerMiddleware: ParsedGlobalMiddleware[], options: {
|
|
8
9
|
pattern: string;
|
|
9
10
|
methods: string[];
|
|
10
|
-
handler: RouteFn | string;
|
|
11
|
+
handler: RouteFn | string | [LazyImport<Controller> | Controller, GetControllerHandlers<Controller>?];
|
|
11
12
|
globalMatchers: RouteMatchers;
|
|
12
13
|
});
|
|
13
14
|
where(param: string, matcher: RouteMatcher | string | RegExp): this;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import is from '@sindresorhus/is';
|
|
2
2
|
import Middleware from '@poppinss/middleware';
|
|
3
3
|
import { Macroable } from '@poppinss/macroable';
|
|
4
|
-
import { moduleExpression } from '@adonisjs/fold';
|
|
5
4
|
import { RuntimeException } from '@poppinss/utils';
|
|
5
|
+
import { moduleCaller, moduleExpression, moduleImporter } from '@adonisjs/fold';
|
|
6
6
|
import { execute } from './executor.js';
|
|
7
7
|
import { dropSlash } from '../helpers.js';
|
|
8
8
|
export class Route extends Macroable {
|
|
@@ -30,10 +30,22 @@ export class Route extends Macroable {
|
|
|
30
30
|
#resolveRouteHandle(handler) {
|
|
31
31
|
if (typeof handler === 'string') {
|
|
32
32
|
return {
|
|
33
|
-
|
|
33
|
+
reference: handler,
|
|
34
34
|
...moduleExpression(handler, this.#app.appRoot).toHandleMethod(),
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
+
if (Array.isArray(handler)) {
|
|
38
|
+
if (is.class_(handler[0])) {
|
|
39
|
+
return {
|
|
40
|
+
reference: handler[0].name,
|
|
41
|
+
...moduleCaller(handler[0], (handler[1] || 'handle')).toHandleMethod(),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
reference: handler[0].name,
|
|
46
|
+
...moduleImporter(handler[0], (handler[1] || 'handle')).toHandleMethod(),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
37
49
|
return handler;
|
|
38
50
|
}
|
|
39
51
|
#getMatchers() {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type Middleware from '@poppinss/middleware';
|
|
2
2
|
import type { ContainerResolver } from '@adonisjs/fold';
|
|
3
|
+
import type { Constructor, LazyImport } from './base.js';
|
|
3
4
|
import type { HttpContext } from '../http_context/main.js';
|
|
4
5
|
import type { MiddlewareFn, ParsedGlobalMiddleware } from './middleware.js';
|
|
6
|
+
export type GetControllerHandlers<Controller extends Constructor<any>> = {
|
|
7
|
+
[K in keyof InstanceType<Controller>]: InstanceType<Controller>[K] extends (ctx: HttpContext, ...args: any[]) => any ? K : never;
|
|
8
|
+
}[keyof InstanceType<Controller>];
|
|
5
9
|
export type MatchItRouteToken = RouteMatcher & {
|
|
6
10
|
old: string;
|
|
7
11
|
type: 0 | 1 | 2 | 3;
|
|
@@ -10,7 +14,7 @@ export type MatchItRouteToken = RouteMatcher & {
|
|
|
10
14
|
};
|
|
11
15
|
export type RouteFn = (ctx: HttpContext) => any;
|
|
12
16
|
export type StoreRouteHandler = RouteFn | {
|
|
13
|
-
|
|
17
|
+
reference: string | [LazyImport<Constructor<any>> | Constructor<any>, any?];
|
|
14
18
|
handle: (resolver: ContainerResolver<any>, ...args: [ctx: HttpContext, ...injections: any[]]) => any;
|
|
15
19
|
};
|
|
16
20
|
export type StoreRouteMiddleware = MiddlewareFn | ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/http-server",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0-0",
|
|
4
4
|
"description": "AdonisJS HTTP server with support packed with Routing and Cookies",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"author": "virk,adonisjs",
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@adonisjs/application": "^6.
|
|
40
|
+
"@adonisjs/application": "^6.4.0-0",
|
|
41
41
|
"@adonisjs/config": "^4.1.2-0",
|
|
42
42
|
"@adonisjs/encryption": "^5.0.2-0",
|
|
43
|
-
"@adonisjs/fold": "^9.
|
|
43
|
+
"@adonisjs/fold": "^9.8.0-0",
|
|
44
44
|
"@adonisjs/logger": "^5.1.0-0",
|
|
45
45
|
"@commitlint/cli": "^17.3.0",
|
|
46
46
|
"@commitlint/config-conventional": "^17.3.0",
|
|
@@ -113,9 +113,9 @@
|
|
|
113
113
|
"vary": "^1.1.2"
|
|
114
114
|
},
|
|
115
115
|
"peerDependencies": {
|
|
116
|
-
"@adonisjs/application": "^6.
|
|
116
|
+
"@adonisjs/application": "^6.4.0-0",
|
|
117
117
|
"@adonisjs/encryption": "^5.0.2-0",
|
|
118
|
-
"@adonisjs/fold": "^9.
|
|
118
|
+
"@adonisjs/fold": "^9.8.0-0"
|
|
119
119
|
},
|
|
120
120
|
"repository": {
|
|
121
121
|
"type": "git",
|