@adonisjs/http-server 7.0.3 → 7.2.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/build/{chunk-KYYKTJYU.js → chunk-MUS67JY5.js} +132 -52
- package/build/chunk-MUS67JY5.js.map +1 -0
- package/build/factories/main.js +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/src/response.d.ts +8 -0
- package/build/src/response_status.d.ts +64 -0
- package/package.json +4 -4
- package/build/chunk-KYYKTJYU.js.map +0 -1
package/build/factories/main.js
CHANGED
package/build/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { Request } from './src/request.js';
|
|
2
2
|
export { Response } from './src/response.js';
|
|
3
|
+
export { ResponseStatus } from './src/response_status.js';
|
|
3
4
|
export { Redirect } from './src/redirect.js';
|
|
4
5
|
export { Server } from './src/server/main.js';
|
|
5
6
|
export { Router } from './src/router/main.js';
|
package/build/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Redirect,
|
|
10
10
|
Request,
|
|
11
11
|
Response,
|
|
12
|
+
ResponseStatus,
|
|
12
13
|
Route,
|
|
13
14
|
RouteGroup,
|
|
14
15
|
RouteResource,
|
|
@@ -17,7 +18,7 @@ import {
|
|
|
17
18
|
defineConfig,
|
|
18
19
|
exceptions_exports,
|
|
19
20
|
parseRange
|
|
20
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-MUS67JY5.js";
|
|
21
22
|
|
|
22
23
|
// src/exception_handler.ts
|
|
23
24
|
import is from "@sindresorhus/is";
|
|
@@ -308,6 +309,7 @@ export {
|
|
|
308
309
|
Redirect,
|
|
309
310
|
Request,
|
|
310
311
|
Response,
|
|
312
|
+
ResponseStatus,
|
|
311
313
|
Route,
|
|
312
314
|
RouteGroup,
|
|
313
315
|
RouteResource,
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/exception_handler.ts"],"sourcesContent":["/*\n * @adonisjs/http-server\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport is from '@sindresorhus/is'\nimport Macroable from '@poppinss/macroable'\nimport type { Level } from '@adonisjs/logger/types'\n\nimport { parseRange } from './helpers.js'\nimport * as errors from './exceptions.js'\nimport type { HttpContext } from './http_context/main.js'\nimport type { HttpError, StatusPageRange, StatusPageRenderer } from './types/server.js'\n\n/**\n * The base HTTP exception handler one can inherit from to handle\n * HTTP exceptions.\n *\n * The HTTP exception handler has support for\n *\n * - Ability to render exceptions by calling the render method on the exception.\n * - Rendering status pages\n * - Pretty printing errors during development\n * - Transforming errors to JSON or HTML using content negotiation\n * - Reporting errors\n */\nexport class ExceptionHandler extends Macroable {\n /**\n * Computed from the status pages property\n */\n #expandedStatusPages?: Record<number, StatusPageRenderer>\n\n /**\n * Whether or not to render debug info. When set to true, the errors\n * will have the complete error stack.\n */\n protected debug: boolean = process.env.NODE_ENV !== 'production'\n\n /**\n * Whether or not to render status pages. When set to true, the unhandled\n * errors with matching status codes will be rendered using a status\n * page.\n */\n protected renderStatusPages: boolean = process.env.NODE_ENV === 'production'\n\n /**\n * A collection of error status code range and the view to render.\n */\n protected statusPages: Record<StatusPageRange, StatusPageRenderer> = {}\n\n /**\n * Enable/disable errors reporting\n */\n protected reportErrors: boolean = true\n\n /**\n * An array of exception classes to ignore when\n * reporting an error\n */\n protected ignoreExceptions: any[] = [\n errors.E_HTTP_EXCEPTION,\n errors.E_ROUTE_NOT_FOUND,\n errors.E_CANNOT_LOOKUP_ROUTE,\n errors.E_HTTP_REQUEST_ABORTED,\n ]\n\n /**\n * An array of HTTP status codes to ignore when reporting\n * an error\n */\n protected ignoreStatuses: number[] = [400, 422, 401]\n\n /**\n * An array of error codes to ignore when reporting\n * an error\n */\n protected ignoreCodes: string[] = []\n\n /**\n * Expands status pages\n */\n #expandStatusPages() {\n if (!this.#expandedStatusPages) {\n this.#expandedStatusPages = Object.keys(this.statusPages).reduce(\n (result, range) => {\n const renderer = this.statusPages[range as StatusPageRange]\n result = Object.assign(result, parseRange(range, renderer))\n return result\n },\n {} as Record<number, StatusPageRenderer>\n )\n }\n\n return this.#expandedStatusPages\n }\n\n /**\n * Forcefully tweaking the type of the error object to\n * have known properties.\n */\n #toHttpError(error: unknown): HttpError {\n const httpError: any = is.object(error) ? error : new Error(String(error))\n if (!httpError.message) {\n httpError.message = 'Internal server error'\n }\n if (!httpError.status) {\n httpError.status = 500\n }\n return httpError\n }\n\n /**\n * Error reporting context\n */\n protected context(ctx: HttpContext): any {\n const requestId = ctx.request.id()\n return requestId\n ? {\n 'x-request-id': requestId,\n }\n : {}\n }\n\n /**\n * Returns the log level for an error based upon the error\n * status code.\n */\n protected getErrorLogLevel(error: HttpError): Level {\n if (error.status >= 500) {\n return 'error'\n }\n\n if (error.status >= 400) {\n return 'warn'\n }\n\n return 'info'\n }\n\n /**\n * A boolean to control if errors should be rendered with\n * all the available debugging info.\n */\n protected isDebuggingEnabled(_: HttpContext): boolean {\n return this.debug\n }\n\n /**\n * Returns a boolean by checking if an error should be reported.\n */\n protected shouldReport(error: HttpError): boolean {\n if (this.reportErrors === false) {\n return false\n }\n\n if (this.ignoreStatuses.includes(error.status)) {\n return false\n }\n\n if (error.code && this.ignoreCodes.includes(error.code)) {\n return false\n }\n\n if (this.ignoreExceptions.find((exception) => error instanceof exception)) {\n return false\n }\n\n return true\n }\n\n /**\n * Renders an error to JSON response\n */\n async renderErrorAsJSON(error: HttpError, ctx: HttpContext) {\n if (this.isDebuggingEnabled(ctx)) {\n const { default: Youch } = await import('youch')\n const json = await new Youch(error, ctx.request.request).toJSON()\n ctx.response.status(error.status).send(json.error)\n return\n }\n\n ctx.response.status(error.status).send({ message: error.message })\n }\n\n /**\n * Renders an error to JSON API response\n */\n async renderErrorAsJSONAPI(error: HttpError, ctx: HttpContext) {\n if (this.isDebuggingEnabled(ctx)) {\n const { default: Youch } = await import('youch')\n const json = await new Youch(error, ctx.request.request).toJSON()\n ctx.response.status(error.status).send(json.error)\n return\n }\n\n ctx.response.status(error.status).send({\n errors: [\n {\n title: error.message,\n code: error.code,\n status: error.status,\n },\n ],\n })\n }\n\n /**\n * Renders an error to HTML response\n */\n async renderErrorAsHTML(error: HttpError, ctx: HttpContext) {\n if (this.isDebuggingEnabled(ctx)) {\n const { default: Youch } = await import('youch')\n const html = await new Youch(error, ctx.request.request).toHTML({\n cspNonce: 'nonce' in ctx.response ? ctx.response.nonce : undefined,\n })\n ctx.response.status(error.status).send(html)\n return\n }\n\n ctx.response.status(error.status).send(`<p> ${error.message} </p>`)\n }\n\n /**\n * Renders the validation error message to a JSON\n * response\n */\n async renderValidationErrorAsJSON(error: HttpError, ctx: HttpContext) {\n ctx.response.status(error.status).send({\n errors: error.messages,\n })\n }\n\n /**\n * Renders the validation error message as per JSON API\n * spec\n */\n async renderValidationErrorAsJSONAPI(error: HttpError, ctx: HttpContext) {\n ctx.response.status(error.status).send({\n errors: error.messages.map((message: any) => {\n return {\n title: message.message,\n code: message.rule,\n source: {\n pointer: message.field,\n },\n meta: message.meta,\n }\n }),\n })\n }\n\n /**\n * Renders the validation error as an HTML string\n */\n async renderValidationErrorAsHTML(error: HttpError, ctx: HttpContext) {\n ctx.response\n .status(error.status)\n .type('html')\n .send(\n error.messages\n .map((message: any) => {\n return `${message.field} - ${message.message}`\n })\n .join('<br />')\n )\n }\n\n /**\n * Renders the error to response\n */\n renderError(error: HttpError, ctx: HttpContext) {\n switch (ctx.request.accepts(['html', 'application/vnd.api+json', 'json'])) {\n case 'application/vnd.api+json':\n return this.renderErrorAsJSONAPI(error, ctx)\n case 'json':\n return this.renderErrorAsJSON(error, ctx)\n case 'html':\n default:\n return this.renderErrorAsHTML(error, ctx)\n }\n }\n\n /**\n * Renders the validation error to response\n */\n renderValidationError(error: HttpError, ctx: HttpContext) {\n switch (ctx.request.accepts(['html', 'application/vnd.api+json', 'json'])) {\n case 'application/vnd.api+json':\n return this.renderValidationErrorAsJSONAPI(error, ctx)\n case 'json':\n return this.renderValidationErrorAsJSON(error, ctx)\n case 'html':\n default:\n return this.renderValidationErrorAsHTML(error, ctx)\n }\n }\n\n /**\n * Reports an error during an HTTP request\n */\n async report(error: unknown, ctx: HttpContext) {\n const httpError = this.#toHttpError(error)\n if (!this.shouldReport(httpError)) {\n return\n }\n\n if (typeof httpError.report === 'function') {\n httpError.report(httpError, ctx)\n return\n }\n\n /**\n * Log the error using the logger\n */\n const level = this.getErrorLogLevel(httpError)\n ctx.logger.log(\n level,\n {\n ...(level === 'error' || level === 'fatal' ? { err: httpError } : {}),\n ...this.context(ctx),\n },\n httpError.message\n )\n }\n\n /**\n * Handles the error during the HTTP request.\n */\n async handle(error: unknown, ctx: HttpContext) {\n const httpError = this.#toHttpError(error)\n\n /**\n * Self handle exception\n */\n if (typeof httpError.handle === 'function') {\n return httpError.handle(httpError, ctx)\n }\n\n /**\n * Handle validation error using the validation error\n * renderers\n */\n if (httpError.code === 'E_VALIDATION_ERROR' && 'messages' in httpError) {\n return this.renderValidationError(httpError, ctx)\n }\n\n /**\n * Render status page\n */\n const statusPages = this.#expandStatusPages()\n if (this.renderStatusPages && statusPages[httpError.status]) {\n const statusPageResponse = await statusPages[httpError.status](httpError, ctx)\n\n /**\n * Use return value and convert it into a response\n */\n if (\n statusPageResponse !== undefined && // Return value is explicitly defined\n !ctx.response.hasLazyBody && // Lazy body is not set\n statusPageResponse !== ctx.response // Return value is not the instance of response object\n ) {\n return ctx.response.safeStatus(httpError.status).send(statusPageResponse)\n }\n return statusPageResponse\n }\n\n /**\n * Use the format renderers.\n */\n return this.renderError(httpError, ctx)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AASA,OAAO,QAAQ;AACf,OAAO,eAAe;AAoBf,IAAM,mBAAN,cAA+B,UAAU;AAAA;AAAA;AAAA;AAAA,EAI9C;AAAA;AAAA;AAAA;AAAA;AAAA,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AA,MACA;AAAA,QACE,GAAI,UAAU,WAAW,UAAU,UAAU,EAAE,KAAK,UAAU,IAAI,CAAC;AAAA,QACnE,GAAG,KAAK,QAAQ,GAAG;AAAA,MACrB;AAAA,MACA,UAAU;AAAA,IACZ;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAO,OAAgB,KAAkB;AAC7C,UAAM,YAAY,KAAK,aAAa,KAAK;AAKzC,QAAI,OAAO,UAAU,WAAW,YAAY;AAC1C,aAAO,UAAU,OAAO,WAAW,GAAG;AAAA,IACxC;AAMA,QAAI,UAAU,SAAS,wBAAwB,cAAc,WAAW;AACtE,aAAO,KAAK,sBAAsB,WAAW,GAAG;AAAA,IAClD;AAKA,UAAM,cAAc,KAAK,mBAAmB;AAC5C,QAAI,KAAK,qBAAqB,YAAY,UAAU,MAAM,GAAG;AAC3D,YAAM,qBAAqB,MAAM,YAAY,UAAU,MAAM,EAAE,WAAW,GAAG;AAK7E,UACE,uBAAuB;AAAA,MACvB,CAAC,IAAI,SAAS;AAAA,MACd,uBAAuB,IAAI,UAC3B;AACA,eAAO,IAAI,SAAS,WAAW,UAAU,MAAM,EAAE,KAAK,kBAAkB;AAAA,MAC1E;AACA,aAAO;AAAA,IACT;AAKA,WAAO,KAAK,YAAY,WAAW,GAAG;AAAA,EACxC;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/exception_handler.ts"],"sourcesContent":["/*\n * @adonisjs/http-server\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport is from '@sindresorhus/is'\nimport Macroable from '@poppinss/macroable'\nimport type { Level } from '@adonisjs/logger/types'\n\nimport { parseRange } from './helpers.js'\nimport * as errors from './exceptions.js'\nimport type { HttpContext } from './http_context/main.js'\nimport type { HttpError, StatusPageRange, StatusPageRenderer } from './types/server.js'\n\n/**\n * The base HTTP exception handler one can inherit from to handle\n * HTTP exceptions.\n *\n * The HTTP exception handler has support for\n *\n * - Ability to render exceptions by calling the render method on the exception.\n * - Rendering status pages\n * - Pretty printing errors during development\n * - Transforming errors to JSON or HTML using content negotiation\n * - Reporting errors\n */\nexport class ExceptionHandler extends Macroable {\n /**\n * Computed from the status pages property\n */\n #expandedStatusPages?: Record<number, StatusPageRenderer>\n\n /**\n * Whether or not to render debug info. When set to true, the errors\n * will have the complete error stack.\n */\n protected debug: boolean = process.env.NODE_ENV !== 'production'\n\n /**\n * Whether or not to render status pages. When set to true, the unhandled\n * errors with matching status codes will be rendered using a status\n * page.\n */\n protected renderStatusPages: boolean = process.env.NODE_ENV === 'production'\n\n /**\n * A collection of error status code range and the view to render.\n */\n protected statusPages: Record<StatusPageRange, StatusPageRenderer> = {}\n\n /**\n * Enable/disable errors reporting\n */\n protected reportErrors: boolean = true\n\n /**\n * An array of exception classes to ignore when\n * reporting an error\n */\n protected ignoreExceptions: any[] = [\n errors.E_HTTP_EXCEPTION,\n errors.E_ROUTE_NOT_FOUND,\n errors.E_CANNOT_LOOKUP_ROUTE,\n errors.E_HTTP_REQUEST_ABORTED,\n ]\n\n /**\n * An array of HTTP status codes to ignore when reporting\n * an error\n */\n protected ignoreStatuses: number[] = [400, 422, 401]\n\n /**\n * An array of error codes to ignore when reporting\n * an error\n */\n protected ignoreCodes: string[] = []\n\n /**\n * Expands status pages\n */\n #expandStatusPages() {\n if (!this.#expandedStatusPages) {\n this.#expandedStatusPages = Object.keys(this.statusPages).reduce(\n (result, range) => {\n const renderer = this.statusPages[range as StatusPageRange]\n result = Object.assign(result, parseRange(range, renderer))\n return result\n },\n {} as Record<number, StatusPageRenderer>\n )\n }\n\n return this.#expandedStatusPages\n }\n\n /**\n * Forcefully tweaking the type of the error object to\n * have known properties.\n */\n #toHttpError(error: unknown): HttpError {\n const httpError: any = is.object(error) ? error : new Error(String(error))\n if (!httpError.message) {\n httpError.message = 'Internal server error'\n }\n if (!httpError.status) {\n httpError.status = 500\n }\n return httpError\n }\n\n /**\n * Error reporting context\n */\n protected context(ctx: HttpContext): any {\n const requestId = ctx.request.id()\n return requestId\n ? {\n 'x-request-id': requestId,\n }\n : {}\n }\n\n /**\n * Returns the log level for an error based upon the error\n * status code.\n */\n protected getErrorLogLevel(error: HttpError): Level {\n if (error.status >= 500) {\n return 'error'\n }\n\n if (error.status >= 400) {\n return 'warn'\n }\n\n return 'info'\n }\n\n /**\n * A boolean to control if errors should be rendered with\n * all the available debugging info.\n */\n protected isDebuggingEnabled(_: HttpContext): boolean {\n return this.debug\n }\n\n /**\n * Returns a boolean by checking if an error should be reported.\n */\n protected shouldReport(error: HttpError): boolean {\n if (this.reportErrors === false) {\n return false\n }\n\n if (this.ignoreStatuses.includes(error.status)) {\n return false\n }\n\n if (error.code && this.ignoreCodes.includes(error.code)) {\n return false\n }\n\n if (this.ignoreExceptions.find((exception) => error instanceof exception)) {\n return false\n }\n\n return true\n }\n\n /**\n * Renders an error to JSON response\n */\n async renderErrorAsJSON(error: HttpError, ctx: HttpContext) {\n if (this.isDebuggingEnabled(ctx)) {\n const { default: Youch } = await import('youch')\n const json = await new Youch(error, ctx.request.request).toJSON()\n ctx.response.status(error.status).send(json.error)\n return\n }\n\n ctx.response.status(error.status).send({ message: error.message })\n }\n\n /**\n * Renders an error to JSON API response\n */\n async renderErrorAsJSONAPI(error: HttpError, ctx: HttpContext) {\n if (this.isDebuggingEnabled(ctx)) {\n const { default: Youch } = await import('youch')\n const json = await new Youch(error, ctx.request.request).toJSON()\n ctx.response.status(error.status).send(json.error)\n return\n }\n\n ctx.response.status(error.status).send({\n errors: [\n {\n title: error.message,\n code: error.code,\n status: error.status,\n },\n ],\n })\n }\n\n /**\n * Renders an error to HTML response\n */\n async renderErrorAsHTML(error: HttpError, ctx: HttpContext) {\n if (this.isDebuggingEnabled(ctx)) {\n const { default: Youch } = await import('youch')\n const html = await new Youch(error, ctx.request.request).toHTML({\n cspNonce: 'nonce' in ctx.response ? ctx.response.nonce : undefined,\n })\n ctx.response.status(error.status).send(html)\n return\n }\n\n ctx.response.status(error.status).send(`<p> ${error.message} </p>`)\n }\n\n /**\n * Renders the validation error message to a JSON\n * response\n */\n async renderValidationErrorAsJSON(error: HttpError, ctx: HttpContext) {\n ctx.response.status(error.status).send({\n errors: error.messages,\n })\n }\n\n /**\n * Renders the validation error message as per JSON API\n * spec\n */\n async renderValidationErrorAsJSONAPI(error: HttpError, ctx: HttpContext) {\n ctx.response.status(error.status).send({\n errors: error.messages.map((message: any) => {\n return {\n title: message.message,\n code: message.rule,\n source: {\n pointer: message.field,\n },\n meta: message.meta,\n }\n }),\n })\n }\n\n /**\n * Renders the validation error as an HTML string\n */\n async renderValidationErrorAsHTML(error: HttpError, ctx: HttpContext) {\n ctx.response\n .status(error.status)\n .type('html')\n .send(\n error.messages\n .map((message: any) => {\n return `${message.field} - ${message.message}`\n })\n .join('<br />')\n )\n }\n\n /**\n * Renders the error to response\n */\n renderError(error: HttpError, ctx: HttpContext) {\n switch (ctx.request.accepts(['html', 'application/vnd.api+json', 'json'])) {\n case 'application/vnd.api+json':\n return this.renderErrorAsJSONAPI(error, ctx)\n case 'json':\n return this.renderErrorAsJSON(error, ctx)\n case 'html':\n default:\n return this.renderErrorAsHTML(error, ctx)\n }\n }\n\n /**\n * Renders the validation error to response\n */\n renderValidationError(error: HttpError, ctx: HttpContext) {\n switch (ctx.request.accepts(['html', 'application/vnd.api+json', 'json'])) {\n case 'application/vnd.api+json':\n return this.renderValidationErrorAsJSONAPI(error, ctx)\n case 'json':\n return this.renderValidationErrorAsJSON(error, ctx)\n case 'html':\n default:\n return this.renderValidationErrorAsHTML(error, ctx)\n }\n }\n\n /**\n * Reports an error during an HTTP request\n */\n async report(error: unknown, ctx: HttpContext) {\n const httpError = this.#toHttpError(error)\n if (!this.shouldReport(httpError)) {\n return\n }\n\n if (typeof httpError.report === 'function') {\n httpError.report(httpError, ctx)\n return\n }\n\n /**\n * Log the error using the logger\n */\n const level = this.getErrorLogLevel(httpError)\n ctx.logger.log(\n level,\n {\n ...(level === 'error' || level === 'fatal' ? { err: httpError } : {}),\n ...this.context(ctx),\n },\n httpError.message\n )\n }\n\n /**\n * Handles the error during the HTTP request.\n */\n async handle(error: unknown, ctx: HttpContext) {\n const httpError = this.#toHttpError(error)\n\n /**\n * Self handle exception\n */\n if (typeof httpError.handle === 'function') {\n return httpError.handle(httpError, ctx)\n }\n\n /**\n * Handle validation error using the validation error\n * renderers\n */\n if (httpError.code === 'E_VALIDATION_ERROR' && 'messages' in httpError) {\n return this.renderValidationError(httpError, ctx)\n }\n\n /**\n * Render status page\n */\n const statusPages = this.#expandStatusPages()\n if (this.renderStatusPages && statusPages[httpError.status]) {\n const statusPageResponse = await statusPages[httpError.status](httpError, ctx)\n\n /**\n * Use return value and convert it into a response\n */\n if (\n statusPageResponse !== undefined && // Return value is explicitly defined\n !ctx.response.hasLazyBody && // Lazy body is not set\n statusPageResponse !== ctx.response // Return value is not the instance of response object\n ) {\n return ctx.response.safeStatus(httpError.status).send(statusPageResponse)\n }\n return statusPageResponse\n }\n\n /**\n * Use the format renderers.\n */\n return this.renderError(httpError, ctx)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AASA,OAAO,QAAQ;AACf,OAAO,eAAe;AAoBf,IAAM,mBAAN,cAA+B,UAAU;AAAA;AAAA;AAAA;AAAA,EAI9C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMU,QAAiB,QAAQ,IAAI,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO1C,oBAA6B,QAAQ,IAAI,aAAa;AAAA;AAAA;AAAA;AAAA,EAKtD,cAA2D,CAAC;AAAA;AAAA;AAAA;AAAA,EAK5D,eAAwB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMxB,mBAA0B;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMU,iBAA2B,CAAC,KAAK,KAAK,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA,EAMzC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AACtE,aAAO,KAAK,sBAAsB,WAAW,GAAG;AAAA,IAClD;AAKA,UAAM,cAAc,KAAK,mBAAmB;AAC5C,QAAI,KAAK,qBAAqB,YAAY,UAAU,MAAM,GAAG;AAC3D,YAAM,qBAAqB,MAAM,YAAY,UAAU,MAAM,EAAE,WAAW,GAAG;AAK7E,UACE,uBAAuB;AAAA,MACvB,CAAC,IAAI,SAAS;AAAA,MACd,uBAAuB,IAAI,UAC3B;AACA,eAAO,IAAI,SAAS,WAAW,UAAU,MAAM,EAAE,KAAK,kBAAkB;AAAA,MAC1E;AACA,aAAO;AAAA,IACT;AAKA,WAAO,KAAK,YAAY,WAAW,GAAG;AAAA,EACxC;AACF;","names":[]}
|
package/build/src/response.d.ts
CHANGED
|
@@ -103,6 +103,14 @@ export declare class Response extends Macroable {
|
|
|
103
103
|
* Downloads a file by streaming it to the response
|
|
104
104
|
*/
|
|
105
105
|
protected streamFileForDownload(filePath: string, generateEtag: boolean, errorCallback?: (error: NodeJS.ErrnoException) => [string, number?]): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Listen for the event the response is written
|
|
108
|
+
* to the TCP socket.
|
|
109
|
+
*
|
|
110
|
+
* Under the hood the callback is registered with
|
|
111
|
+
* the "https://github.com/jshttp/on-finished" package
|
|
112
|
+
*/
|
|
113
|
+
onFinish(callback: (err: Error | null, response: ServerResponse) => void): void;
|
|
106
114
|
/**
|
|
107
115
|
* Writes headers with the Node.js res object using the
|
|
108
116
|
* response.setHeader method
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export declare const ResponseStatus: {
|
|
2
|
+
readonly Continue: 100;
|
|
3
|
+
readonly SwitchingProtocols: 101;
|
|
4
|
+
readonly Processing: 102;
|
|
5
|
+
readonly EarlyHints: 103;
|
|
6
|
+
readonly Ok: 200;
|
|
7
|
+
readonly Created: 201;
|
|
8
|
+
readonly Accepted: 202;
|
|
9
|
+
readonly NonAuthoritativeInformation: 203;
|
|
10
|
+
readonly NoContent: 204;
|
|
11
|
+
readonly ResetContent: 205;
|
|
12
|
+
readonly PartialContent: 206;
|
|
13
|
+
readonly MultiStatus: 207;
|
|
14
|
+
readonly AlreadyReported: 208;
|
|
15
|
+
readonly IMUsed: 226;
|
|
16
|
+
readonly MultipleChoices: 300;
|
|
17
|
+
readonly MovedPermanently: 301;
|
|
18
|
+
readonly Found: 302;
|
|
19
|
+
readonly SeeOther: 303;
|
|
20
|
+
readonly NotModified: 304;
|
|
21
|
+
readonly UseProxy: 305;
|
|
22
|
+
readonly TemporaryRedirect: 307;
|
|
23
|
+
readonly PermanentRedirect: 308;
|
|
24
|
+
readonly BadRequest: 400;
|
|
25
|
+
readonly Unauthorized: 401;
|
|
26
|
+
readonly PaymentRequired: 402;
|
|
27
|
+
readonly Forbidden: 403;
|
|
28
|
+
readonly NotFound: 404;
|
|
29
|
+
readonly MethodNotAllowed: 405;
|
|
30
|
+
readonly NotAcceptable: 406;
|
|
31
|
+
readonly ProxyAuthenticationRequired: 407;
|
|
32
|
+
readonly RequestTimeout: 408;
|
|
33
|
+
readonly Conflict: 409;
|
|
34
|
+
readonly Gone: 410;
|
|
35
|
+
readonly LengthRequired: 411;
|
|
36
|
+
readonly PreconditionFailed: 412;
|
|
37
|
+
readonly PayloadTooLarge: 413;
|
|
38
|
+
readonly URITooLong: 414;
|
|
39
|
+
readonly UnsupportedMediaType: 415;
|
|
40
|
+
readonly RangeNotSatisfiable: 416;
|
|
41
|
+
readonly ExpectationFailed: 417;
|
|
42
|
+
readonly ImATeapot: 418;
|
|
43
|
+
readonly MisdirectedRequest: 421;
|
|
44
|
+
readonly UnprocessableEntity: 422;
|
|
45
|
+
readonly Locked: 423;
|
|
46
|
+
readonly FailedDependency: 424;
|
|
47
|
+
readonly TooEarly: 425;
|
|
48
|
+
readonly UpgradeRequired: 426;
|
|
49
|
+
readonly PreconditionRequired: 428;
|
|
50
|
+
readonly TooManyRequests: 429;
|
|
51
|
+
readonly RequestHeaderFieldsTooLarge: 431;
|
|
52
|
+
readonly UnavailableForLegalReasons: 451;
|
|
53
|
+
readonly InternalServerError: 500;
|
|
54
|
+
readonly NotImplemented: 501;
|
|
55
|
+
readonly BadGateway: 502;
|
|
56
|
+
readonly ServiceUnavailable: 503;
|
|
57
|
+
readonly GatewayTimeout: 504;
|
|
58
|
+
readonly HTTPVersionNotSupported: 505;
|
|
59
|
+
readonly VariantAlsoNegotiates: 506;
|
|
60
|
+
readonly InsufficientStorage: 507;
|
|
61
|
+
readonly LoopDetected: 508;
|
|
62
|
+
readonly NotExtended: 510;
|
|
63
|
+
readonly NetworkAuthenticationRequired: 511;
|
|
64
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/http-server",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "AdonisJS HTTP server with support packed with Routing and Cookies",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@types/supertest": "^6.0.2",
|
|
76
76
|
"@types/type-is": "^1.6.6",
|
|
77
77
|
"@types/vary": "^1.1.3",
|
|
78
|
-
"@vinejs/vine": "^
|
|
78
|
+
"@vinejs/vine": "^2.0.0",
|
|
79
79
|
"autocannon": "^7.14.0",
|
|
80
80
|
"c8": "^9.1.0",
|
|
81
81
|
"cross-env": "^7.0.3",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"github-label-sync": "^2.3.1",
|
|
88
88
|
"http-status-codes": "^2.3.0",
|
|
89
89
|
"husky": "^9.0.10",
|
|
90
|
-
"np": "^
|
|
90
|
+
"np": "^10.0.2",
|
|
91
91
|
"pem": "^1.14.8",
|
|
92
92
|
"prettier": "^3.2.4",
|
|
93
93
|
"reflect-metadata": "^0.2.1",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"content-disposition": "^0.5.4",
|
|
108
108
|
"cookie": "^0.6.0",
|
|
109
109
|
"destroy": "^1.2.0",
|
|
110
|
-
"encodeurl": "^
|
|
110
|
+
"encodeurl": "^2.0.0",
|
|
111
111
|
"etag": "^1.8.1",
|
|
112
112
|
"fresh": "^0.5.2",
|
|
113
113
|
"mime-types": "^2.1.35",
|