@adonisjs/http-server 5.12.0 → 6.0.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/README.md +15 -38
- package/build/index.d.ts +16 -0
- package/build/index.js +16 -0
- package/build/src/cookies/client.d.ts +12 -0
- package/build/src/cookies/client.js +42 -0
- package/build/src/cookies/drivers/encrypted.d.ts +4 -0
- package/build/src/cookies/drivers/encrypted.js +16 -0
- package/build/src/cookies/drivers/plain.d.ts +3 -0
- package/build/src/cookies/drivers/plain.js +13 -0
- package/build/src/cookies/drivers/signed.d.ts +4 -0
- package/build/src/cookies/drivers/signed.js +16 -0
- package/build/src/cookies/parser.d.ts +9 -0
- package/build/src/cookies/parser.js +69 -0
- package/build/src/cookies/serializer.d.ts +11 -0
- package/build/src/cookies/serializer.js +39 -0
- package/build/src/debug.d.ts +3 -0
- package/build/src/debug.js +2 -0
- package/build/src/define_config.d.ts +2 -0
- package/build/src/define_config.js +40 -0
- package/build/src/define_middleware.d.ts +4 -0
- package/build/src/define_middleware.js +6 -0
- package/build/src/exceptions/abort_exception.d.ts +5 -0
- package/build/src/exceptions/abort_exception.js +6 -0
- package/build/src/exceptions/cannot_lookup_route.d.ts +5 -0
- package/build/src/exceptions/cannot_lookup_route.js +5 -0
- package/build/src/exceptions/http_exception.d.ts +6 -0
- package/build/src/exceptions/http_exception.js +20 -0
- package/build/src/exceptions/route_not_found.d.ts +5 -0
- package/build/src/exceptions/route_not_found.js +5 -0
- package/build/src/helpers.d.ts +6 -67
- package/build/src/helpers.js +13 -168
- package/build/src/http_context/local_storage.d.ts +9 -0
- package/build/src/http_context/local_storage.js +14 -0
- package/build/src/http_context/main.d.ts +20 -0
- package/build/src/http_context/main.js +49 -0
- package/build/src/middleware/store.d.ts +11 -0
- package/build/src/middleware/store.js +33 -0
- package/build/src/qs.d.ts +7 -0
- package/build/src/qs.js +13 -0
- package/build/src/redirect.d.ts +18 -0
- package/build/src/redirect.js +80 -0
- package/build/src/request.d.ts +81 -0
- package/build/src/request.js +315 -0
- package/build/src/response.d.ts +108 -0
- package/build/src/response.js +587 -0
- package/build/src/router/brisk.d.ts +18 -0
- package/build/src/router/brisk.js +35 -0
- package/build/src/router/executor.d.ts +4 -0
- package/build/src/router/executor.js +16 -0
- package/build/src/router/group.d.ts +19 -0
- package/build/src/router/group.js +117 -0
- package/build/src/router/lookup_store/main.d.ts +17 -0
- package/build/src/router/lookup_store/main.js +37 -0
- package/build/src/router/lookup_store/route_finder.d.ts +8 -0
- package/build/src/router/lookup_store/route_finder.js +28 -0
- package/build/src/router/lookup_store/url_builder.d.ts +16 -0
- package/build/src/router/lookup_store/url_builder.js +111 -0
- package/build/src/router/main.d.ts +36 -0
- package/build/src/router/main.js +161 -0
- package/build/src/router/matchers.d.ts +14 -0
- package/build/src/router/matchers.js +15 -0
- package/build/src/router/resource.d.ts +27 -0
- package/build/src/router/resource.js +124 -0
- package/build/src/router/route.d.ts +28 -0
- package/build/src/router/route.js +135 -0
- package/build/src/router/store.d.ts +12 -0
- package/build/src/router/store.js +87 -0
- package/build/src/server/factories/final_handler.d.ts +4 -0
- package/build/src/server/factories/final_handler.js +17 -0
- package/build/src/server/factories/middleware_handler.d.ts +5 -0
- package/build/src/server/factories/middleware_handler.js +5 -0
- package/build/src/server/factories/use_return_value.d.ts +2 -0
- package/build/src/server/factories/use_return_value.js +9 -0
- package/build/src/server/factories/write_response.d.ts +2 -0
- package/build/src/server/factories/write_response.js +12 -0
- package/build/src/server/main.d.ts +23 -0
- package/build/src/server/main.js +124 -0
- package/build/src/types/base.d.ts +5 -0
- package/build/src/types/base.js +1 -0
- package/build/src/types/middleware.d.ts +14 -0
- package/build/src/types/middleware.js +1 -0
- package/build/src/types/qs.d.ts +15 -0
- package/build/src/types/qs.js +1 -0
- package/build/src/types/request.d.ts +7 -0
- package/build/src/types/request.js +1 -0
- package/build/src/types/response.d.ts +18 -0
- package/build/src/types/response.js +1 -0
- package/build/src/types/route.d.ts +74 -0
- package/build/src/types/route.js +1 -0
- package/build/src/types/server.d.ts +13 -0
- package/build/src/types/server.js +1 -0
- package/package.json +88 -86
- package/build/adonis-typings/container.d.ts +0 -24
- package/build/adonis-typings/container.js +0 -8
- package/build/adonis-typings/context.d.ts +0 -73
- package/build/adonis-typings/context.js +0 -8
- package/build/adonis-typings/cookie-client.d.ts +0 -34
- package/build/adonis-typings/cookie-client.js +0 -8
- package/build/adonis-typings/http-server.d.ts +0 -98
- package/build/adonis-typings/http-server.js +0 -8
- package/build/adonis-typings/index.d.ts +0 -16
- package/build/adonis-typings/index.js +0 -16
- package/build/adonis-typings/middleware.d.ts +0 -95
- package/build/adonis-typings/middleware.js +0 -8
- package/build/adonis-typings/request.d.ts +0 -556
- package/build/adonis-typings/request.js +0 -8
- package/build/adonis-typings/response.d.ts +0 -440
- package/build/adonis-typings/response.js +0 -8
- package/build/adonis-typings/route.d.ts +0 -559
- package/build/adonis-typings/route.js +0 -8
- package/build/exceptions.json +0 -110
- package/build/providers/HttpServerProvider.d.ts +0 -46
- package/build/providers/HttpServerProvider.js +0 -100
- package/build/src/Cookie/Client/index.d.ts +0 -39
- package/build/src/Cookie/Client/index.js +0 -108
- package/build/src/Cookie/Drivers/Encrypted.d.ts +0 -24
- package/build/src/Cookie/Drivers/Encrypted.js +0 -42
- package/build/src/Cookie/Drivers/Plain.d.ts +0 -23
- package/build/src/Cookie/Drivers/Plain.js +0 -40
- package/build/src/Cookie/Drivers/Signed.d.ts +0 -24
- package/build/src/Cookie/Drivers/Signed.js +0 -42
- package/build/src/Cookie/Parser/index.d.ts +0 -61
- package/build/src/Cookie/Parser/index.js +0 -174
- package/build/src/Cookie/Serializer/index.d.ts +0 -46
- package/build/src/Cookie/Serializer/index.js +0 -88
- package/build/src/Exceptions/HttpException.d.ts +0 -20
- package/build/src/Exceptions/HttpException.js +0 -36
- package/build/src/Exceptions/RouterException.d.ts +0 -36
- package/build/src/Exceptions/RouterException.js +0 -76
- package/build/src/HttpContext/LocalStorage/index.d.ts +0 -24
- package/build/src/HttpContext/LocalStorage/index.js +0 -28
- package/build/src/HttpContext/index.d.ts +0 -90
- package/build/src/HttpContext/index.js +0 -181
- package/build/src/MiddlewareStore/index.d.ts +0 -92
- package/build/src/MiddlewareStore/index.js +0 -133
- package/build/src/Redirect/index.d.ts +0 -71
- package/build/src/Redirect/index.js +0 -139
- package/build/src/Request/index.d.ts +0 -619
- package/build/src/Request/index.js +0 -862
- package/build/src/Response/index.d.ts +0 -414
- package/build/src/Response/index.js +0 -1010
- package/build/src/Router/BriskRoute.d.ts +0 -53
- package/build/src/Router/BriskRoute.js +0 -74
- package/build/src/Router/Group.d.ts +0 -101
- package/build/src/Router/Group.js +0 -165
- package/build/src/Router/LookupStore.d.ts +0 -122
- package/build/src/Router/LookupStore.js +0 -264
- package/build/src/Router/Matchers.d.ts +0 -31
- package/build/src/Router/Matchers.js +0 -43
- package/build/src/Router/Resource.d.ts +0 -95
- package/build/src/Router/Resource.js +0 -182
- package/build/src/Router/Route.d.ts +0 -138
- package/build/src/Router/Route.js +0 -204
- package/build/src/Router/Store.d.ts +0 -93
- package/build/src/Router/Store.js +0 -211
- package/build/src/Router/index.d.ts +0 -142
- package/build/src/Router/index.js +0 -333
- package/build/src/Server/ExceptionManager/index.d.ts +0 -49
- package/build/src/Server/ExceptionManager/index.js +0 -96
- package/build/src/Server/Hooks/index.d.ts +0 -43
- package/build/src/Server/Hooks/index.js +0 -77
- package/build/src/Server/PreCompiler/index.d.ts +0 -60
- package/build/src/Server/PreCompiler/index.js +0 -143
- package/build/src/Server/RequestHandler/index.d.ts +0 -39
- package/build/src/Server/RequestHandler/index.js +0 -87
- package/build/src/Server/index.d.ts +0 -90
- package/build/src/Server/index.js +0 -175
- package/build/standalone.d.ts +0 -14
- package/build/standalone.js +0 -23
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @adonisjs/http-server
|
|
3
|
-
*
|
|
4
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
/// <reference path="../../adonis-typings/index.d.ts" />
|
|
10
|
-
import { Macroable } from 'macroable';
|
|
11
|
-
import { Route } from './Route';
|
|
12
|
-
import { BriskRouteContract, RouteMatchersNode, RouteHandler, MakeUrlOptions } from '@ioc:Adonis/Core/Route';
|
|
13
|
-
/**
|
|
14
|
-
* Brisk route enables you to expose expressive API for
|
|
15
|
-
* defining route handler.
|
|
16
|
-
*
|
|
17
|
-
* For example: AdonisJs uses [[BriskRoute]] `Route.on().render()`
|
|
18
|
-
* to render a view without defining a controller method or
|
|
19
|
-
* closure.
|
|
20
|
-
*/
|
|
21
|
-
export declare class BriskRoute extends Macroable implements BriskRouteContract {
|
|
22
|
-
private pattern;
|
|
23
|
-
private globalMatchers;
|
|
24
|
-
protected static macros: {};
|
|
25
|
-
protected static getters: {};
|
|
26
|
-
/**
|
|
27
|
-
* Invoked by is reference to the parent method that calls `setHandler` on
|
|
28
|
-
* this class. We keep a reference to the parent method name for raising
|
|
29
|
-
* meaningful exception
|
|
30
|
-
*/
|
|
31
|
-
private invokedBy;
|
|
32
|
-
/**
|
|
33
|
-
* Reference to route instance. Set after `setHandler` is called
|
|
34
|
-
*/
|
|
35
|
-
route: null | Route;
|
|
36
|
-
constructor(pattern: string, globalMatchers: RouteMatchersNode);
|
|
37
|
-
/**
|
|
38
|
-
* Set handler for the brisk route. The `invokedBy` string is the reference
|
|
39
|
-
* to the method that calls this method. It is required to create human
|
|
40
|
-
* readable error message when `setHandler` is called for multiple
|
|
41
|
-
* times.
|
|
42
|
-
*/
|
|
43
|
-
setHandler(handler: RouteHandler, invokedBy: string, methods?: string[]): Route;
|
|
44
|
-
/**
|
|
45
|
-
* Redirect to a given route. Params from the original request will be used when no
|
|
46
|
-
* custom params are defined
|
|
47
|
-
*/
|
|
48
|
-
redirect(identifier: string, params?: any[] | Record<string, any>, options?: MakeUrlOptions): Route;
|
|
49
|
-
/**
|
|
50
|
-
* Redirect request to a fixed path
|
|
51
|
-
*/
|
|
52
|
-
redirectToPath(url: string): Route;
|
|
53
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @adonisjs/http-server
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.BriskRoute = void 0;
|
|
12
|
-
/// <reference path="../../adonis-typings/index.ts" />
|
|
13
|
-
const macroable_1 = require("macroable");
|
|
14
|
-
const utils_1 = require("@poppinss/utils");
|
|
15
|
-
const Route_1 = require("./Route");
|
|
16
|
-
/**
|
|
17
|
-
* Brisk route enables you to expose expressive API for
|
|
18
|
-
* defining route handler.
|
|
19
|
-
*
|
|
20
|
-
* For example: AdonisJs uses [[BriskRoute]] `Route.on().render()`
|
|
21
|
-
* to render a view without defining a controller method or
|
|
22
|
-
* closure.
|
|
23
|
-
*/
|
|
24
|
-
class BriskRoute extends macroable_1.Macroable {
|
|
25
|
-
constructor(pattern, globalMatchers) {
|
|
26
|
-
super();
|
|
27
|
-
this.pattern = pattern;
|
|
28
|
-
this.globalMatchers = globalMatchers;
|
|
29
|
-
/**
|
|
30
|
-
* Invoked by is reference to the parent method that calls `setHandler` on
|
|
31
|
-
* this class. We keep a reference to the parent method name for raising
|
|
32
|
-
* meaningful exception
|
|
33
|
-
*/
|
|
34
|
-
this.invokedBy = '';
|
|
35
|
-
/**
|
|
36
|
-
* Reference to route instance. Set after `setHandler` is called
|
|
37
|
-
*/
|
|
38
|
-
this.route = null;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Set handler for the brisk route. The `invokedBy` string is the reference
|
|
42
|
-
* to the method that calls this method. It is required to create human
|
|
43
|
-
* readable error message when `setHandler` is called for multiple
|
|
44
|
-
* times.
|
|
45
|
-
*/
|
|
46
|
-
setHandler(handler, invokedBy, methods) {
|
|
47
|
-
if (this.route) {
|
|
48
|
-
throw new utils_1.Exception(`\`Route.${invokedBy}\` and \`${this.invokedBy}\` cannot be called together`, 500, 'E_MULTIPLE_BRISK_HANDLERS');
|
|
49
|
-
}
|
|
50
|
-
this.route = new Route_1.Route(this.pattern, methods || ['GET', 'HEAD'], handler, this.globalMatchers);
|
|
51
|
-
this.invokedBy = invokedBy;
|
|
52
|
-
return this.route;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Redirect to a given route. Params from the original request will be used when no
|
|
56
|
-
* custom params are defined
|
|
57
|
-
*/
|
|
58
|
-
redirect(identifier, params, options) {
|
|
59
|
-
return this.setHandler(async (ctx) => {
|
|
60
|
-
return ctx.response.redirect().toRoute(identifier, params || ctx.params, options);
|
|
61
|
-
}, 'redirect');
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Redirect request to a fixed path
|
|
65
|
-
*/
|
|
66
|
-
redirectToPath(url) {
|
|
67
|
-
return this.setHandler(async (ctx) => {
|
|
68
|
-
return ctx.response.redirect().toPath(url);
|
|
69
|
-
}, 'redirect');
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.BriskRoute = BriskRoute;
|
|
73
|
-
BriskRoute.macros = {};
|
|
74
|
-
BriskRoute.getters = {};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @adonisjs/http-server
|
|
3
|
-
*
|
|
4
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
/// <reference path="../../adonis-typings/index.d.ts" />
|
|
10
|
-
import { Macroable } from 'macroable';
|
|
11
|
-
import { RouteGroupContract, RouteParamMatcher, RouteMiddlewareHandler } from '@ioc:Adonis/Core/Route';
|
|
12
|
-
import { Route } from './Route';
|
|
13
|
-
import { BriskRoute } from './BriskRoute';
|
|
14
|
-
import { RouteResource } from './Resource';
|
|
15
|
-
/**
|
|
16
|
-
* Group class exposes the API to take action on a group of routes.
|
|
17
|
-
* The group routes must be pre-defined using the constructor.
|
|
18
|
-
*/
|
|
19
|
-
export declare class RouteGroup extends Macroable implements RouteGroupContract {
|
|
20
|
-
routes: (Route | RouteResource | BriskRoute | RouteGroup)[];
|
|
21
|
-
protected static macros: {};
|
|
22
|
-
protected static getters: {};
|
|
23
|
-
/**
|
|
24
|
-
* Array of middleware registered on the group
|
|
25
|
-
*/
|
|
26
|
-
private groupMiddleware;
|
|
27
|
-
/**
|
|
28
|
-
* We register the group middleware only once with the route
|
|
29
|
-
* and then mutate the internal stack. This ensures that
|
|
30
|
-
* group own middleware are pushed to the last, but the
|
|
31
|
-
* entire group of middleware is added to the front
|
|
32
|
-
* in the routes
|
|
33
|
-
*/
|
|
34
|
-
private registeredMiddlewareWithRoute;
|
|
35
|
-
constructor(routes: (Route | RouteResource | BriskRoute | RouteGroup)[]);
|
|
36
|
-
/**
|
|
37
|
-
* Invokes a given method with params on the route instance or route
|
|
38
|
-
* resource instance
|
|
39
|
-
*/
|
|
40
|
-
private invoke;
|
|
41
|
-
/**
|
|
42
|
-
* Define Regex matchers for a given param for all the routes.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```ts
|
|
46
|
-
* Route.group(() => {
|
|
47
|
-
* }).where('id', /^[0-9]+/)
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
where(param: string, matcher: RouteParamMatcher): this;
|
|
51
|
-
/**
|
|
52
|
-
* Define prefix all the routes in the group.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```ts
|
|
56
|
-
* Route.group(() => {
|
|
57
|
-
* }).prefix('v1')
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
prefix(prefix: string): this;
|
|
61
|
-
/**
|
|
62
|
-
* Define domain for all the routes.
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```ts
|
|
66
|
-
* Route.group(() => {
|
|
67
|
-
* }).domain(':name.adonisjs.com')
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
domain(domain: string): this;
|
|
71
|
-
/**
|
|
72
|
-
* Prepend name to the routes name.
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```ts
|
|
76
|
-
* Route.group(() => {
|
|
77
|
-
* }).as('version1')
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
as(name: string): this;
|
|
81
|
-
/**
|
|
82
|
-
* Prepend an array of middleware to all routes middleware.
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```ts
|
|
86
|
-
* Route.group(() => {
|
|
87
|
-
* }).middleware(['auth'])
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
middleware(middleware: RouteMiddlewareHandler | RouteMiddlewareHandler[], prepend?: boolean): this;
|
|
91
|
-
/**
|
|
92
|
-
* Define namespace for all the routes inside the group.
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```ts
|
|
96
|
-
* Route.group(() => {
|
|
97
|
-
* }).namespace('App/Admin/Controllers')
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
namespace(namespace: string): this;
|
|
101
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @adonisjs/http-server
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.RouteGroup = void 0;
|
|
12
|
-
/// <reference path="../../adonis-typings/index.ts" />
|
|
13
|
-
const macroable_1 = require("macroable");
|
|
14
|
-
const BriskRoute_1 = require("./BriskRoute");
|
|
15
|
-
const Resource_1 = require("./Resource");
|
|
16
|
-
const RouterException_1 = require("../Exceptions/RouterException");
|
|
17
|
-
/**
|
|
18
|
-
* Group class exposes the API to take action on a group of routes.
|
|
19
|
-
* The group routes must be pre-defined using the constructor.
|
|
20
|
-
*/
|
|
21
|
-
class RouteGroup extends macroable_1.Macroable {
|
|
22
|
-
constructor(routes) {
|
|
23
|
-
super();
|
|
24
|
-
this.routes = routes;
|
|
25
|
-
/**
|
|
26
|
-
* Array of middleware registered on the group
|
|
27
|
-
*/
|
|
28
|
-
this.groupMiddleware = [];
|
|
29
|
-
/**
|
|
30
|
-
* We register the group middleware only once with the route
|
|
31
|
-
* and then mutate the internal stack. This ensures that
|
|
32
|
-
* group own middleware are pushed to the last, but the
|
|
33
|
-
* entire group of middleware is added to the front
|
|
34
|
-
* in the routes
|
|
35
|
-
*/
|
|
36
|
-
this.registeredMiddlewareWithRoute = false;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Invokes a given method with params on the route instance or route
|
|
40
|
-
* resource instance
|
|
41
|
-
*/
|
|
42
|
-
invoke(route, method, params) {
|
|
43
|
-
if (route instanceof Resource_1.RouteResource) {
|
|
44
|
-
route.routes.forEach((child) => this.invoke(child, method, params));
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
if (route instanceof RouteGroup) {
|
|
48
|
-
route.routes.forEach((child) => this.invoke(child, method, params));
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
if (route instanceof BriskRoute_1.BriskRoute) {
|
|
52
|
-
/* istanbul ignore else */
|
|
53
|
-
if (route.route) {
|
|
54
|
-
/*
|
|
55
|
-
* Raise error when trying to prefix route name but route doesn't have
|
|
56
|
-
* a name
|
|
57
|
-
*/
|
|
58
|
-
if (method === 'as' && !route.route.name) {
|
|
59
|
-
throw RouterException_1.RouterException.cannotDefineGroupName();
|
|
60
|
-
}
|
|
61
|
-
route.route[method](...params);
|
|
62
|
-
}
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
/*
|
|
66
|
-
* Raise error when trying to prefix route name but route doesn't have
|
|
67
|
-
* a name
|
|
68
|
-
*/
|
|
69
|
-
if (method === 'as' && !route.name) {
|
|
70
|
-
throw RouterException_1.RouterException.cannotDefineGroupName();
|
|
71
|
-
}
|
|
72
|
-
route[method](...params);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Define Regex matchers for a given param for all the routes.
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* ```ts
|
|
79
|
-
* Route.group(() => {
|
|
80
|
-
* }).where('id', /^[0-9]+/)
|
|
81
|
-
* ```
|
|
82
|
-
*/
|
|
83
|
-
where(param, matcher) {
|
|
84
|
-
this.routes.forEach((route) => this.invoke(route, 'where', [param, matcher]));
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Define prefix all the routes in the group.
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
* ```ts
|
|
92
|
-
* Route.group(() => {
|
|
93
|
-
* }).prefix('v1')
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
prefix(prefix) {
|
|
97
|
-
this.routes.forEach((route) => this.invoke(route, 'prefix', [prefix]));
|
|
98
|
-
return this;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Define domain for all the routes.
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* ```ts
|
|
105
|
-
* Route.group(() => {
|
|
106
|
-
* }).domain(':name.adonisjs.com')
|
|
107
|
-
* ```
|
|
108
|
-
*/
|
|
109
|
-
domain(domain) {
|
|
110
|
-
this.routes.forEach((route) => this.invoke(route, 'domain', [domain]));
|
|
111
|
-
return this;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Prepend name to the routes name.
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* ```ts
|
|
118
|
-
* Route.group(() => {
|
|
119
|
-
* }).as('version1')
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
as(name) {
|
|
123
|
-
this.routes.forEach((route) => this.invoke(route, 'as', [name, true]));
|
|
124
|
-
return this;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Prepend an array of middleware to all routes middleware.
|
|
128
|
-
*
|
|
129
|
-
* @example
|
|
130
|
-
* ```ts
|
|
131
|
-
* Route.group(() => {
|
|
132
|
-
* }).middleware(['auth'])
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
middleware(middleware, prepend = false) {
|
|
136
|
-
middleware = Array.isArray(middleware) ? middleware : [middleware];
|
|
137
|
-
if (prepend) {
|
|
138
|
-
middleware.forEach((one) => this.groupMiddleware.unshift(one));
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
middleware.forEach((one) => this.groupMiddleware.push(one));
|
|
142
|
-
}
|
|
143
|
-
if (!this.registeredMiddlewareWithRoute) {
|
|
144
|
-
this.registeredMiddlewareWithRoute = true;
|
|
145
|
-
this.routes.forEach((route) => this.invoke(route, 'middleware', [this.groupMiddleware, true]));
|
|
146
|
-
}
|
|
147
|
-
return this;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Define namespace for all the routes inside the group.
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* ```ts
|
|
154
|
-
* Route.group(() => {
|
|
155
|
-
* }).namespace('App/Admin/Controllers')
|
|
156
|
-
* ```
|
|
157
|
-
*/
|
|
158
|
-
namespace(namespace) {
|
|
159
|
-
this.routes.forEach((route) => this.invoke(route, 'namespace', [namespace]));
|
|
160
|
-
return this;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
exports.RouteGroup = RouteGroup;
|
|
164
|
-
RouteGroup.macros = {};
|
|
165
|
-
RouteGroup.getters = {};
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { RouteJSON, LookupStoreTree, UrlBuilderContract, LookupStoreContract } from '@ioc:Adonis/Core/Route';
|
|
2
|
-
import { EncryptionContract } from '@ioc:Adonis/Core/Encryption';
|
|
3
|
-
/**
|
|
4
|
-
* A class to encapsulate finding routes
|
|
5
|
-
*/
|
|
6
|
-
declare class Routes {
|
|
7
|
-
private routes;
|
|
8
|
-
constructor(routes: RouteJSON[]);
|
|
9
|
-
/**
|
|
10
|
-
* Find a route by indentifier
|
|
11
|
-
*/
|
|
12
|
-
find(routeIdentifier: string): RouteJSON | null;
|
|
13
|
-
/**
|
|
14
|
-
* Find a route by indentifier or fail
|
|
15
|
-
*/
|
|
16
|
-
findOrFail(routeIdentifier: string): RouteJSON;
|
|
17
|
-
/**
|
|
18
|
-
* Find if a route exists
|
|
19
|
-
*/
|
|
20
|
-
has(routeIdentifier: string): boolean;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Url builder is responsible for building the URLs
|
|
24
|
-
*/
|
|
25
|
-
export declare class UrlBuilder implements UrlBuilderContract {
|
|
26
|
-
private encryption;
|
|
27
|
-
private routes;
|
|
28
|
-
/**
|
|
29
|
-
* Params to be used for building the URL
|
|
30
|
-
*/
|
|
31
|
-
private routeParams;
|
|
32
|
-
/**
|
|
33
|
-
* A custom query string to append to the URL
|
|
34
|
-
*/
|
|
35
|
-
private queryString;
|
|
36
|
-
/**
|
|
37
|
-
* A boolean to know if the route should be looked
|
|
38
|
-
* up inside the route store or not
|
|
39
|
-
*/
|
|
40
|
-
private lookupRoute;
|
|
41
|
-
/**
|
|
42
|
-
* A baseUrl to prefix to the endpoint
|
|
43
|
-
*/
|
|
44
|
-
private baseUrl;
|
|
45
|
-
constructor(encryption: EncryptionContract, routes: Routes);
|
|
46
|
-
/**
|
|
47
|
-
* Processes the pattern against the params
|
|
48
|
-
*/
|
|
49
|
-
private processPattern;
|
|
50
|
-
/**
|
|
51
|
-
* Suffix the query string to the URL
|
|
52
|
-
*/
|
|
53
|
-
private suffixQueryString;
|
|
54
|
-
/**
|
|
55
|
-
* Prefix a custom url to the final URI
|
|
56
|
-
*/
|
|
57
|
-
prefixUrl(url: string): this;
|
|
58
|
-
/**
|
|
59
|
-
* Disable route lookup. Calling this method considers
|
|
60
|
-
* the "identifier" as the route pattern
|
|
61
|
-
*/
|
|
62
|
-
disableRouteLookup(): this;
|
|
63
|
-
/**
|
|
64
|
-
* Append query string to the final URI
|
|
65
|
-
*/
|
|
66
|
-
qs(queryString?: Record<string, any>): this;
|
|
67
|
-
/**
|
|
68
|
-
* Define required params to resolve the route
|
|
69
|
-
*/
|
|
70
|
-
params(params?: any[] | Record<string, any>): this;
|
|
71
|
-
/**
|
|
72
|
-
* Generate url for the given route identifier
|
|
73
|
-
*/
|
|
74
|
-
make(identifier: string): string;
|
|
75
|
-
/**
|
|
76
|
-
* Generate url for the given route identifier
|
|
77
|
-
*/
|
|
78
|
-
makeSigned(identifier: string, options?: {
|
|
79
|
-
expiresIn?: string | number;
|
|
80
|
-
purpose?: string;
|
|
81
|
-
}): string;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* The look up store to make URLs for a given route by looking
|
|
85
|
-
* it by its name, route handler or the pattern directly.
|
|
86
|
-
*/
|
|
87
|
-
export declare class LookupStore implements LookupStoreContract {
|
|
88
|
-
private encryption;
|
|
89
|
-
/**
|
|
90
|
-
* Shape of the registered routes. Optimized for lookups
|
|
91
|
-
*/
|
|
92
|
-
tree: LookupStoreTree;
|
|
93
|
-
constructor(encryption: EncryptionContract);
|
|
94
|
-
/**
|
|
95
|
-
* Register a route for lookups
|
|
96
|
-
*/
|
|
97
|
-
register(route: RouteJSON): void;
|
|
98
|
-
/**
|
|
99
|
-
* Returns the route builder for the root domain
|
|
100
|
-
*/
|
|
101
|
-
builder(): UrlBuilder;
|
|
102
|
-
/**
|
|
103
|
-
* Returns the route builder a given domain.
|
|
104
|
-
*/
|
|
105
|
-
builderForDomain(domainPattern: string): UrlBuilder;
|
|
106
|
-
/**
|
|
107
|
-
* Find a route by indentifier. Optionally one can find routes inside
|
|
108
|
-
* a given domain
|
|
109
|
-
*/
|
|
110
|
-
find(routeIdentifier: string, domainPattern?: string): RouteJSON | null;
|
|
111
|
-
/**
|
|
112
|
-
* Find a route by indentifier or fail. Optionally one can find routes inside
|
|
113
|
-
* a given domain
|
|
114
|
-
*/
|
|
115
|
-
findOrFail(routeIdentifier: string, domainPattern?: string): RouteJSON;
|
|
116
|
-
/**
|
|
117
|
-
* Find if a route for given identifier exists. Optionally one can find routes inside
|
|
118
|
-
* a given domain
|
|
119
|
-
*/
|
|
120
|
-
has(routeIdentifier: string, domainPattern?: string): boolean;
|
|
121
|
-
}
|
|
122
|
-
export {};
|