@adonisjs/http-server 8.0.0-next.12 → 8.0.0-next.13
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/define_config-DpDqx7A4.js +1953 -0
- package/build/factories/http_context.d.ts +4 -4
- package/build/factories/main.d.ts +2 -2
- package/build/factories/main.js +162 -346
- package/build/factories/request.d.ts +3 -3
- package/build/factories/response.d.ts +3 -3
- package/build/helpers-C_2HouOe.js +52 -0
- package/build/helpers-Dt-25M21.js +660 -0
- package/build/index.d.ts +2 -2
- package/build/index.js +157 -375
- package/build/src/client/url_builder.js +3 -12
- package/build/src/exception_handler.d.ts +7 -0
- package/build/src/helpers.js +3 -26
- package/build/src/http_context/main.d.ts +7 -7
- package/build/src/redirect.d.ts +2 -2
- package/build/src/request.d.ts +1 -1
- package/build/src/response.d.ts +2 -2
- package/build/src/server/main.d.ts +5 -5
- package/build/src/types/main.js +1 -0
- package/build/src/types/response.d.ts +6 -1
- package/build/url_builder-piNQy-CF.js +114 -0
- package/package.json +19 -16
- package/build/chunk-2QM3D5BN.js +0 -87
- package/build/chunk-77CSRFCU.js +0 -131
- package/build/chunk-L2UOVWDK.js +0 -4441
- package/build/chunk-QDK57QGB.js +0 -1176
package/build/src/response.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ import type { CastableHeader, CookieOptions, ResponseConfig, ResponseStream } fr
|
|
|
19
19
|
* response.download('/path/to/file.pdf')
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
export declare class
|
|
22
|
+
export declare class HttpResponse extends Macroable {
|
|
23
23
|
#private;
|
|
24
24
|
request: IncomingMessage;
|
|
25
25
|
response: ServerResponse;
|
|
@@ -46,7 +46,7 @@ export declare class Response extends Macroable {
|
|
|
46
46
|
/**
|
|
47
47
|
* The readable stream instance configured for the response
|
|
48
48
|
*/
|
|
49
|
-
get outgoingStream():
|
|
49
|
+
get outgoingStream(): ResponseStream | undefined;
|
|
50
50
|
/**
|
|
51
51
|
* Configuration for file streaming including path and etag generation flag
|
|
52
52
|
*/
|
|
@@ -8,9 +8,9 @@ import { type ContainerResolver } from '@adonisjs/fold';
|
|
|
8
8
|
import type { ServerResponse, IncomingMessage, Server as HttpServer } from 'node:http';
|
|
9
9
|
import type { MiddlewareAsClass, ParsedGlobalMiddleware } from '../types/middleware.ts';
|
|
10
10
|
import type { ServerConfig, HttpServerEvents, ErrorHandlerAsAClass, TestingMiddlewarePipeline } from '../types/server.ts';
|
|
11
|
-
import {
|
|
12
|
-
import { Response } from '../response.ts';
|
|
11
|
+
import { HttpRequest } from '../request.ts';
|
|
13
12
|
import { Router } from '../router/main.ts';
|
|
13
|
+
import { HttpResponse } from '../response.ts';
|
|
14
14
|
import { HttpContext } from '../http_context/main.ts';
|
|
15
15
|
/**
|
|
16
16
|
* The Server class provides the core HTTP server implementation for AdonisJS.
|
|
@@ -105,7 +105,7 @@ export declare class Server {
|
|
|
105
105
|
* @param res - Node.js ServerResponse
|
|
106
106
|
* @returns New Request instance
|
|
107
107
|
*/
|
|
108
|
-
createRequest(req: IncomingMessage, res: ServerResponse):
|
|
108
|
+
createRequest(req: IncomingMessage, res: ServerResponse): HttpRequest;
|
|
109
109
|
/**
|
|
110
110
|
* Creates a Response instance from Node.js request/response objects
|
|
111
111
|
*
|
|
@@ -113,7 +113,7 @@ export declare class Server {
|
|
|
113
113
|
* @param res - Node.js ServerResponse
|
|
114
114
|
* @returns New Response instance
|
|
115
115
|
*/
|
|
116
|
-
createResponse(req: IncomingMessage, res: ServerResponse):
|
|
116
|
+
createResponse(req: IncomingMessage, res: ServerResponse): HttpResponse;
|
|
117
117
|
/**
|
|
118
118
|
* Creates an HttpContext instance with request-specific logger
|
|
119
119
|
*
|
|
@@ -122,7 +122,7 @@ export declare class Server {
|
|
|
122
122
|
* @param resolver - Container resolver for dependency injection
|
|
123
123
|
* @returns New HttpContext instance
|
|
124
124
|
*/
|
|
125
|
-
createHttpContext(request:
|
|
125
|
+
createHttpContext(request: HttpRequest, response: HttpResponse, resolver: ContainerResolver<any>): HttpContext;
|
|
126
126
|
/**
|
|
127
127
|
* Gets the list of registered global middleware
|
|
128
128
|
*
|
package/build/src/types/main.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -30,6 +30,11 @@ export type CastableHeader = string | number | boolean | string[] | number[] | b
|
|
|
30
30
|
* Configuration options for HTTP response handling and processing
|
|
31
31
|
*/
|
|
32
32
|
export type ResponseConfig = {
|
|
33
|
+
/**
|
|
34
|
+
* Define a custom serializer to serialize the response body
|
|
35
|
+
* to a JSON string
|
|
36
|
+
*/
|
|
37
|
+
serializeJSON(payload: unknown): string | undefined;
|
|
33
38
|
/**
|
|
34
39
|
* Whether or not to generate etags for responses. Etags can be
|
|
35
40
|
* enabled/disabled when sending response as well.
|
|
@@ -51,4 +56,4 @@ export type ResponseConfig = {
|
|
|
51
56
|
/**
|
|
52
57
|
* A readable stream that can be piped to the response stream method
|
|
53
58
|
*/
|
|
54
|
-
export type ResponseStream = Readable
|
|
59
|
+
export type ResponseStream = Readable | ReadableStream<any>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { n as findRoute, t as createURL } from "./helpers-C_2HouOe.js";
|
|
2
|
+
function createUrlBuilder(routesLoader, searchParamsStringifier) {
|
|
3
|
+
let domainsList;
|
|
4
|
+
let domainsRoutes;
|
|
5
|
+
function createUrlForRoute(identifier, params, options, method) {
|
|
6
|
+
if (!domainsRoutes) {
|
|
7
|
+
domainsRoutes = typeof routesLoader === "function" ? routesLoader() : routesLoader;
|
|
8
|
+
if (!domainsRoutes || typeof domainsRoutes !== "object") throw new Error(`Cannot construct routes. Expected the value to be an object, instead received ${typeof domainsRoutes}`);
|
|
9
|
+
if (!domainsList) domainsList = Object.keys(domainsRoutes).filter((domain$1) => domain$1 !== "root");
|
|
10
|
+
}
|
|
11
|
+
const domain = domainsList.find((name) => identifier.startsWith(`${name}@`));
|
|
12
|
+
const routeIdentifier = domain ? identifier.replace(/* @__PURE__ */ new RegExp(`^${domain}@`), "") : identifier;
|
|
13
|
+
const route = findRoute(domainsRoutes, routeIdentifier, domain, method, true);
|
|
14
|
+
if (!route) {
|
|
15
|
+
if (method) throw new Error(`Cannot lookup route "${routeIdentifier}" for method "${method}"`);
|
|
16
|
+
throw new Error(`Cannot lookup route "${routeIdentifier}"`);
|
|
17
|
+
}
|
|
18
|
+
return createURL(route.name ?? route.pattern, route.tokens, searchParamsStringifier, params, options);
|
|
19
|
+
}
|
|
20
|
+
const urlFor = function route(...[identifier, params, options]) {
|
|
21
|
+
return createUrlForRoute(identifier, params, options);
|
|
22
|
+
};
|
|
23
|
+
urlFor.get = function urlForMethodGet(...[identifier, params, options]) {
|
|
24
|
+
const method = "GET";
|
|
25
|
+
const url = createUrlForRoute(identifier, params, options, method);
|
|
26
|
+
return {
|
|
27
|
+
url,
|
|
28
|
+
method,
|
|
29
|
+
toString() {
|
|
30
|
+
return url;
|
|
31
|
+
},
|
|
32
|
+
form: {
|
|
33
|
+
action: url,
|
|
34
|
+
method
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
urlFor.post = function urlForMethodPost(...[identifier, params, options]) {
|
|
39
|
+
const method = "POST";
|
|
40
|
+
const url = createUrlForRoute(identifier, params, options, method);
|
|
41
|
+
return {
|
|
42
|
+
url,
|
|
43
|
+
method,
|
|
44
|
+
toString() {
|
|
45
|
+
return url;
|
|
46
|
+
},
|
|
47
|
+
form: {
|
|
48
|
+
action: url,
|
|
49
|
+
method
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
urlFor.put = function urlForMethodPut(...[identifier, params, options]) {
|
|
54
|
+
const method = "PUT";
|
|
55
|
+
const url = createUrlForRoute(identifier, params, options, method);
|
|
56
|
+
return {
|
|
57
|
+
url,
|
|
58
|
+
method,
|
|
59
|
+
toString() {
|
|
60
|
+
return url;
|
|
61
|
+
},
|
|
62
|
+
form: {
|
|
63
|
+
action: url,
|
|
64
|
+
method
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
urlFor.patch = function urlForMethodPatch(...[identifier, params, options]) {
|
|
69
|
+
const method = "PATCH";
|
|
70
|
+
const url = createUrlForRoute(identifier, params, options, method);
|
|
71
|
+
return {
|
|
72
|
+
url,
|
|
73
|
+
method,
|
|
74
|
+
toString() {
|
|
75
|
+
return url;
|
|
76
|
+
},
|
|
77
|
+
form: {
|
|
78
|
+
action: url,
|
|
79
|
+
method
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
urlFor.delete = function urlForMethodDelete(...[identifier, params, options]) {
|
|
84
|
+
const method = "DELETE";
|
|
85
|
+
const url = createUrlForRoute(identifier, params, options, method);
|
|
86
|
+
return {
|
|
87
|
+
url,
|
|
88
|
+
method,
|
|
89
|
+
toString() {
|
|
90
|
+
return url;
|
|
91
|
+
},
|
|
92
|
+
form: {
|
|
93
|
+
action: url,
|
|
94
|
+
method
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
urlFor.method = function urlForCustomMethod(method, ...[identifier, params, options]) {
|
|
99
|
+
const url = createUrlForRoute(identifier, params, options, method);
|
|
100
|
+
return {
|
|
101
|
+
url,
|
|
102
|
+
method,
|
|
103
|
+
toString() {
|
|
104
|
+
return url;
|
|
105
|
+
},
|
|
106
|
+
form: {
|
|
107
|
+
action: url,
|
|
108
|
+
method
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
return urlFor;
|
|
113
|
+
}
|
|
114
|
+
export { createUrlBuilder as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/http-server",
|
|
3
|
-
"version": "8.0.0-next.
|
|
3
|
+
"version": "8.0.0-next.13",
|
|
4
4
|
"description": "AdonisJS HTTP server with support packed with Routing and Cookies",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"test": "cross-env NODE_DEBUG=adonisjs:http c8 npm run quick:test",
|
|
25
25
|
"typecheck": "tsc --noEmit",
|
|
26
26
|
"precompile": "npm run lint",
|
|
27
|
-
"compile": "
|
|
27
|
+
"compile": "tsdown && tsc --emitDeclarationOnly --declaration",
|
|
28
28
|
"build": "npm run compile",
|
|
29
29
|
"prebenchmark": "npm run build",
|
|
30
30
|
"benchmark": "node benchmarks/index.js",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@japa/runner": "^4.4.0",
|
|
59
59
|
"@japa/snapshot": "^2.0.9",
|
|
60
60
|
"@poppinss/ts-exec": "^1.4.1",
|
|
61
|
-
"@release-it/conventional-changelog": "^10.0.
|
|
61
|
+
"@release-it/conventional-changelog": "^10.0.2",
|
|
62
62
|
"@types/accepts": "^1.3.7",
|
|
63
63
|
"@types/content-disposition": "^0.5.9",
|
|
64
64
|
"@types/destroy": "^1.0.3",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"@types/fresh": "^0.5.3",
|
|
68
68
|
"@types/fs-extra": "^11.0.4",
|
|
69
69
|
"@types/mime-types": "^3.0.1",
|
|
70
|
-
"@types/node": "^24.
|
|
70
|
+
"@types/node": "^24.10.1",
|
|
71
71
|
"@types/on-finished": "^2.3.5",
|
|
72
72
|
"@types/pem": "^1.14.4",
|
|
73
73
|
"@types/proxy-addr": "^2.0.3",
|
|
@@ -75,22 +75,22 @@
|
|
|
75
75
|
"@types/supertest": "^6.0.3",
|
|
76
76
|
"@types/type-is": "^1.6.7",
|
|
77
77
|
"@types/vary": "^1.1.3",
|
|
78
|
-
"@vinejs/vine": "^4.
|
|
78
|
+
"@vinejs/vine": "^4.1.0",
|
|
79
79
|
"autocannon": "^8.0.0",
|
|
80
80
|
"c8": "^10.1.3",
|
|
81
81
|
"cross-env": "^10.1.0",
|
|
82
|
-
"eslint": "^9.
|
|
83
|
-
"fastify": "^5.6.
|
|
82
|
+
"eslint": "^9.39.1",
|
|
83
|
+
"fastify": "^5.6.2",
|
|
84
84
|
"fs-extra": "^11.3.2",
|
|
85
85
|
"get-port": "^7.1.0",
|
|
86
86
|
"http-status-codes": "^2.3.0",
|
|
87
87
|
"pem": "^1.14.8",
|
|
88
|
-
"prettier": "^3.
|
|
88
|
+
"prettier": "^3.7.3",
|
|
89
89
|
"reflect-metadata": "^0.2.2",
|
|
90
|
-
"release-it": "^19.0.
|
|
90
|
+
"release-it": "^19.0.6",
|
|
91
91
|
"supertest": "^7.1.4",
|
|
92
|
-
"
|
|
93
|
-
"typedoc": "^0.28.
|
|
92
|
+
"tsdown": "^0.17.0-beta.5",
|
|
93
|
+
"typedoc": "^0.28.15",
|
|
94
94
|
"typescript": "^5.9.3",
|
|
95
95
|
"youch": "^4.1.0-beta.11"
|
|
96
96
|
},
|
|
@@ -99,15 +99,15 @@
|
|
|
99
99
|
"@poppinss/matchit": "^3.2.0",
|
|
100
100
|
"@poppinss/middleware": "^3.2.6",
|
|
101
101
|
"@poppinss/utils": "^7.0.0-next.3",
|
|
102
|
-
"@sindresorhus/is": "^7.1.
|
|
102
|
+
"@sindresorhus/is": "^7.1.1",
|
|
103
103
|
"accepts": "^1.3.8",
|
|
104
|
-
"content-disposition": "^0.
|
|
105
|
-
"cookie": "^
|
|
104
|
+
"content-disposition": "^1.0.1",
|
|
105
|
+
"cookie-es": "^2.0.0",
|
|
106
106
|
"destroy": "^1.2.0",
|
|
107
107
|
"encodeurl": "^2.0.0",
|
|
108
108
|
"etag": "^1.8.1",
|
|
109
109
|
"fresh": "^0.5.2",
|
|
110
|
-
"mime-types": "^3.0.
|
|
110
|
+
"mime-types": "^3.0.2",
|
|
111
111
|
"on-finished": "^2.4.1",
|
|
112
112
|
"proxy-addr": "^2.0.7",
|
|
113
113
|
"qs": "^6.14.0",
|
|
@@ -177,7 +177,7 @@
|
|
|
177
177
|
]
|
|
178
178
|
},
|
|
179
179
|
"prettier": "@adonisjs/prettier-config",
|
|
180
|
-
"
|
|
180
|
+
"tsdown": {
|
|
181
181
|
"entry": [
|
|
182
182
|
"./index.ts",
|
|
183
183
|
"./src/helpers.ts",
|
|
@@ -188,7 +188,10 @@
|
|
|
188
188
|
"outDir": "./build",
|
|
189
189
|
"clean": true,
|
|
190
190
|
"format": "esm",
|
|
191
|
+
"minify": "dce-only",
|
|
192
|
+
"fixedExtension": false,
|
|
191
193
|
"dts": false,
|
|
194
|
+
"treeshake": false,
|
|
192
195
|
"sourcemap": false,
|
|
193
196
|
"target": "esnext"
|
|
194
197
|
}
|
package/build/chunk-2QM3D5BN.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __export = (target, all) => {
|
|
3
|
-
for (var name in all)
|
|
4
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
// src/client/helpers.ts
|
|
8
|
-
function findRoute(domainsRoutes, routeIdentifier, domain, method, disableLegacyLookup) {
|
|
9
|
-
if (!domain) {
|
|
10
|
-
let route = null;
|
|
11
|
-
for (const routeDomain of Object.keys(domainsRoutes)) {
|
|
12
|
-
route = findRoute(domainsRoutes, routeIdentifier, routeDomain, method, disableLegacyLookup);
|
|
13
|
-
if (route) {
|
|
14
|
-
break;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return route;
|
|
18
|
-
}
|
|
19
|
-
const routes = domainsRoutes[domain];
|
|
20
|
-
if (!routes) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
const lookupByName = true;
|
|
24
|
-
const lookupByPattern = !disableLegacyLookup;
|
|
25
|
-
const lookupByController = !disableLegacyLookup;
|
|
26
|
-
return routes.find((route) => {
|
|
27
|
-
if (method && !route.methods.includes(method)) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
if (lookupByName && route.name === routeIdentifier || lookupByPattern && route.pattern === routeIdentifier) {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
if (lookupByController && route.handler && typeof route.handler === "object") {
|
|
34
|
-
return "reference" in route.handler && route.handler.reference === routeIdentifier;
|
|
35
|
-
}
|
|
36
|
-
return false;
|
|
37
|
-
}) || null;
|
|
38
|
-
}
|
|
39
|
-
function createURL(pattern, tokens, searchParamsStringifier, params, options) {
|
|
40
|
-
const uriSegments = [];
|
|
41
|
-
const paramsArray = Array.isArray(params) ? params : null;
|
|
42
|
-
const paramsObject = !Array.isArray(params) ? params ?? {} : {};
|
|
43
|
-
let paramsIndex = 0;
|
|
44
|
-
for (const token of tokens) {
|
|
45
|
-
if (token.type === 0) {
|
|
46
|
-
uriSegments.push(token.val === "/" ? "" : `${token.val}${token.end}`);
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if (token.type === 2) {
|
|
50
|
-
const values = paramsArray ? paramsArray.slice(paramsIndex) : paramsObject["*"];
|
|
51
|
-
if (!Array.isArray(values) || !values.length) {
|
|
52
|
-
throw new Error(
|
|
53
|
-
`Cannot make URL for "${pattern}". Invalid value provided for the wildcard param`
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
uriSegments.push(`${values.join("/")}${token.end}`);
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
const paramName = token.val;
|
|
60
|
-
const value = paramsArray ? paramsArray[paramsIndex] : paramsObject[paramName];
|
|
61
|
-
const isDefined = value !== void 0 && value !== null;
|
|
62
|
-
if (token.type === 1 && !isDefined) {
|
|
63
|
-
throw new Error(
|
|
64
|
-
`Cannot make URL for "${pattern}". Missing value for the "${paramName}" param`
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
if (isDefined) {
|
|
68
|
-
uriSegments.push(`${value}${token.end}`);
|
|
69
|
-
}
|
|
70
|
-
paramsIndex++;
|
|
71
|
-
}
|
|
72
|
-
let URI = `/${uriSegments.join("/")}`;
|
|
73
|
-
if (options?.prefixUrl) {
|
|
74
|
-
URI = `${options?.prefixUrl.replace(/\/$/, "")}${URI}`;
|
|
75
|
-
}
|
|
76
|
-
if (options?.qs) {
|
|
77
|
-
const queryString = searchParamsStringifier(options?.qs);
|
|
78
|
-
URI = queryString ? `${URI}?${queryString}` : URI;
|
|
79
|
-
}
|
|
80
|
-
return URI;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export {
|
|
84
|
-
__export,
|
|
85
|
-
findRoute,
|
|
86
|
-
createURL
|
|
87
|
-
};
|
package/build/chunk-77CSRFCU.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createURL,
|
|
3
|
-
findRoute
|
|
4
|
-
} from "./chunk-2QM3D5BN.js";
|
|
5
|
-
|
|
6
|
-
// src/client/url_builder.ts
|
|
7
|
-
function createUrlBuilder(routesLoader, searchParamsStringifier) {
|
|
8
|
-
let domainsList;
|
|
9
|
-
let domainsRoutes;
|
|
10
|
-
function createUrlForRoute(identifier, params, options, method) {
|
|
11
|
-
if (!domainsRoutes) {
|
|
12
|
-
domainsRoutes = typeof routesLoader === "function" ? routesLoader() : routesLoader;
|
|
13
|
-
}
|
|
14
|
-
if (!domainsList) {
|
|
15
|
-
domainsList = Object.keys(domainsRoutes).filter((domain2) => domain2 !== "root");
|
|
16
|
-
}
|
|
17
|
-
const domain = domainsList.find((name) => identifier.startsWith(`${name}@`));
|
|
18
|
-
const routeIdentifier = domain ? identifier.replace(new RegExp(`^${domain}@`), "") : identifier;
|
|
19
|
-
const route = findRoute(domainsRoutes, routeIdentifier, domain, method, true);
|
|
20
|
-
if (!route) {
|
|
21
|
-
if (method) {
|
|
22
|
-
throw new Error(`Cannot lookup route "${routeIdentifier}" for method "${method}"`);
|
|
23
|
-
}
|
|
24
|
-
throw new Error(`Cannot lookup route "${routeIdentifier}"`);
|
|
25
|
-
}
|
|
26
|
-
return createURL(
|
|
27
|
-
route.name ?? route.pattern,
|
|
28
|
-
route.tokens,
|
|
29
|
-
searchParamsStringifier,
|
|
30
|
-
params,
|
|
31
|
-
options
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
const urlFor = function route(...[identifier, params, options]) {
|
|
35
|
-
return createUrlForRoute(identifier, params, options);
|
|
36
|
-
};
|
|
37
|
-
urlFor.get = function urlForMethodGet(...[identifier, params, options]) {
|
|
38
|
-
const method = "GET";
|
|
39
|
-
const url = createUrlForRoute(identifier, params, options, method);
|
|
40
|
-
return {
|
|
41
|
-
url,
|
|
42
|
-
method,
|
|
43
|
-
toString() {
|
|
44
|
-
return url;
|
|
45
|
-
},
|
|
46
|
-
form: {
|
|
47
|
-
action: url,
|
|
48
|
-
method
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
urlFor.post = function urlForMethodPost(...[identifier, params, options]) {
|
|
53
|
-
const method = "POST";
|
|
54
|
-
const url = createUrlForRoute(identifier, params, options, method);
|
|
55
|
-
return {
|
|
56
|
-
url,
|
|
57
|
-
method,
|
|
58
|
-
toString() {
|
|
59
|
-
return url;
|
|
60
|
-
},
|
|
61
|
-
form: {
|
|
62
|
-
action: url,
|
|
63
|
-
method
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
urlFor.put = function urlForMethodPut(...[identifier, params, options]) {
|
|
68
|
-
const method = "PUT";
|
|
69
|
-
const url = createUrlForRoute(identifier, params, options, method);
|
|
70
|
-
return {
|
|
71
|
-
url,
|
|
72
|
-
method,
|
|
73
|
-
toString() {
|
|
74
|
-
return url;
|
|
75
|
-
},
|
|
76
|
-
form: {
|
|
77
|
-
action: url,
|
|
78
|
-
method
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
urlFor.patch = function urlForMethodPatch(...[identifier, params, options]) {
|
|
83
|
-
const method = "PATCH";
|
|
84
|
-
const url = createUrlForRoute(identifier, params, options, method);
|
|
85
|
-
return {
|
|
86
|
-
url,
|
|
87
|
-
method,
|
|
88
|
-
toString() {
|
|
89
|
-
return url;
|
|
90
|
-
},
|
|
91
|
-
form: {
|
|
92
|
-
action: url,
|
|
93
|
-
method
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
urlFor.delete = function urlForMethodDelete(...[identifier, params, options]) {
|
|
98
|
-
const method = "DELETE";
|
|
99
|
-
const url = createUrlForRoute(identifier, params, options, method);
|
|
100
|
-
return {
|
|
101
|
-
url,
|
|
102
|
-
method,
|
|
103
|
-
toString() {
|
|
104
|
-
return url;
|
|
105
|
-
},
|
|
106
|
-
form: {
|
|
107
|
-
action: url,
|
|
108
|
-
method
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
urlFor.method = function urlForCustomMethod(method, ...[identifier, params, options]) {
|
|
113
|
-
const url = createUrlForRoute(identifier, params, options, method);
|
|
114
|
-
return {
|
|
115
|
-
url,
|
|
116
|
-
method,
|
|
117
|
-
toString() {
|
|
118
|
-
return url;
|
|
119
|
-
},
|
|
120
|
-
form: {
|
|
121
|
-
action: url,
|
|
122
|
-
method
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
return urlFor;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export {
|
|
130
|
-
createUrlBuilder
|
|
131
|
-
};
|