@adonisjs/http-server 6.8.2-1 → 6.8.2-3
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
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
|
}
|
|
@@ -23,7 +23,7 @@ export class BriskRoute extends Macroable {
|
|
|
23
23
|
return this.route;
|
|
24
24
|
}
|
|
25
25
|
redirect(identifier, params, options) {
|
|
26
|
-
return this.setHandler(async (ctx)
|
|
26
|
+
return this.setHandler(async function redirectsToRoute(ctx) {
|
|
27
27
|
const redirector = ctx.response.redirect();
|
|
28
28
|
if (options?.status) {
|
|
29
29
|
redirector.status(options.status);
|
|
@@ -32,7 +32,7 @@ export class BriskRoute extends Macroable {
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
redirectToPath(url, options) {
|
|
35
|
-
return this.setHandler(async (ctx)
|
|
35
|
+
return this.setHandler(async function redirectsToPath(ctx) {
|
|
36
36
|
const redirector = ctx.response.redirect();
|
|
37
37
|
if (options?.status) {
|
|
38
38
|
redirector.status(options.status);
|
|
@@ -29,8 +29,8 @@ export declare class Router extends LookupStore {
|
|
|
29
29
|
patch<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
|
|
30
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
|
-
resource(resource: string, controller: string): RouteResource;
|
|
33
|
-
shallowResource(resource: string, controller: string): RouteResource;
|
|
32
|
+
resource(resource: string, controller: string | LazyImport<Constructor<any>> | Constructor<any>): RouteResource;
|
|
33
|
+
shallowResource(resource: string, controller: string | LazyImport<Constructor<any>> | Constructor<any>): RouteResource;
|
|
34
34
|
on(pattern: string): BriskRoute;
|
|
35
35
|
where(param: string, matcher: RouteMatcher | string | RegExp): this;
|
|
36
36
|
commit(): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Macroable from '@poppinss/macroable';
|
|
2
2
|
import type { Application } from '@adonisjs/application';
|
|
3
3
|
import { Route } from './route.js';
|
|
4
|
+
import type { Constructor, LazyImport } from '../types/base.js';
|
|
4
5
|
import type { ParsedGlobalMiddleware } from '../types/middleware.js';
|
|
5
6
|
import type { ResourceActionNames, RouteMatcher, RouteMatchers } from '../types/route.js';
|
|
6
7
|
export declare class RouteResource extends Macroable {
|
|
@@ -8,7 +9,7 @@ export declare class RouteResource extends Macroable {
|
|
|
8
9
|
routes: Route[];
|
|
9
10
|
constructor(app: Application<any>, routerMiddleware: ParsedGlobalMiddleware[], options: {
|
|
10
11
|
resource: string;
|
|
11
|
-
controller: string
|
|
12
|
+
controller: string | LazyImport<Constructor<any>> | Constructor<any>;
|
|
12
13
|
globalMatchers: RouteMatchers;
|
|
13
14
|
shallow: boolean;
|
|
14
15
|
});
|
|
@@ -42,7 +42,9 @@ export class RouteResource extends Macroable {
|
|
|
42
42
|
const route = new Route(this.#app, this.#routerMiddleware, {
|
|
43
43
|
pattern,
|
|
44
44
|
methods,
|
|
45
|
-
handler:
|
|
45
|
+
handler: typeof this.#controller === 'string'
|
|
46
|
+
? `${this.#controller}.${action}`
|
|
47
|
+
: [this.#controller, action],
|
|
46
48
|
globalMatchers: this.#globalMatchers,
|
|
47
49
|
});
|
|
48
50
|
route.as(`${this.#routesBaseName}.${action}`);
|
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-3",
|
|
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",
|