@adonisjs/http-server 7.7.0 → 8.0.0-next.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/build/chunk-ASX56VAK.js +76 -0
- package/build/{chunk-6FSCILWX.js → chunk-HMYAZG76.js} +986 -616
- package/build/factories/http_context.d.ts +3 -3
- package/build/factories/http_server.d.ts +1 -1
- package/build/factories/main.d.ts +6 -6
- package/build/factories/main.js +87 -87
- package/build/factories/qs_parser_factory.d.ts +2 -2
- package/build/factories/request.d.ts +2 -2
- package/build/factories/response.d.ts +3 -3
- package/build/factories/router.d.ts +1 -1
- package/build/factories/server_factory.d.ts +2 -2
- package/build/factories/url_builder_factory.d.ts +25 -0
- package/build/index.d.ts +16 -15
- package/build/index.js +25 -23
- package/build/src/cookies/client.d.ts +2 -2
- package/build/src/cookies/parser.d.ts +2 -2
- package/build/src/cookies/serializer.d.ts +8 -2
- package/build/src/define_config.d.ts +1 -1
- package/build/src/define_middleware.d.ts +4 -3
- package/build/src/{exceptions.d.ts → errors.d.ts} +20 -6
- package/build/src/exception_handler.d.ts +4 -4
- package/build/src/helpers.d.ts +50 -15
- package/build/src/helpers.js +18 -0
- package/build/src/http_context/local_storage.d.ts +1 -1
- package/build/src/http_context/main.d.ts +5 -5
- package/build/src/qs.d.ts +3 -3
- package/build/src/redirect.d.ts +5 -5
- package/build/src/request.d.ts +12 -11
- package/build/src/response.d.ts +6 -6
- package/build/src/router/brisk.d.ts +6 -5
- package/build/src/router/executor.d.ts +4 -4
- package/build/src/router/factories/use_return_value.d.ts +6 -1
- package/build/src/router/group.d.ts +6 -6
- package/build/src/router/{lookup_store → legacy}/url_builder.d.ts +20 -4
- package/build/src/router/main.d.ts +117 -21
- package/build/src/router/resource.d.ts +4 -4
- package/build/src/router/route.d.ts +3 -3
- package/build/src/router/signed_url_builder.d.ts +15 -0
- package/build/src/router/store.d.ts +2 -2
- package/build/src/router/url_builder.d.ts +14 -0
- package/build/src/server/factories/middleware_handler.d.ts +4 -4
- package/build/src/server/factories/route_finder.d.ts +10 -0
- package/build/src/server/factories/write_response.d.ts +1 -1
- package/build/src/server/main.d.ts +12 -8
- package/build/src/tracing_channels.d.ts +23 -0
- package/build/src/types/main.d.ts +7 -7
- package/build/src/types/main.js +0 -1
- package/build/src/types/middleware.d.ts +35 -2
- package/build/src/types/request.d.ts +4 -0
- package/build/src/types/response.d.ts +1 -1
- package/build/src/types/route.d.ts +50 -49
- package/build/src/types/server.d.ts +5 -5
- package/build/src/types/tracing_channels.d.ts +6 -0
- package/build/src/types/url_builder.d.ts +147 -0
- package/build/src/utils.d.ts +28 -0
- package/package.json +45 -38
- package/build/chunk-6FSCILWX.js.map +0 -1
- package/build/factories/main.js.map +0 -1
- package/build/index.js.map +0 -1
- package/build/src/router/lookup_store/main.d.ts +0 -48
- package/build/src/router/lookup_store/route_finder.d.ts +0 -25
- package/build/src/router/parser.d.ts +0 -5
- package/build/src/server/factories/final_handler.d.ts +0 -10
- package/build/src/types/base.d.ts +0 -19
- package/build/src/types/main.js.map +0 -1
package/build/src/helpers.d.ts
CHANGED
|
@@ -1,23 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type { RouteJSON } from './types/route.js';
|
|
5
|
-
import { RouteResource } from './router/resource.js';
|
|
1
|
+
import { type CookieOptions } from './types/response.ts';
|
|
2
|
+
import type { RouteMatchers, RouteJSON, MatchItRouteToken } from './types/route.ts';
|
|
3
|
+
import { type MiddlewareFn, type RouteHandlerInfo, type MiddlewareHandlerInfo, type ParsedGlobalMiddleware, type ParsedNamedMiddleware } from './types/middleware.ts';
|
|
6
4
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* This function is similar to the intrinsic function encodeURI. However, it will not encode:
|
|
6
|
+
* - The \, ^, or | characters
|
|
7
|
+
* - The % character when it's part of a valid sequence
|
|
8
|
+
* - [ and ] (for IPv6 hostnames)
|
|
9
|
+
* - Replaces raw, unpaired surrogate pairs with the Unicode replacement character
|
|
10
|
+
*
|
|
11
|
+
* Some tests
|
|
12
|
+
* encodeURI('http://localhost/%20snow.html') // http://localhost/%2520snow.html
|
|
13
|
+
* encodeUrl('http://localhost/%20snow.html') // http://localhost/%20snow.html
|
|
14
|
+
*
|
|
15
|
+
* encodeURI('http://[::1]:8080/foo/bar') // http://%5B::1%5D:8080/foo/bar
|
|
16
|
+
* encodeUrl('http://[::1]:8080/foo/bar') // http://[::1]:8080/foo/bar
|
|
9
17
|
*/
|
|
10
|
-
export
|
|
18
|
+
export { default as encodeUrl } from 'encodeurl';
|
|
11
19
|
/**
|
|
12
|
-
*
|
|
20
|
+
* Re-exports the "https://www.npmjs.com/package/mime-types" package
|
|
13
21
|
*/
|
|
14
|
-
export
|
|
22
|
+
export { default as mime } from 'mime-types';
|
|
15
23
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
24
|
+
* Parse a route pattern into an array of tokens. These tokes can be used
|
|
25
|
+
* to match routes, or print them with semantic information.
|
|
26
|
+
*
|
|
27
|
+
* Token types
|
|
28
|
+
*
|
|
29
|
+
* - 0: (static) segment
|
|
30
|
+
* - 1: (parameter) segment
|
|
31
|
+
* - 2: (wildcard) segment
|
|
32
|
+
* - 3: (optional parameter) segment
|
|
33
|
+
*
|
|
34
|
+
* Value (val) refers to the segment value
|
|
35
|
+
*
|
|
36
|
+
* end refers to be the suffix or the segment (if any)
|
|
18
37
|
*/
|
|
19
|
-
export declare function
|
|
38
|
+
export declare function parseRoute(pattern: string, matchers?: RouteMatchers): MatchItRouteToken[];
|
|
20
39
|
/**
|
|
21
|
-
*
|
|
40
|
+
* Match a given URI with an array of patterns and extract the params
|
|
41
|
+
* from the URL. Null value is returned in case of no match
|
|
22
42
|
*/
|
|
23
|
-
export declare function
|
|
43
|
+
export declare function matchRoute(url: string, patterns: string[]): null | Record<string, string>;
|
|
44
|
+
/**
|
|
45
|
+
* Serialize the value of a cookie to a string you can send via
|
|
46
|
+
* set-cookie response header.
|
|
47
|
+
*/
|
|
48
|
+
export declare function serializeCookie(key: string, value: string, options?: Partial<CookieOptions>): string;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the info about a middleware handler. In case of lazy imports, the method
|
|
51
|
+
* will return the import path
|
|
52
|
+
*/
|
|
53
|
+
export declare function middlewareInfo(middleware: MiddlewareFn | ParsedGlobalMiddleware | ParsedNamedMiddleware): Promise<MiddlewareHandlerInfo>;
|
|
54
|
+
/**
|
|
55
|
+
* Returns the info about a route handler. In case of lazy imports, the method
|
|
56
|
+
* will return the import path.
|
|
57
|
+
*/
|
|
58
|
+
export declare function routeInfo(route: RouteJSON): Promise<RouteHandlerInfo>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
default as default2,
|
|
3
|
+
default2 as default3,
|
|
4
|
+
matchRoute,
|
|
5
|
+
middlewareInfo,
|
|
6
|
+
parseRoute,
|
|
7
|
+
routeInfo,
|
|
8
|
+
serializeCookie
|
|
9
|
+
} from "../chunk-ASX56VAK.js";
|
|
10
|
+
export {
|
|
11
|
+
default2 as encodeUrl,
|
|
12
|
+
matchRoute,
|
|
13
|
+
middlewareInfo,
|
|
14
|
+
default3 as mime,
|
|
15
|
+
parseRoute,
|
|
16
|
+
routeInfo,
|
|
17
|
+
serializeCookie
|
|
18
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import Macroable from '@poppinss/macroable';
|
|
2
2
|
import type { Logger } from '@adonisjs/logger';
|
|
3
|
-
import { ContainerResolver } from '@adonisjs/fold';
|
|
4
|
-
import type { Request } from '../request.
|
|
5
|
-
import type { Response } from '../response.
|
|
6
|
-
import type {
|
|
3
|
+
import { type ContainerResolver } from '@adonisjs/fold';
|
|
4
|
+
import type { Request } from '../request.ts';
|
|
5
|
+
import type { Response } from '../response.ts';
|
|
6
|
+
import type { RouteJSON } from '../types/route.ts';
|
|
7
7
|
/**
|
|
8
8
|
* Http context encapsulates properties for a given HTTP request. The
|
|
9
9
|
* context class can be extended using macros and getters.
|
|
@@ -37,7 +37,7 @@ export declare class HttpContext extends Macroable {
|
|
|
37
37
|
* Reference to the current route. Not available inside
|
|
38
38
|
* server middleware
|
|
39
39
|
*/
|
|
40
|
-
route?:
|
|
40
|
+
route?: RouteJSON;
|
|
41
41
|
/**
|
|
42
42
|
* A unique key for the current route
|
|
43
43
|
*/
|
package/build/src/qs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { QSParserConfig } from './types/qs.
|
|
1
|
+
import { type QSParserConfig } from './types/qs.ts';
|
|
2
2
|
/**
|
|
3
3
|
* Query string parser used to parse and stringify query
|
|
4
4
|
* strings.
|
|
@@ -6,6 +6,6 @@ import { QSParserConfig } from './types/qs.js';
|
|
|
6
6
|
export declare class Qs {
|
|
7
7
|
#private;
|
|
8
8
|
constructor(config: QSParserConfig);
|
|
9
|
-
parse(value: string)
|
|
10
|
-
stringify(value: any)
|
|
9
|
+
parse: (value: string) => import("qs").ParsedQs;
|
|
10
|
+
stringify: (value: any) => string;
|
|
11
11
|
}
|
package/build/src/redirect.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { IncomingMessage } from 'node:http';
|
|
2
|
-
import type { Qs } from './qs.
|
|
3
|
-
import type { Response } from './response.
|
|
4
|
-
import type { Router } from './router/main.
|
|
5
|
-
import type {
|
|
2
|
+
import type { Qs } from './qs.ts';
|
|
3
|
+
import type { Response } from './response.ts';
|
|
4
|
+
import type { Router } from './router/main.ts';
|
|
5
|
+
import type { RoutesList, URLOptions, GetRoutesForMethod, RouteBuilderArguments } from './types/url_builder.ts';
|
|
6
6
|
/**
|
|
7
7
|
* Exposes the API to construct redirect routes
|
|
8
8
|
*/
|
|
@@ -33,7 +33,7 @@ export declare class Redirect {
|
|
|
33
33
|
/**
|
|
34
34
|
* Redirect the request using a route identifier.
|
|
35
35
|
*/
|
|
36
|
-
toRoute
|
|
36
|
+
toRoute<Identifier extends keyof GetRoutesForMethod<'GET'> & string>(...args: RouteBuilderArguments<RoutesList, Identifier, 'GET', URLOptions>): void;
|
|
37
37
|
/**
|
|
38
38
|
* Redirect the request using a path.
|
|
39
39
|
*/
|
package/build/src/request.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import Macroable from '@poppinss/macroable';
|
|
2
|
-
import { UrlWithStringQuery } from 'node:url';
|
|
3
2
|
import type { Encryption } from '@adonisjs/encryption';
|
|
4
|
-
import { ServerResponse, IncomingMessage, IncomingHttpHeaders } from 'node:http';
|
|
5
|
-
import type { Qs } from './qs.
|
|
6
|
-
import { RequestConfig } from './types/request.
|
|
7
|
-
import type { HttpContext } from './http_context/main.
|
|
3
|
+
import { type ServerResponse, type IncomingMessage, type IncomingHttpHeaders } from 'node:http';
|
|
4
|
+
import type { Qs } from './qs.ts';
|
|
5
|
+
import { type RequestConfig } from './types/request.ts';
|
|
6
|
+
import type { HttpContext } from './http_context/main.ts';
|
|
8
7
|
/**
|
|
9
8
|
* HTTP Request class exposes the interface to consistently read values
|
|
10
9
|
* related to a given HTTP request. The class is wrapper over
|
|
@@ -19,11 +18,13 @@ export declare class Request extends Macroable {
|
|
|
19
18
|
request: IncomingMessage;
|
|
20
19
|
response: ServerResponse;
|
|
21
20
|
/**
|
|
22
|
-
*
|
|
23
|
-
* object. This is done to build URL's with query string without
|
|
24
|
-
* stringifying the object
|
|
21
|
+
* Parsed URL with query string stored as a string.
|
|
25
22
|
*/
|
|
26
|
-
parsedUrl:
|
|
23
|
+
parsedUrl: {
|
|
24
|
+
pathname: string;
|
|
25
|
+
query: string;
|
|
26
|
+
shouldDecodeParam: boolean;
|
|
27
|
+
};
|
|
27
28
|
/**
|
|
28
29
|
* The ctx will be set by the context itself. It creates a circular
|
|
29
30
|
* reference
|
|
@@ -532,7 +533,7 @@ export declare class Request extends Macroable {
|
|
|
532
533
|
serialize(): {
|
|
533
534
|
id: string | undefined;
|
|
534
535
|
url: string;
|
|
535
|
-
query: string
|
|
536
|
+
query: string;
|
|
536
537
|
body: Record<string, any>;
|
|
537
538
|
params: Record<string, any>;
|
|
538
539
|
headers: IncomingHttpHeaders;
|
|
@@ -549,7 +550,7 @@ export declare class Request extends Macroable {
|
|
|
549
550
|
toJSON(): {
|
|
550
551
|
id: string | undefined;
|
|
551
552
|
url: string;
|
|
552
|
-
query: string
|
|
553
|
+
query: string;
|
|
553
554
|
body: Record<string, any>;
|
|
554
555
|
params: Record<string, any>;
|
|
555
556
|
headers: IncomingHttpHeaders;
|
package/build/src/response.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import Macroable from '@poppinss/macroable';
|
|
2
2
|
import type { Encryption } from '@adonisjs/encryption';
|
|
3
|
-
import { ServerResponse, IncomingMessage } from 'node:http';
|
|
4
|
-
import type { Qs } from './qs.
|
|
5
|
-
import { Redirect } from './redirect.
|
|
6
|
-
import type { Router } from './router/main.
|
|
7
|
-
import type { HttpContext } from './http_context/main.
|
|
8
|
-
import type { CastableHeader, CookieOptions, ResponseConfig, ResponseStream } from './types/response.
|
|
3
|
+
import { type ServerResponse, type IncomingMessage } from 'node:http';
|
|
4
|
+
import type { Qs } from './qs.ts';
|
|
5
|
+
import { Redirect } from './redirect.ts';
|
|
6
|
+
import type { Router } from './router/main.ts';
|
|
7
|
+
import type { HttpContext } from './http_context/main.ts';
|
|
8
|
+
import type { CastableHeader, CookieOptions, ResponseConfig, ResponseStream } from './types/response.ts';
|
|
9
9
|
/**
|
|
10
10
|
* The response is a wrapper over [ServerResponse](https://nodejs.org/api/http.html#http_class_http_serverresponse)
|
|
11
11
|
* streamlining the process of writing response body and automatically setting up appropriate headers.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import Macroable from '@poppinss/macroable';
|
|
2
2
|
import type { Application } from '@adonisjs/application';
|
|
3
|
-
import { Route } from './route.
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
3
|
+
import { Route } from './route.ts';
|
|
4
|
+
import type { RouteFn, RouteMatchers } from '../types/route.ts';
|
|
5
|
+
import type { ParsedGlobalMiddleware } from '../types/middleware.ts';
|
|
6
|
+
import type { RoutesList, URLOptions, GetRoutesForMethod, RouteBuilderArguments } from '../types/url_builder.ts';
|
|
6
7
|
/**
|
|
7
8
|
* Brisk routes exposes the API to configure the route handler by chaining
|
|
8
9
|
* one of the pre-defined methods.
|
|
@@ -30,9 +31,9 @@ export declare class BriskRoute extends Macroable {
|
|
|
30
31
|
* Redirects to a given route. Params from the original request will
|
|
31
32
|
* be used when no custom params are defined.
|
|
32
33
|
*/
|
|
33
|
-
redirect
|
|
34
|
+
redirect<Identifier extends keyof GetRoutesForMethod<'GET'> & string>(...args: RouteBuilderArguments<RoutesList, Identifier, 'GET', URLOptions & {
|
|
34
35
|
status: number;
|
|
35
|
-
}): Route;
|
|
36
|
+
}>): Route;
|
|
36
37
|
/**
|
|
37
38
|
* Redirect request to a fixed URL
|
|
38
39
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ContainerResolver } from '@adonisjs/fold';
|
|
2
|
-
import type {
|
|
3
|
-
import type { HttpContext } from '../http_context/main.
|
|
4
|
-
import type { ServerErrorHandler } from '../types/server.
|
|
2
|
+
import type { RouteJSON } from '../types/route.ts';
|
|
3
|
+
import type { HttpContext } from '../http_context/main.ts';
|
|
4
|
+
import type { ServerErrorHandler } from '../types/server.ts';
|
|
5
5
|
/**
|
|
6
6
|
* Executor to execute the route middleware pipeline the route
|
|
7
7
|
* handler
|
|
8
8
|
*/
|
|
9
|
-
export declare function execute(route:
|
|
9
|
+
export declare function execute(route: RouteJSON, resolver: ContainerResolver<any>, ctx: HttpContext, errorResponder: ServerErrorHandler['handle']): Promise<void>;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type HttpContext } from '../../http_context/main.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Check if the value can be used to write the response body. Returns
|
|
4
|
+
* false when the response body has already been set
|
|
5
|
+
*/
|
|
6
|
+
export declare function canWriteResponseBody(value: any, ctx: HttpContext): boolean;
|
|
2
7
|
/**
|
|
3
8
|
* A factory function that uses the return value of the request
|
|
4
9
|
* pipeline as the response
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Macroable from '@poppinss/macroable';
|
|
2
|
-
import type {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import type { OneOrMore } from '@poppinss/utils/types';
|
|
3
|
+
import { type Route } from './route.ts';
|
|
4
|
+
import { BriskRoute } from './brisk.ts';
|
|
5
|
+
import { RouteResource } from './resource.ts';
|
|
6
|
+
import { type RouteMatcher } from '../types/route.ts';
|
|
7
|
+
import type { MiddlewareFn, ParsedNamedMiddleware } from '../types/middleware.ts';
|
|
8
8
|
/**
|
|
9
9
|
* Group class exposes the API to take action on a group of routes.
|
|
10
10
|
* The group routes must be pre-defined using the constructor.
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { Qs } from '../../qs.js';
|
|
3
|
-
import type { RouteFinder } from './route_finder.js';
|
|
1
|
+
import { type Router } from '../main.ts';
|
|
4
2
|
/**
|
|
5
3
|
* URL builder class is used to create URIs for pre-registered
|
|
6
4
|
* routes.
|
|
@@ -13,37 +11,55 @@ import type { RouteFinder } from './route_finder.js';
|
|
|
13
11
|
* .params([category.id])
|
|
14
12
|
* .make('categories.posts.index')
|
|
15
13
|
* ```
|
|
14
|
+
*
|
|
15
|
+
* @deprecated
|
|
16
|
+
* Instead use "@adonisjs/core/services/url_builder" instead
|
|
16
17
|
*/
|
|
17
18
|
export declare class UrlBuilder {
|
|
18
19
|
#private;
|
|
19
|
-
constructor(
|
|
20
|
+
constructor(router: Router, domain?: string);
|
|
20
21
|
/**
|
|
21
22
|
* Prefix a custom base URL to the final URI
|
|
23
|
+
* @deprecated
|
|
24
|
+
* Instead use "@adonisjs/core/services/url_builder" instead
|
|
22
25
|
*/
|
|
23
26
|
prefixUrl(url: string): this;
|
|
24
27
|
/**
|
|
25
28
|
* Disable route lookup. Calling this method considers
|
|
26
29
|
* the "identifier" as the route pattern
|
|
30
|
+
* @deprecated
|
|
31
|
+
* Instead use "@adonisjs/core/services/url_builder" instead
|
|
27
32
|
*/
|
|
28
33
|
disableRouteLookup(): this;
|
|
29
34
|
/**
|
|
30
35
|
* Append query string to the final URI
|
|
36
|
+
* @deprecated
|
|
37
|
+
* Instead use "@adonisjs/core/services/url_builder" instead
|
|
31
38
|
*/
|
|
32
39
|
qs(queryString?: Record<string, any>): this;
|
|
33
40
|
/**
|
|
34
41
|
* Specify params to apply to the route pattern
|
|
42
|
+
* @deprecated
|
|
43
|
+
* Instead use "@adonisjs/core/services/url_builder" instead
|
|
35
44
|
*/
|
|
36
45
|
params(params?: any[] | Record<string, any>): this;
|
|
37
46
|
/**
|
|
38
47
|
* Generate URL for the given route identifier. The identifier can be the
|
|
39
48
|
* route name, controller.method name or the route pattern
|
|
40
49
|
* itself.
|
|
50
|
+
*
|
|
51
|
+
* @deprecated
|
|
52
|
+
* Instead use "@adonisjs/core/services/url_builder" instead
|
|
41
53
|
*/
|
|
42
54
|
make(identifier: string): string;
|
|
43
55
|
/**
|
|
44
56
|
* Generate a signed URL for the given route identifier. The identifier can be the
|
|
45
57
|
* route name, controller.method name or the route pattern
|
|
46
58
|
* itself.
|
|
59
|
+
*
|
|
60
|
+
* @deprecated
|
|
61
|
+
* Instead use "@adonisjs/core/services/url_builder" instead
|
|
62
|
+
*
|
|
47
63
|
*/
|
|
48
64
|
makeSigned(identifier: string, options?: {
|
|
49
65
|
expiresIn?: string | number;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import type { Encryption } from '@adonisjs/encryption';
|
|
2
2
|
import type { Application } from '@adonisjs/application';
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import type { MiddlewareAsClass, ParsedGlobalMiddleware } from '../types/middleware.
|
|
12
|
-
import type { RouteFn,
|
|
3
|
+
import type { Constructor, LazyImport } from '@poppinss/utils/types';
|
|
4
|
+
import type { Qs } from '../qs.ts';
|
|
5
|
+
import { Route } from './route.ts';
|
|
6
|
+
import { RouteGroup } from './group.ts';
|
|
7
|
+
import { BriskRoute } from './brisk.ts';
|
|
8
|
+
import { RouteResource } from './resource.ts';
|
|
9
|
+
import { UrlBuilder } from './legacy/url_builder.ts';
|
|
10
|
+
import { RouteMatchers as Matchers } from './matchers.ts';
|
|
11
|
+
import type { MiddlewareAsClass, ParsedGlobalMiddleware } from '../types/middleware.ts';
|
|
12
|
+
import type { RouteFn, RouteJSON, MatchedRoute, RouteMatchers, MakeUrlOptions, MakeSignedUrlOptions, GetControllerHandlers, RouteMatcher } from '../types/route.ts';
|
|
13
|
+
import { type UrlFor, type LookupList, type RoutesList, type SignedURLOptions } from '../types/url_builder.ts';
|
|
13
14
|
/**
|
|
14
15
|
* Router class exposes a unified API to register new routes, group them or
|
|
15
16
|
* create route resources.
|
|
@@ -22,13 +23,8 @@ import type { RouteFn, MatchedRoute, RouteMatcher, RouteMatchers, MakeUrlOptions
|
|
|
22
23
|
* })
|
|
23
24
|
* ```
|
|
24
25
|
*/
|
|
25
|
-
export declare class Router
|
|
26
|
+
export declare class Router {
|
|
26
27
|
#private;
|
|
27
|
-
/**
|
|
28
|
-
* Collection of routes, including route resource and route
|
|
29
|
-
* group. To get a flat list of routes, call `router.toJSON()`
|
|
30
|
-
*/
|
|
31
|
-
routes: (Route | RouteResource | RouteGroup | BriskRoute)[];
|
|
32
28
|
/**
|
|
33
29
|
* A flag to know if routes for explicit domains have been registered.
|
|
34
30
|
* The boolean is computed after calling the "commit" method.
|
|
@@ -44,11 +40,36 @@ export declare class Router extends LookupStore {
|
|
|
44
40
|
* have no impact
|
|
45
41
|
*/
|
|
46
42
|
get commited(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Query string parser for making URLs
|
|
45
|
+
*/
|
|
46
|
+
qs: Qs;
|
|
47
|
+
/**
|
|
48
|
+
* The URLBuilder offers a type-safe API for creating URL for pre-registered
|
|
49
|
+
* routes or the route patterns.
|
|
50
|
+
*
|
|
51
|
+
* We recommend using the URLBuilder over the "makeUrl" and "makeSignedUrl"
|
|
52
|
+
* methods.
|
|
53
|
+
*/
|
|
54
|
+
urlBuilder: {
|
|
55
|
+
urlFor: UrlFor<RoutesList extends LookupList ? RoutesList : never>;
|
|
56
|
+
signedUrlFor: UrlFor<RoutesList extends LookupList ? RoutesList : never, SignedURLOptions>;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* List of route references kept for lookup.
|
|
60
|
+
*/
|
|
61
|
+
protected routes: {
|
|
62
|
+
[domain: string]: RouteJSON[];
|
|
63
|
+
};
|
|
47
64
|
constructor(app: Application<any>, encryption: Encryption, qsParser: Qs);
|
|
65
|
+
/**
|
|
66
|
+
* Register route JSON payload
|
|
67
|
+
*/
|
|
68
|
+
protected register(route: RouteJSON): void;
|
|
48
69
|
/**
|
|
49
70
|
* Parses the route pattern
|
|
50
71
|
*/
|
|
51
|
-
parsePattern(pattern: string, matchers?: RouteMatchers): import("../types/route.
|
|
72
|
+
parsePattern(pattern: string, matchers?: RouteMatchers): import("../types/route.ts").MatchItRouteToken[];
|
|
52
73
|
/**
|
|
53
74
|
* Define an array of middleware to use on all the routes.
|
|
54
75
|
* Calling this method multiple times pushes to the
|
|
@@ -60,8 +81,9 @@ export declare class Router extends LookupStore {
|
|
|
60
81
|
* not registered anywhere, but instead converted in a new collection
|
|
61
82
|
* of functions you can apply on the routes, or router groups.
|
|
62
83
|
*/
|
|
63
|
-
named<NamedMiddleware extends Record<string, LazyImport<MiddlewareAsClass>>>(collection: NamedMiddleware): { [K in keyof NamedMiddleware]: <Args extends import("../types/middleware.
|
|
84
|
+
named<NamedMiddleware extends Record<string, LazyImport<MiddlewareAsClass>>>(collection: NamedMiddleware): { [K in keyof NamedMiddleware]: <Args extends import("../types/middleware.ts").GetMiddlewareArgs<import("@poppinss/utils/types").UnWrapLazyImport<NamedMiddleware[K]>>>(...args: Args) => {
|
|
64
85
|
name: K;
|
|
86
|
+
reference: LazyImport<MiddlewareAsClass> | MiddlewareAsClass;
|
|
65
87
|
args: Args[0];
|
|
66
88
|
handle: ParsedGlobalMiddleware["handle"];
|
|
67
89
|
}; };
|
|
@@ -101,11 +123,11 @@ export declare class Router extends LookupStore {
|
|
|
101
123
|
/**
|
|
102
124
|
* Registers a route resource with conventional set of routes
|
|
103
125
|
*/
|
|
104
|
-
resource(resource: string, controller: string | LazyImport<Constructor<any>> | Constructor<any>): RouteResource<import("../types/route.
|
|
126
|
+
resource(resource: string, controller: string | LazyImport<Constructor<any>> | Constructor<any>): RouteResource<import("../types/route.ts").ResourceActionNames>;
|
|
105
127
|
/**
|
|
106
128
|
* Register a route resource with shallow nested routes.
|
|
107
129
|
*/
|
|
108
|
-
shallowResource(resource: string, controller: string | LazyImport<Constructor<any>> | Constructor<any>): RouteResource<import("../types/route.
|
|
130
|
+
shallowResource(resource: string, controller: string | LazyImport<Constructor<any>> | Constructor<any>): RouteResource<import("../types/route.ts").ResourceActionNames>;
|
|
109
131
|
/**
|
|
110
132
|
* Returns a brisk route instance for a given URL pattern
|
|
111
133
|
*/
|
|
@@ -120,16 +142,90 @@ export declare class Router extends LookupStore {
|
|
|
120
142
|
* commit method is called.
|
|
121
143
|
*/
|
|
122
144
|
commit(): void;
|
|
145
|
+
/**
|
|
146
|
+
* The lookup strategies to follow when generating URL builder
|
|
147
|
+
* types and client
|
|
148
|
+
*/
|
|
149
|
+
lookupStrategies: ('name' | 'pattern' | 'controller')[];
|
|
150
|
+
/**
|
|
151
|
+
* Define the lookup strategies to follow when generating URL builder
|
|
152
|
+
* types and client.
|
|
153
|
+
*/
|
|
154
|
+
updateLookupStrategies(strategies: ('name' | 'pattern' | 'controller')[]): this;
|
|
155
|
+
/**
|
|
156
|
+
* Finds a route by its identifier. The identifier can be the
|
|
157
|
+
* route name, controller.method name or the route pattern
|
|
158
|
+
* itself.
|
|
159
|
+
*
|
|
160
|
+
* When "followLookupStrategy" is enabled, the lookup will be performed
|
|
161
|
+
* on the basis of the lookup strategy enabled via the "lookupStrategies"
|
|
162
|
+
* method. The default lookupStrategy is "name" and "pattern".
|
|
163
|
+
*/
|
|
164
|
+
find(routeIdentifier: string, domain?: string, method?: string, followLookupStrategy?: boolean): RouteJSON | null;
|
|
165
|
+
/**
|
|
166
|
+
* Finds a route by its identifier. The identifier can be the
|
|
167
|
+
* route name, controller.method name or the route pattern
|
|
168
|
+
* itself.
|
|
169
|
+
*
|
|
170
|
+
* An error is raised when unable to find the route.
|
|
171
|
+
*
|
|
172
|
+
* When "followLookupStrategy" is enabled, the lookup will be performed
|
|
173
|
+
* on the basis of the lookup strategy enabled via the "lookupStrategies"
|
|
174
|
+
* method. The default lookupStrategy is "name" and "pattern".
|
|
175
|
+
*/
|
|
176
|
+
findOrFail(routeIdentifier: string, domain?: string, method?: string, followLookupStrategy?: boolean): RouteJSON;
|
|
177
|
+
/**
|
|
178
|
+
* Check if a route exists. The identifier can be the
|
|
179
|
+
* route name, controller.method name or the route pattern
|
|
180
|
+
* itself.
|
|
181
|
+
*
|
|
182
|
+
* When "followLookupStrategy" is enabled, the lookup will be performed
|
|
183
|
+
* on the basis of the lookup strategy enabled via the "lookupStrategies"
|
|
184
|
+
* method. The default lookupStrategy is "name" and "pattern".
|
|
185
|
+
*/
|
|
186
|
+
has(routeIdentifier: string, domain?: string, method?: string, followLookupStrategy?: boolean): boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Returns a list of routes grouped by their domain names
|
|
189
|
+
*/
|
|
190
|
+
toJSON(): {
|
|
191
|
+
[domain: string]: RouteJSON[];
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Generates types for the URL builder. These types must
|
|
195
|
+
* be written inside a file for the URL builder to
|
|
196
|
+
* pick them up.
|
|
197
|
+
*/
|
|
198
|
+
generateTypes(indentation?: number): string;
|
|
123
199
|
/**
|
|
124
200
|
* Find route for a given URL, method and optionally domain
|
|
125
201
|
*/
|
|
126
|
-
match(
|
|
202
|
+
match(uri: string, method: string, shouldDecodeParam: boolean, hostname?: string | null): null | MatchedRoute;
|
|
203
|
+
/**
|
|
204
|
+
* Create URL builder instance.
|
|
205
|
+
* @deprecated
|
|
206
|
+
*
|
|
207
|
+
* Instead use "@adonisjs/core/services/url_builder" instead
|
|
208
|
+
*/
|
|
209
|
+
builder(): UrlBuilder;
|
|
210
|
+
/**
|
|
211
|
+
* Create URL builder instance for a given domain.
|
|
212
|
+
* @deprecated
|
|
213
|
+
*
|
|
214
|
+
* Instead use "@adonisjs/core/services/url_builder"
|
|
215
|
+
*/
|
|
216
|
+
builderForDomain(domain: string): UrlBuilder;
|
|
127
217
|
/**
|
|
128
218
|
* Make URL to a pre-registered route
|
|
219
|
+
*
|
|
220
|
+
* @deprecated
|
|
221
|
+
* Instead use "@adonisjs/core/services/url_builder"
|
|
129
222
|
*/
|
|
130
223
|
makeUrl(routeIdentifier: string, params?: any[] | Record<string, any>, options?: MakeUrlOptions): string;
|
|
131
224
|
/**
|
|
132
225
|
* Makes a signed URL to a pre-registered route.
|
|
226
|
+
*
|
|
227
|
+
* @deprecated
|
|
228
|
+
* Instead use "@adonisjs/core/services/url_builder"
|
|
133
229
|
*/
|
|
134
230
|
makeSignedUrl(routeIdentifier: string, params?: any[] | Record<string, any>, options?: MakeSignedUrlOptions): string;
|
|
135
231
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import Macroable from '@poppinss/macroable';
|
|
2
2
|
import type { Application } from '@adonisjs/application';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
3
|
+
import type { Constructor, LazyImport, OneOrMore } from '@poppinss/utils/types';
|
|
4
|
+
import { Route } from './route.ts';
|
|
5
|
+
import type { ResourceActionNames, RouteMatcher, RouteMatchers } from '../types/route.ts';
|
|
6
|
+
import type { MiddlewareFn, ParsedNamedMiddleware, ParsedGlobalMiddleware } from '../types/middleware.ts';
|
|
7
7
|
/**
|
|
8
8
|
* Route resource exposes the API to register multiple routes for a resource.
|
|
9
9
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Macroable from '@poppinss/macroable';
|
|
2
2
|
import type { Application } from '@adonisjs/application';
|
|
3
|
-
import type { Constructor, LazyImport, OneOrMore } from '
|
|
4
|
-
import type { MiddlewareFn, ParsedNamedMiddleware, ParsedGlobalMiddleware } from '../types/middleware.
|
|
5
|
-
import type {
|
|
3
|
+
import type { Constructor, LazyImport, OneOrMore } from '@poppinss/utils/types';
|
|
4
|
+
import type { MiddlewareFn, ParsedNamedMiddleware, ParsedGlobalMiddleware } from '../types/middleware.ts';
|
|
5
|
+
import type { RouteFn, RouteJSON, RouteMatcher, RouteMatchers, StoreRouteMiddleware, GetControllerHandlers } from '../types/route.ts';
|
|
6
6
|
/**
|
|
7
7
|
* The route class exposes the APIs for constructing a route using the
|
|
8
8
|
* fluent API.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Encryption } from '@adonisjs/encryption';
|
|
2
|
+
import { type Router } from './main.ts';
|
|
3
|
+
import { type MatchItRouteToken } from '../types/route.ts';
|
|
4
|
+
import { type UrlFor, type LookupList, type SignedURLOptions } from '../types/url_builder.ts';
|
|
5
|
+
/**
|
|
6
|
+
* Makes signed URL for a given route pattern. The route pattern could be an
|
|
7
|
+
* identifier or an array of tokens.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createSignedURL(identifier: string, tokens: MatchItRouteToken[], searchParamsStringifier: (qs: Record<string, any>) => string, encryption: Encryption, params?: any[] | {
|
|
10
|
+
[param: string]: any;
|
|
11
|
+
}, options?: SignedURLOptions): string;
|
|
12
|
+
/**
|
|
13
|
+
* Creates the URLBuilder helper for making signed URLs
|
|
14
|
+
*/
|
|
15
|
+
export declare function createSignedUrlBuilder<Routes extends LookupList>(router: Router, encryption: Encryption, searchParamsStringifier: (qs: Record<string, any>) => string): UrlFor<Routes, SignedURLOptions>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RouteJSON, MatchedRoute, StoreRoutesTree, MatchItRouteToken } from '../types/route.
|
|
1
|
+
import type { RouteJSON, MatchedRoute, StoreRoutesTree, MatchItRouteToken } from '../types/route.ts';
|
|
2
2
|
/**
|
|
3
3
|
* Store class is used to store a list of routes, along side with their tokens
|
|
4
4
|
* to match the URLs.
|
|
@@ -55,7 +55,7 @@ export declare class RoutesStore {
|
|
|
55
55
|
* qualified runtime domain. You must call `matchDomain` first to fetch
|
|
56
56
|
* the pattern for qualified domain
|
|
57
57
|
*/
|
|
58
|
-
match(url: string, method: string, domain?: {
|
|
58
|
+
match(url: string, method: string, shouldDecodeParam: boolean, domain?: {
|
|
59
59
|
tokens: MatchItRouteToken[];
|
|
60
60
|
hostname: string;
|
|
61
61
|
}): null | MatchedRoute;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Router } from './main.ts';
|
|
2
|
+
import { type MatchItRouteToken } from '../types/route.ts';
|
|
3
|
+
import { type UrlFor, type LookupList, type URLOptions } from '../types/url_builder.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Makes URL for a given route pattern. The route pattern could be an
|
|
6
|
+
* identifier or an array of tokens.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createURL(identifier: string, tokens: Pick<MatchItRouteToken, 'val' | 'type' | 'end'>[], searchParamsStringifier: (qs: Record<string, any>) => string, params?: any[] | {
|
|
9
|
+
[param: string]: any;
|
|
10
|
+
}, options?: URLOptions): string;
|
|
11
|
+
/**
|
|
12
|
+
* Creates the URLBuilder helper
|
|
13
|
+
*/
|
|
14
|
+
export declare function createUrlBuilder<Routes extends LookupList>(router: Router, searchParamsStringifier: (qs: Record<string, any>) => string): UrlFor<Routes>;
|