@adonisjs/http-server 6.8.2-2 → 6.8.2-4
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/response.js +3 -4
- package/build/src/router/lookup_store/url_builder.js +2 -2
- package/build/src/router/main.d.ts +3 -2
- package/build/src/router/main.js +4 -0
- package/build/src/router/parser.d.ts +2 -0
- package/build/src/router/parser.js +5 -0
- package/build/src/router/store.js +3 -2
- package/package.json +3 -3
package/build/src/response.js
CHANGED
|
@@ -5,16 +5,15 @@ import mime from 'mime-types';
|
|
|
5
5
|
import destroy from 'destroy';
|
|
6
6
|
import { extname } from 'node:path';
|
|
7
7
|
import onFinished from 'on-finished';
|
|
8
|
-
import { promisify } from 'node:util';
|
|
9
8
|
import json from '@poppinss/utils/json';
|
|
10
9
|
import Macroable from '@poppinss/macroable';
|
|
11
|
-
import { createReadStream
|
|
10
|
+
import { createReadStream } from 'node:fs';
|
|
11
|
+
import { stat } from 'node:fs/promises';
|
|
12
12
|
import { RuntimeException } from '@poppinss/utils';
|
|
13
13
|
import contentDisposition from 'content-disposition';
|
|
14
14
|
import { Redirect } from './redirect.js';
|
|
15
15
|
import { CookieSerializer } from './cookies/serializer.js';
|
|
16
16
|
import { E_HTTP_REQUEST_ABORTED } from './exceptions.js';
|
|
17
|
-
const statFn = promisify(stat);
|
|
18
17
|
const CACHEABLE_HTTP_METHODS = ['GET', 'HEAD'];
|
|
19
18
|
export class Response extends Macroable {
|
|
20
19
|
request;
|
|
@@ -203,7 +202,7 @@ export class Response extends Macroable {
|
|
|
203
202
|
}
|
|
204
203
|
async streamFileForDownload(filePath, generateEtag, errorCallback) {
|
|
205
204
|
try {
|
|
206
|
-
const stats = await
|
|
205
|
+
const stats = await stat(filePath);
|
|
207
206
|
if (!stats || !stats.isFile()) {
|
|
208
207
|
throw new TypeError('response.download only accepts path to a file');
|
|
209
208
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import matchit from '@poppinss/matchit';
|
|
2
1
|
import { RuntimeException } from '@poppinss/utils';
|
|
2
|
+
import { parseRoutePattern } from '../parser.js';
|
|
3
3
|
export class UrlBuilder {
|
|
4
4
|
#qsParser;
|
|
5
5
|
#params = {};
|
|
@@ -28,7 +28,7 @@ export class UrlBuilder {
|
|
|
28
28
|
const paramsArray = Array.isArray(this.#params) ? this.#params : null;
|
|
29
29
|
const paramsObject = !Array.isArray(this.#params) ? this.#params : {};
|
|
30
30
|
let paramsIndex = 0;
|
|
31
|
-
const tokens =
|
|
31
|
+
const tokens = parseRoutePattern(pattern);
|
|
32
32
|
for (const token of tokens) {
|
|
33
33
|
if (token.type === 0) {
|
|
34
34
|
uriSegments.push(`${token.val}${token.end}`);
|
|
@@ -5,17 +5,18 @@ 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 { Constructor, LazyImport } from '../types/base.js';
|
|
9
8
|
import { LookupStore } from './lookup_store/main.js';
|
|
10
9
|
import { RouteMatchers as Matchers } from './matchers.js';
|
|
10
|
+
import type { Constructor, LazyImport } from '../types/base.js';
|
|
11
11
|
import type { MiddlewareAsClass, ParsedGlobalMiddleware } from '../types/middleware.js';
|
|
12
|
-
import type { RouteFn, MatchedRoute, RouteMatcher, MakeUrlOptions, MakeSignedUrlOptions, GetControllerHandlers } from '../types/route.js';
|
|
12
|
+
import type { RouteFn, MatchedRoute, RouteMatcher, RouteMatchers, 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)[];
|
|
16
16
|
usingDomains: boolean;
|
|
17
17
|
matchers: Matchers;
|
|
18
18
|
constructor(app: Application<any>, encryption: Encryption, qsParser: Qs);
|
|
19
|
+
parsePattern(pattern: string, matchers?: RouteMatchers): import("../types/route.js").MatchItRouteToken[];
|
|
19
20
|
use(middleware: LazyImport<MiddlewareAsClass>[]): this;
|
|
20
21
|
named<NamedMiddleware extends Record<string, LazyImport<MiddlewareAsClass>>>(collection: NamedMiddleware): { [K in keyof NamedMiddleware]: <Args extends import("../types/middleware.js").GetMiddlewareArgs<import("../types/base.js").UnWrapLazyImport<NamedMiddleware[K]>>>(...args: Args) => {
|
|
21
22
|
name: K;
|
package/build/src/router/main.js
CHANGED
|
@@ -10,6 +10,7 @@ import { RouteResource } from './resource.js';
|
|
|
10
10
|
import { LookupStore } from './lookup_store/main.js';
|
|
11
11
|
import { RouteMatchers as Matchers } from './matchers.js';
|
|
12
12
|
import { defineNamedMiddleware } from '../define_middleware.js';
|
|
13
|
+
import { parseRoutePattern } from './parser.js';
|
|
13
14
|
export class Router extends LookupStore {
|
|
14
15
|
#app;
|
|
15
16
|
#store = new RoutesStore();
|
|
@@ -31,6 +32,9 @@ export class Router extends LookupStore {
|
|
|
31
32
|
}
|
|
32
33
|
this.routes.push(entity);
|
|
33
34
|
}
|
|
35
|
+
parsePattern(pattern, matchers) {
|
|
36
|
+
return parseRoutePattern(pattern, matchers);
|
|
37
|
+
}
|
|
34
38
|
use(middleware) {
|
|
35
39
|
middleware.forEach((one) => this.#middleware.push(moduleImporter(one, 'handle').toHandleMethod()));
|
|
36
40
|
return this;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import matchit from '@poppinss/matchit';
|
|
2
2
|
import lodash from '@poppinss/utils/lodash';
|
|
3
3
|
import { RuntimeException } from '@poppinss/utils';
|
|
4
|
+
import { parseRoutePattern } from './parser.js';
|
|
4
5
|
export class RoutesStore {
|
|
5
6
|
usingDomains = false;
|
|
6
7
|
tree = { tokens: [], domains: {} };
|
|
7
8
|
#getDomainNode(domain) {
|
|
8
9
|
if (!this.tree.domains[domain]) {
|
|
9
|
-
this.tree.tokens.push(
|
|
10
|
+
this.tree.tokens.push(parseRoutePattern(domain));
|
|
10
11
|
this.tree.domains[domain] = {};
|
|
11
12
|
}
|
|
12
13
|
return this.tree.domains[domain];
|
|
@@ -48,7 +49,7 @@ export class RoutesStore {
|
|
|
48
49
|
if (route.domain !== 'root') {
|
|
49
50
|
this.usingDomains = true;
|
|
50
51
|
}
|
|
51
|
-
const tokens =
|
|
52
|
+
const tokens = parseRoutePattern(route.pattern, route.matchers);
|
|
52
53
|
const routeNode = lodash.merge({ meta: {} }, lodash.pick(route, ['pattern', 'handler', 'meta', 'middleware', 'name', 'execute']));
|
|
53
54
|
routeNode.meta.params = this.#collectRouteParams(routeNode, tokens);
|
|
54
55
|
route.methods.forEach((method) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/http-server",
|
|
3
|
-
"version": "6.8.2-
|
|
3
|
+
"version": "6.8.2-4",
|
|
4
4
|
"description": "AdonisJS HTTP server with support packed with Routing and Cookies",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@japa/run-failed-tests": "^1.1.1",
|
|
53
53
|
"@japa/runner": "^2.5.1",
|
|
54
54
|
"@japa/spec-reporter": "^1.3.3",
|
|
55
|
-
"@swc/core": "^1.3.
|
|
55
|
+
"@swc/core": "^1.3.40",
|
|
56
56
|
"@types/accepts": "^1.3.5",
|
|
57
57
|
"@types/content-disposition": "^0.5.5",
|
|
58
58
|
"@types/cookie": "^0.5.1",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@types/fs-extra": "^11.0.1",
|
|
64
64
|
"@types/http-status-codes": "^1.2.0",
|
|
65
65
|
"@types/mime-types": "^2.1.1",
|
|
66
|
-
"@types/node": "^18.15.
|
|
66
|
+
"@types/node": "^18.15.2",
|
|
67
67
|
"@types/on-finished": "^2.3.1",
|
|
68
68
|
"@types/pem": "^1.9.6",
|
|
69
69
|
"@types/proxy-addr": "^2.0.0",
|