@adonisjs/http-server 7.7.0 → 7.8.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/router/route.ts","../src/router/factories/use_return_value.ts","../src/router/executor.ts","../src/helpers.ts","../src/router/brisk.ts","../src/router/group.ts","../src/router/resource.ts","../src/debug.ts","../src/cookies/drivers/plain.ts","../src/cookies/drivers/signed.ts","../src/cookies/drivers/encrypted.ts","../src/cookies/client.ts","../src/request.ts","../src/cookies/parser.ts","../src/redirect.ts","../src/exceptions.ts","../src/response_status.ts","../src/response.ts","../src/cookies/serializer.ts","../src/router/main.ts","../src/router/store.ts","../src/router/parser.ts","../src/router/lookup_store/main.ts","../src/router/lookup_store/url_builder.ts","../src/router/lookup_store/route_finder.ts","../src/router/matchers.ts","../src/define_middleware.ts","../src/http_context/main.ts","../src/http_context/local_storage.ts","../src/server/main.ts","../src/qs.ts","../src/server/factories/final_handler.ts","../src/server/factories/write_response.ts","../src/server/factories/middleware_handler.ts","../src/define_config.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 Middleware from '@poppinss/middleware'\nimport { RuntimeException } from '@poppinss/utils'\nimport type { Application } from '@adonisjs/application'\nimport { moduleCaller, moduleImporter } from '@adonisjs/fold'\n\nimport { execute } from './executor.js'\nimport { dropSlash } from '../helpers.js'\nimport type { Constructor, LazyImport, OneOrMore } from '../types/base.js'\n\nimport type {\n MiddlewareFn,\n ParsedNamedMiddleware,\n ParsedGlobalMiddleware,\n} from '../types/middleware.js'\n\nimport type {\n GetControllerHandlers,\n RouteFn,\n RouteJSON,\n RouteMatcher,\n RouteMatchers,\n StoreRouteHandler,\n StoreRouteMiddleware,\n} from '../types/route.js'\nimport debug from '../debug.js'\n\n/**\n * The route class exposes the APIs for constructing a route using the\n * fluent API.\n */\nexport class Route<Controller extends Constructor<any> = any> extends Macroable {\n /**\n * Route pattern\n */\n #pattern: string\n\n /**\n * HTTP Methods for the route\n */\n #methods: string[]\n\n /**\n * A unique name for the route\n */\n #name?: string\n\n /**\n * A boolean to prevent route from getting registered within\n * the store.\n *\n * This flag must be set before \"Router.commit\" method\n */\n #isDeleted: boolean = false\n\n /**\n * Route handler\n */\n #handler: StoreRouteHandler\n\n /**\n * Matchers inherited from the router\n */\n #globalMatchers: RouteMatchers\n\n /**\n * Reference to the AdonisJS application\n */\n #app: Application<any>\n\n /**\n * Middleware registered on the router\n */\n #routerMiddleware: ParsedGlobalMiddleware[]\n\n /**\n * By default the route is part of the `root` domain. Root domain is used\n * when no domain is defined\n */\n #routeDomain: string = 'root'\n\n /**\n * An object of matchers to be forwarded to the store. The matchers\n * list is populated by calling `where` method\n */\n #matchers: RouteMatchers = {}\n\n /**\n * Custom prefixes defined on the route or the route parent\n * groups\n */\n #prefixes: string[] = []\n\n /**\n * Middleware defined directly on the route or the route parent\n * routes. We mantain an array for each layer of the stack\n */\n #middleware: StoreRouteMiddleware[][] = []\n\n constructor(\n app: Application<any>,\n routerMiddleware: ParsedGlobalMiddleware[],\n options: {\n pattern: string\n methods: string[]\n handler:\n | RouteFn\n | string\n | [LazyImport<Controller> | Controller, GetControllerHandlers<Controller>?]\n globalMatchers: RouteMatchers\n }\n ) {\n super()\n this.#app = app\n this.#routerMiddleware = routerMiddleware\n this.#pattern = options.pattern\n this.#methods = options.methods\n this.#handler = this.#resolveRouteHandle(options.handler)\n this.#globalMatchers = options.globalMatchers\n }\n\n /**\n * Resolves the route handler string expression to a\n * handler method object\n */\n #resolveRouteHandle(\n handler:\n | RouteFn\n | string\n | [LazyImport<Controller> | Controller, GetControllerHandlers<Controller>?]\n ) {\n /**\n * Convert magic string to handle method call\n */\n if (typeof handler === 'string') {\n const parts = handler.split('.')\n const method = parts.length === 1 ? 'handle' : parts.pop()!\n const moduleRefId = parts.join('.')\n\n return {\n reference: handler,\n ...moduleImporter(() => this.#app.import(moduleRefId), method).toHandleMethod(),\n name: handler,\n }\n }\n\n /**\n * Using a lazily imported controller\n */\n if (Array.isArray(handler)) {\n /**\n * The first item of the tuple is a class constructor\n */\n if (is.class(handler[0])) {\n return {\n reference: handler,\n ...moduleCaller(handler[0], (handler[1] || 'handle') as string).toHandleMethod(),\n }\n }\n\n /**\n * The first item of the tuple is a function that lazily\n * loads the controller\n */\n return {\n reference: handler,\n ...moduleImporter(handler[0], (handler[1] || 'handle') as string).toHandleMethod(),\n }\n }\n\n return handler\n }\n\n /**\n * Returns an object of param matchers by merging global and local\n * matchers. The local copy is given preference over the global\n * one's\n */\n #getMatchers() {\n return { ...this.#globalMatchers, ...this.#matchers }\n }\n\n /**\n * Returns a normalized pattern string by prefixing the `prefix` (if defined).\n */\n #computePattern(): string {\n const pattern = dropSlash(this.#pattern)\n const prefix = this.#prefixes\n .slice()\n .reverse()\n .map((one) => dropSlash(one))\n .join('')\n\n return prefix ? `${prefix}${pattern === '/' ? '' : pattern}` : pattern\n }\n\n /**\n * Define matcher for a given param. If a matcher exists, then we do not\n * override that, since the routes inside a group will set matchers\n * before the group, so they should have priority over the group\n * matchers.\n *\n * ```ts\n * Route.group(() => {\n * Route.get('/:id', 'handler').where('id', /^[0-9]$/)\n * }).where('id', /[^a-z$]/)\n * ```\n *\n * The `/^[0-9]$/` will win over the matcher defined by the group\n */\n where(param: string, matcher: RouteMatcher | string | RegExp): this {\n if (this.#matchers[param]) {\n return this\n }\n\n if (typeof matcher === 'string') {\n this.#matchers[param] = { match: new RegExp(matcher) }\n } else if (is.regExp(matcher)) {\n this.#matchers[param] = { match: matcher }\n } else {\n this.#matchers[param] = matcher\n }\n\n return this\n }\n\n /**\n * Define prefix for the route. Calling this method multiple times\n * applies multiple prefixes in the reverse order.\n */\n prefix(prefix: string): this {\n this.#prefixes.push(prefix)\n return this\n }\n\n /**\n * Define a custom domain for the route. We do not overwrite the domain\n * unless `overwrite` flag is set to true.\n */\n domain(domain: string, overwrite: boolean = false): this {\n if (this.#routeDomain === 'root' || overwrite) {\n this.#routeDomain = domain\n }\n return this\n }\n\n /**\n * Define one or more middleware to be executed before the route\n * handler.\n *\n * Named middleware can be referenced using the name registered with\n * the router middleware store.\n */\n use(middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this {\n this.#middleware.push(Array.isArray(middleware) ? middleware : [middleware])\n return this\n }\n\n /**\n * @alias use\n */\n middleware(middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this {\n return this.use(middleware)\n }\n\n /**\n * Give a unique name to the route. Assinging a new unique removes the\n * existing name of the route.\n *\n * Setting prepends to true prefixes the name to the existing name.\n */\n as(name: string, prepend = false): this {\n if (prepend) {\n if (!this.#name) {\n throw new RuntimeException(\n `Routes inside a group must have names before calling \"router.group.as\"`\n )\n }\n\n this.#name = `${name}.${this.#name}`\n return this\n }\n\n this.#name = name\n return this\n }\n\n /**\n * Check if the route was marked to be deleted\n */\n isDeleted(): boolean {\n return this.#isDeleted\n }\n\n /**\n * Mark route as deleted. Deleted routes are not registered\n * with the route store\n */\n markAsDeleted() {\n this.#isDeleted = true\n }\n\n /**\n * Get the route name\n */\n getName(): string | undefined {\n return this.#name\n }\n\n /**\n * Get the route pattern\n */\n getPattern(): string {\n return this.#pattern\n }\n\n /**\n * Set the route pattern\n */\n setPattern(pattern: string): this {\n this.#pattern = pattern\n return this\n }\n\n /**\n * Returns the stack of middleware registered on the route.\n * The value is shared by reference.\n */\n getMiddleware() {\n return this.#middleware\n }\n\n /**\n * Returns the middleware instance for persistence inside the\n * store\n */\n #getMiddlewareForStore() {\n const middleware = new Middleware<StoreRouteMiddleware>()\n\n this.#routerMiddleware.forEach((one) => {\n debug('adding global middleware to route %s, %O', this.#pattern, one)\n middleware.add(one)\n })\n this.#middleware.flat().forEach((one) => {\n debug('adding named middleware to route %s, %O', this.#pattern, one)\n middleware.add(one)\n })\n\n return middleware\n }\n\n /**\n * Returns JSON representation of the route\n */\n toJSON(): RouteJSON {\n return {\n domain: this.#routeDomain,\n pattern: this.#computePattern(),\n matchers: this.#getMatchers(),\n meta: {},\n name: this.#name,\n handler: this.#handler,\n methods: this.#methods,\n middleware: this.#getMiddlewareForStore(),\n execute: execute,\n }\n }\n}\n","/*\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 type { HttpContext } from '../../http_context/main.js'\n\n/**\n * A factory function that uses the return value of the request\n * pipeline as the response\n */\nexport function useReturnValue(ctx: HttpContext) {\n return function (value: any) {\n if (\n value !== undefined && // Return value is explicitly defined\n !ctx.response.hasLazyBody && // Lazy body is not set\n value !== ctx.response // Return value is not the instance of response object\n ) {\n ctx.response.send(value)\n }\n }\n}\n","/*\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 type { ContainerResolver } from '@adonisjs/fold'\nimport type { StoreRouteNode } from '../types/route.js'\nimport type { HttpContext } from '../http_context/main.js'\nimport type { ServerErrorHandler } from '../types/server.js'\nimport { useReturnValue } from './factories/use_return_value.js'\n\n/**\n * Executor to execute the route middleware pipeline the route\n * handler\n */\nexport function execute(\n route: StoreRouteNode,\n resolver: ContainerResolver<any>,\n ctx: HttpContext,\n errorResponder: ServerErrorHandler['handle']\n) {\n return route.middleware\n .runner()\n .errorHandler((error) => errorResponder(error, ctx))\n .finalHandler(async () => {\n if (typeof route.handler === 'function') {\n return Promise.resolve(route.handler(ctx)).then(useReturnValue(ctx))\n }\n\n return route.handler.handle(resolver, ctx).then(useReturnValue(ctx))\n })\n .run(async (middleware, next) => {\n if (typeof middleware === 'function') {\n return middleware(ctx, next)\n }\n\n return middleware.handle(resolver, ctx, next, middleware.args)\n })\n}\n","/*\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 Cache from 'tmp-cache'\nimport { InvalidArgumentsException } from '@poppinss/utils'\n\nimport { Route } from './router/route.js'\nimport { BriskRoute } from './router/brisk.js'\nimport { RouteGroup } from './router/group.js'\nimport type { RouteJSON } from './types/route.js'\nimport { RouteResource } from './router/resource.js'\n\nconst proxyCache = new Cache({ max: 200 })\n\n/**\n * Makes input string consistent by having only the starting\n * slash\n */\nexport function dropSlash(input: string): string {\n if (input === '/') {\n return '/'\n }\n\n return `/${input.replace(/^\\//, '').replace(/\\/$/, '')}`\n}\n\n/**\n * Returns a flat list of routes from the route groups and resources\n */\nexport function toRoutesJSON(\n routes: (RouteGroup | Route | RouteResource | BriskRoute)[]\n): RouteJSON[] {\n return routes.reduce((list: RouteJSON[], route) => {\n if (route instanceof RouteGroup) {\n list = list.concat(toRoutesJSON(route.routes))\n return list\n }\n\n if (route instanceof RouteResource) {\n list = list.concat(toRoutesJSON(route.routes))\n return list\n }\n\n if (route instanceof BriskRoute) {\n if (route.route && !route.route.isDeleted()) {\n list.push(route.route.toJSON())\n }\n return list\n }\n\n if (!route.isDeleted()) {\n list.push(route.toJSON())\n }\n\n return list\n }, [])\n}\n\n/**\n * Helper to know if the remote address should\n * be trusted.\n */\nexport function trustProxy(\n remoteAddress: string,\n proxyFn: (addr: string, distance: number) => boolean\n): boolean {\n if (proxyCache.has(remoteAddress)) {\n return proxyCache.get(remoteAddress) as boolean\n }\n\n const result = proxyFn(remoteAddress, 0)\n proxyCache.set(remoteAddress, result)\n return result\n}\n\n/**\n * Parses a range expression to an object filled with the range\n */\nexport function parseRange<T>(range: string, value: T): Record<number, T> {\n const parts = range.split('..')\n const min = Number(parts[0])\n const max = Number(parts[1])\n\n /**\n * The ending status code does not exists\n */\n if (parts.length === 1 && !Number.isNaN(min)) {\n return {\n [min]: value,\n }\n }\n\n /**\n * The starting status code is not a number\n */\n if (Number.isNaN(min) || Number.isNaN(max)) {\n return {}\n }\n\n /**\n * Min and max are same\n */\n if (min === max) {\n return {\n [min]: value,\n }\n }\n\n /**\n * Max cannot be smaller than min\n */\n if (max < min) {\n throw new InvalidArgumentsException(`Invalid range \"${range}\"`)\n }\n\n /**\n * Loop over the range and create a collection\n * of status codes\n */\n return [...Array(max - min + 1).keys()].reduce(\n (result, step) => {\n result[min + step] = value\n return result\n },\n {} as Record<number, T>\n )\n}\n","/*\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 Macroable from '@poppinss/macroable'\nimport type { Application } from '@adonisjs/application'\n\nimport { Route } from './route.js'\nimport type { HttpContext } from '../http_context/main.js'\nimport type { ParsedGlobalMiddleware } from '../types/middleware.js'\nimport type { MakeUrlOptions, RouteFn, RouteMatchers } from '../types/route.js'\n\n/**\n * Brisk routes exposes the API to configure the route handler by chaining\n * one of the pre-defined methods.\n *\n * For example: Instead of defining the redirect logic as a callback, one can\n * chain the `.redirect` method.\n *\n * Brisk routes are always registered under the `GET` HTTP method.\n */\nexport class BriskRoute extends Macroable {\n /**\n * Route pattern\n */\n #pattern: string\n\n /**\n * Matchers inherited from the router\n */\n #globalMatchers: RouteMatchers\n\n /**\n * Reference to the AdonisJS application\n */\n #app: Application<any>\n\n /**\n * Middleware registered on the router\n */\n #routerMiddleware: ParsedGlobalMiddleware[]\n\n /**\n * Reference to route instance. Set after `setHandler` is called\n */\n route: null | Route = null\n\n constructor(\n app: Application<any>,\n routerMiddleware: ParsedGlobalMiddleware[],\n options: {\n pattern: string\n globalMatchers: RouteMatchers\n }\n ) {\n super()\n this.#app = app\n this.#routerMiddleware = routerMiddleware\n this.#pattern = options.pattern\n this.#globalMatchers = options.globalMatchers\n }\n\n /**\n * Set handler for the brisk route\n */\n setHandler(handler: RouteFn): Route {\n this.route = new Route(this.#app, this.#routerMiddleware, {\n pattern: this.#pattern,\n globalMatchers: this.#globalMatchers,\n methods: ['GET', 'HEAD'],\n handler: handler,\n })\n\n return this.route\n }\n\n /**\n * Redirects to a given route. Params from the original request will\n * be used when no custom params are defined.\n */\n redirect(\n identifier: string,\n params?: any[] | Record<string, any>,\n options?: MakeUrlOptions & { status: number }\n ): Route {\n function redirectsToRoute(ctx: HttpContext) {\n const redirector = ctx.response.redirect()\n if (options?.status) {\n redirector.status(options.status)\n }\n\n return redirector.toRoute(identifier, params || ctx.params, options)\n }\n Object.defineProperty(redirectsToRoute, 'listArgs', { value: identifier, writable: false })\n\n return this.setHandler(redirectsToRoute)\n }\n\n /**\n * Redirect request to a fixed URL\n */\n redirectToPath(url: string, options?: { status: number }): Route {\n function redirectsToPath(ctx: HttpContext) {\n const redirector = ctx.response.redirect()\n if (options?.status) {\n redirector.status(options.status)\n }\n\n return redirector.toPath(url)\n }\n Object.defineProperty(redirectsToPath, 'listArgs', { value: url, writable: false })\n\n return this.setHandler(redirectsToPath)\n }\n}\n","/*\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 Macroable from '@poppinss/macroable'\nimport type { RouteMatcher, StoreRouteMiddleware } from '../types/route.js'\nimport type { MiddlewareFn, ParsedNamedMiddleware } from '../types/middleware.js'\n\nimport { Route } from './route.js'\nimport { BriskRoute } from './brisk.js'\nimport { RouteResource } from './resource.js'\nimport { OneOrMore } from '../types/base.js'\n\n/**\n * Group class exposes the API to take action on a group of routes.\n * The group routes must be pre-defined using the constructor.\n */\nexport class RouteGroup extends Macroable {\n /**\n * Array of middleware registered on the group.\n */\n #middleware: StoreRouteMiddleware[] = []\n\n constructor(public routes: (Route | RouteGroup | RouteResource | BriskRoute)[]) {\n super()\n }\n\n /**\n * Shares midldeware stack with the routes. The method is invoked recursively\n * to only register middleware with the route class and not with the\n * resource or the child group\n */\n #shareMiddlewareStackWithRoutes(route: RouteGroup | Route | RouteResource | BriskRoute) {\n if (route instanceof RouteGroup) {\n route.routes.forEach((child) => this.#shareMiddlewareStackWithRoutes(child))\n return\n }\n\n if (route instanceof RouteResource) {\n route.routes.forEach((child) => child.getMiddleware().unshift(this.#middleware))\n return\n }\n\n if (route instanceof BriskRoute) {\n route.route!.getMiddleware().unshift(this.#middleware)\n return\n }\n\n route.getMiddleware().unshift(this.#middleware)\n }\n\n /**\n * Updates the route name. The method is invoked recursively to only update\n * the name with the route class and not with the resource or the child\n * group.\n */\n #updateRouteName(route: RouteGroup | Route | RouteResource | BriskRoute, name: string) {\n if (route instanceof RouteGroup) {\n route.routes.forEach((child) => this.#updateRouteName(child, name))\n return\n }\n\n if (route instanceof RouteResource) {\n route.routes.forEach((child) => child.as(name, true))\n return\n }\n\n if (route instanceof BriskRoute) {\n route.route!.as(name, true)\n return\n }\n\n route.as(name, true)\n }\n\n /**\n * Sets prefix on the route. The method is invoked recursively to only set\n * the prefix with the route class and not with the resource or the\n * child group.\n */\n #setRoutePrefix(route: RouteGroup | Route | RouteResource | BriskRoute, prefix: string) {\n if (route instanceof RouteGroup) {\n route.routes.forEach((child) => this.#setRoutePrefix(child, prefix))\n return\n }\n\n if (route instanceof RouteResource) {\n route.routes.forEach((child) => child.prefix(prefix))\n return\n }\n\n if (route instanceof BriskRoute) {\n route.route!.prefix(prefix)\n return\n }\n\n route.prefix(prefix)\n }\n\n /**\n * Updates domain on the route. The method is invoked recursively to only update\n * the domain with the route class and not with the resource or the child\n * group.\n */\n #updateRouteDomain(route: RouteGroup | Route | RouteResource | BriskRoute, domain: string) {\n if (route instanceof RouteGroup) {\n route.routes.forEach((child) => this.#updateRouteDomain(child, domain))\n return\n }\n\n if (route instanceof RouteResource) {\n route.routes.forEach((child) => child.domain(domain))\n return\n }\n\n if (route instanceof BriskRoute) {\n route.route!.domain(domain, false)\n return\n }\n\n route.domain(domain, false)\n }\n\n /**\n * Updates matchers on the route. The method is invoked recursively to only update\n * the matchers with the route class and not with the resource or the child\n * group.\n */\n #updateRouteMatchers(\n route: RouteGroup | Route | RouteResource | BriskRoute,\n param: string,\n matcher: RouteMatcher | string | RegExp\n ) {\n if (route instanceof RouteGroup) {\n route.routes.forEach((child) => this.#updateRouteMatchers(child, param, matcher))\n return\n }\n\n if (route instanceof RouteResource) {\n route.routes.forEach((child) => child.where(param, matcher))\n return\n }\n\n if (route instanceof BriskRoute) {\n route.route!.where(param, matcher)\n return\n }\n\n route.where(param, matcher)\n }\n\n /**\n * Define route param matcher\n *\n * ```ts\n * Route.group(() => {\n * }).where('id', /^[0-9]+/)\n * ```\n */\n where(param: string, matcher: RouteMatcher | string | RegExp): this {\n this.routes.forEach((route) => this.#updateRouteMatchers(route, param, matcher))\n return this\n }\n\n /**\n * Define prefix all the routes in the group.\n *\n * ```ts\n * Route.group(() => {\n * }).prefix('v1')\n * ```\n */\n prefix(prefix: string): this {\n this.routes.forEach((route) => this.#setRoutePrefix(route, prefix))\n return this\n }\n\n /**\n * Define domain for all the routes.\n *\n * ```ts\n * Route.group(() => {\n * }).domain(':name.adonisjs.com')\n * ```\n */\n domain(domain: string): this {\n this.routes.forEach((route) => this.#updateRouteDomain(route, domain))\n return this\n }\n\n /**\n * Prepend name to the routes name.\n *\n * ```ts\n * Route.group(() => {\n * }).as('version1')\n * ```\n */\n as(name: string): this {\n this.routes.forEach((route) => this.#updateRouteName(route, name))\n return this\n }\n /**\n * Prepend an array of middleware to all routes middleware.\n *\n * ```ts\n * Route.group(() => {\n * }).use(middleware.auth())\n * ```\n */\n use(middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this {\n /**\n * Register middleware with children. We share the group middleware\n * array by reference, therefore have to register it only for the\n * first time.\n */\n if (!this.#middleware.length) {\n this.routes.forEach((route) => this.#shareMiddlewareStackWithRoutes(route))\n }\n\n if (Array.isArray(middleware)) {\n for (let one of middleware) {\n this.#middleware.push(one)\n }\n } else {\n this.#middleware.push(middleware)\n }\n\n return this\n }\n\n /**\n * @alias use\n */\n middleware(middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this {\n return this.use(middleware)\n }\n}\n","/*\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 string from '@poppinss/utils/string'\nimport Macroable from '@poppinss/macroable'\nimport { RuntimeException } from '@poppinss/utils'\nimport type { Application } from '@adonisjs/application'\n\nimport { Route } from './route.js'\nimport type { Constructor, LazyImport, OneOrMore } from '../types/base.js'\nimport type {\n MiddlewareFn,\n ParsedGlobalMiddleware,\n ParsedNamedMiddleware,\n} from '../types/middleware.js'\nimport type { ResourceActionNames, RouteMatcher, RouteMatchers } from '../types/route.js'\n\n/**\n * Route resource exposes the API to register multiple routes for a resource.\n */\nexport class RouteResource<\n ActionNames extends ResourceActionNames = ResourceActionNames,\n> extends Macroable {\n /**\n * Resource identifier. Nested resources are separated\n * with a dot notation\n */\n #resource: string\n\n /**\n * The controller to handle resource routing requests\n */\n #controller: string | LazyImport<Constructor<any>> | Constructor<any>\n\n /**\n * Is it a shallow resource? Shallow resources URLs do not have parent\n * resource name and id once they can be identified with the id.\n */\n #shallow: boolean = false\n\n /**\n * Matchers inherited from the router\n */\n #globalMatchers: RouteMatchers\n\n /**\n * Reference to the AdonisJS application\n */\n #app: Application<any>\n\n /**\n * Middleware registered on the router\n */\n #routerMiddleware: ParsedGlobalMiddleware[]\n\n /**\n * Parameter names for the resources. Defaults to `id` for\n * a singular resource and `resource_id` for nested\n * resources.\n */\n #params: Record<string, string> = {}\n\n /**\n * Base name for the routes. We suffix action names\n * on top of the base name\n */\n #routesBaseName: string\n\n /**\n * A collection of routes instances that belongs to this resource\n */\n routes: Route[] = []\n\n constructor(\n app: Application<any>,\n routerMiddleware: ParsedGlobalMiddleware[],\n options: {\n resource: string\n controller: string | LazyImport<Constructor<any>> | Constructor<any>\n globalMatchers: RouteMatchers\n shallow: boolean\n }\n ) {\n super()\n this.#validateResourceName(options.resource)\n\n this.#app = app\n this.#shallow = options.shallow\n this.#routerMiddleware = routerMiddleware\n this.#controller = options.controller\n this.#globalMatchers = options.globalMatchers\n this.#resource = this.#normalizeResourceName(options.resource)\n this.#routesBaseName = this.#getRoutesBaseName()\n this.#buildRoutes()\n }\n\n /**\n * Normalizes the resource name to dropping leading and trailing\n * slashes.\n */\n #normalizeResourceName(resource: string) {\n return resource.replace(/^\\//, '').replace(/\\/$/, '')\n }\n\n /**\n * Ensure resource name is not an empty string\n */\n #validateResourceName(resource: string) {\n if (!resource || resource === '/') {\n throw new RuntimeException(`Invalid resource name \"${resource}\"`)\n }\n }\n\n /**\n * Converting segments of a resource to snake case to\n * make the route name.\n */\n #getRoutesBaseName() {\n return this.#resource\n .split('.')\n .map((token) => string.snakeCase(token))\n .join('.')\n }\n\n /**\n * Create a new route for the given pattern, methods and controller action\n */\n #createRoute(pattern: string, methods: string[], action: ResourceActionNames) {\n const route = new Route(this.#app, this.#routerMiddleware, {\n pattern,\n methods,\n handler:\n typeof this.#controller === 'string'\n ? `${this.#controller}.${action}`\n : [this.#controller, action],\n globalMatchers: this.#globalMatchers,\n })\n\n route.as(`${this.#routesBaseName}.${action}`)\n this.routes.push(route)\n }\n\n /**\n * Returns the `resource_id` name for a given resource. The\n * resource name is converted to singular form and\n * transformed to snake case.\n *\n * photos becomes photo_id\n * users becomes user_id\n */\n #getResourceId(resource: string) {\n return `${string.snakeCase(string.singular(resource))}_id`\n }\n\n /**\n * Build routes for the given resource\n */\n #buildRoutes() {\n const resources = this.#resource.split('.')\n\n const mainResource = resources.pop()!\n this.#params[mainResource] = ':id'\n\n const baseURI = `${resources\n .map((resource) => {\n const paramName = `:${this.#getResourceId(resource)}`\n this.#params[resource] = paramName\n\n return `${resource}/${paramName}`\n })\n .join('/')}/${mainResource}`\n\n this.#createRoute(baseURI, ['GET', 'HEAD'], 'index')\n this.#createRoute(`${baseURI}/create`, ['GET', 'HEAD'], 'create')\n this.#createRoute(baseURI, ['POST'], 'store')\n this.#createRoute(`${this.#shallow ? mainResource : baseURI}/:id`, ['GET', 'HEAD'], 'show')\n this.#createRoute(`${this.#shallow ? mainResource : baseURI}/:id/edit`, ['GET', 'HEAD'], 'edit')\n this.#createRoute(`${this.#shallow ? mainResource : baseURI}/:id`, ['PUT', 'PATCH'], 'update')\n this.#createRoute(`${this.#shallow ? mainResource : baseURI}/:id`, ['DELETE'], 'destroy')\n }\n\n /**\n * Filter the routes based on their partial names\n */\n #filter(names: ActionNames | ActionNames[], inverse: boolean) {\n const actions = Array.isArray(names) ? names : [names]\n return this.routes.filter((route) => {\n const match = actions.find((name) => route.getName()!.endsWith(name))\n return inverse ? !match : match\n })\n }\n\n /**\n * Register only given routes and remove others\n */\n only<Name extends ActionNames>(names: Name[]): RouteResource<Name> {\n this.#filter(names, true).forEach((route) => route.markAsDeleted())\n return this\n }\n\n /**\n * Register all routes, except the one's defined\n */\n except<Name extends ActionNames>(names: Name[]): RouteResource<Exclude<ActionNames, Name>> {\n this.#filter(names, false).forEach((route) => route.markAsDeleted())\n return this\n }\n\n /**\n * Register api only routes. The `create` and `edit` routes, which\n * are meant to show forms will not be registered\n */\n apiOnly(): RouteResource<Exclude<ActionNames, 'create' | 'edit'>> {\n return this.except(['create', 'edit'] as ActionNames[])\n }\n\n /**\n * Define matcher for params inside the resource\n */\n where(key: string, matcher: RouteMatcher | string | RegExp): this {\n this.routes.forEach((route) => {\n route.where(key, matcher)\n })\n\n return this\n }\n\n /**\n * Tap into multiple routes to configure them by their name\n */\n tap(callback: (route: Route) => void): this\n tap(actions: ActionNames | ActionNames[], callback: (route: Route) => void): this\n tap(\n actions: ((route: Route) => void) | ActionNames | ActionNames[],\n callback?: (route: Route) => void\n ): this {\n if (typeof actions === 'function') {\n this.routes.forEach((route) => {\n if (!route.isDeleted()) {\n actions(route)\n }\n })\n return this\n }\n\n this.#filter(actions, false).forEach((route) => {\n if (!route.isDeleted()) {\n callback!(route)\n }\n })\n return this\n }\n\n /**\n * Set the param name for a given resource\n */\n params(resources: { [resource: string]: string }): this {\n Object.keys(resources).forEach((resource) => {\n const param = resources[resource]\n const existingParam = this.#params[resource]\n this.#params[resource] = `:${param}`\n\n this.routes.forEach((route) => {\n route.setPattern(\n route.getPattern().replace(`${resource}/${existingParam}`, `${resource}/:${param}`)\n )\n })\n })\n\n return this\n }\n\n /**\n * Define one or more middleware on the routes created by\n * the resource.\n *\n * Calling this method multiple times will append middleware\n * to existing list.\n */\n use(\n actions: ActionNames | ActionNames[] | '*',\n middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>\n ): this {\n if (actions === '*') {\n this.tap((route) => route.use(middleware))\n } else {\n this.tap(actions, (route) => route.use(middleware))\n }\n return this\n }\n\n /**\n * @alias use\n */\n middleware(\n actions: ActionNames | ActionNames[] | '*',\n middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>\n ): this {\n return this.use(actions, middleware)\n }\n\n /**\n * Prepend name to all the routes\n */\n as(name: string, normalizeName: boolean = true): this {\n name = normalizeName ? string.snakeCase(name) : name\n this.routes.forEach((route) => {\n route.as(route.getName()!.replace(this.#routesBaseName, name), false)\n })\n\n this.#routesBaseName = name\n return this\n }\n}\n","/*\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 { debuglog } from 'node:util'\nexport default debuglog('adonisjs:http')\n","/*\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 { base64, MessageBuilder } from '@poppinss/utils'\n\n/**\n * Encodes a value into a base64 url encoded string to\n * be set as cookie\n */\nexport function pack(value: any): null | string {\n if (value === undefined || value === null) {\n return null\n }\n return base64.urlEncode(new MessageBuilder().build(value))\n}\n\n/**\n * Returns true when this `unpack` method of this module can attempt\n * to unpack the encode value.\n */\nexport function canUnpack(encodedValue: string) {\n return typeof encodedValue === 'string'\n}\n\n/**\n * Attempts to unpack the value by decoding it. Make sure to call, `canUnpack`\n * before calling this method\n */\nexport function unpack(encodedValue: string): null | any {\n return new MessageBuilder().verify(base64.urlDecode(encodedValue, 'utf-8', false))\n}\n","/*\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 type { Encryption } from '@adonisjs/encryption'\n\n/**\n * Signs a value to be shared as a cookie. The signed output has a\n * hash to verify tampering with the original value\n */\nexport function pack(key: string, value: any, encryption: Encryption): null | string {\n if (value === undefined || value === null) {\n return null\n }\n return `s:${encryption.verifier.sign(value, undefined, key)}`\n}\n\n/**\n * Returns a boolean, if the unpack method from this module can attempt\n * to unpack the signed value.\n */\nexport function canUnpack(signedValue: string) {\n return typeof signedValue === 'string' && signedValue.substring(0, 2) === 's:'\n}\n\n/**\n * Attempts to unpack the signed value. Make sure to call `canUnpack` before\n * calling this method.\n */\nexport function unpack(key: string, signedValue: string, encryption: Encryption): null | any {\n const value = signedValue.slice(2)\n if (!value) {\n return null\n }\n\n return encryption.verifier.unsign(value, key)\n}\n","/*\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 type { Encryption } from '@adonisjs/encryption'\n\n/**\n * Encrypt a value to be set as cookie\n */\nexport function pack(key: string, value: any, encryption: Encryption): null | string {\n if (value === undefined || value === null) {\n return null\n }\n return `e:${encryption.encrypt(value, undefined, key)}`\n}\n\n/**\n * Returns a boolean, if the unpack method from this module can attempt\n * to unpack encrypted value.\n */\nexport function canUnpack(encryptedValue: string) {\n return typeof encryptedValue === 'string' && encryptedValue.substring(0, 2) === 'e:'\n}\n\n/**\n * Attempts to unpack the encrypted cookie value. Returns null, when fails to do so.\n * Only call this method, when `canUnpack` returns true, otherwise runtime\n * exceptions can be raised.\n */\nexport function unpack(key: string, encryptedValue: string, encryption: Encryption): null | any {\n const value = encryptedValue.slice(2)\n if (!value) {\n return null\n }\n\n return encryption.decrypt(value, key)\n}\n","/*\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 type { Encryption } from '@adonisjs/encryption'\n\nimport * as plainCookiesDriver from './drivers/plain.js'\nimport * as signedCookiesDriver from './drivers/signed.js'\nimport * as encryptedCookiesDriver from './drivers/encrypted.js'\n\n/**\n * Cookie client exposes the API to parse/set AdonisJS cookies\n * as a client.\n */\nexport class CookieClient {\n #encryption: Encryption\n\n constructor(encryption: Encryption) {\n this.#encryption = encryption\n }\n\n /**\n * Encrypt a key value pair to be sent in the cookie header\n */\n encrypt(key: string, value: any): string | null {\n return encryptedCookiesDriver.pack(key, value, this.#encryption)\n }\n\n /**\n * Sign a key value pair to be sent in the cookie header\n */\n sign(key: string, value: any): string | null {\n return signedCookiesDriver.pack(key, value, this.#encryption)\n }\n\n /**\n * Encode a key value pair to be sent in the cookie header\n */\n encode(_: string, value: any): string | null {\n return plainCookiesDriver.pack(value)\n }\n\n /**\n * Unsign a signed cookie value\n */\n unsign(key: string, value: string) {\n return signedCookiesDriver.canUnpack(value)\n ? signedCookiesDriver.unpack(key, value, this.#encryption)\n : null\n }\n\n /**\n * Decrypt an encrypted cookie value\n */\n decrypt(key: string, value: string) {\n return encryptedCookiesDriver.canUnpack(value)\n ? encryptedCookiesDriver.unpack(key, value, this.#encryption)\n : null\n }\n\n /**\n * Decode an encoded cookie value\n */\n decode(_: string, value: string) {\n return plainCookiesDriver.canUnpack(value) ? plainCookiesDriver.unpack(value) : null\n }\n\n /**\n * Parse response cookie\n */\n parse(key: string, value: any) {\n /**\n * Unsign signed cookie\n */\n if (signedCookiesDriver.canUnpack(value)) {\n return signedCookiesDriver.unpack(key, value, this.#encryption)\n }\n\n /**\n * Decrypted encrypted cookie\n */\n if (encryptedCookiesDriver.canUnpack(value)) {\n return encryptedCookiesDriver.unpack(key, value, this.#encryption)\n }\n\n /**\n * Decode encoded cookie\n */\n if (plainCookiesDriver.canUnpack(value)) {\n return plainCookiesDriver.unpack(value)\n }\n }\n}\n","/*\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 fresh from 'fresh'\nimport typeIs from 'type-is'\nimport accepts from 'accepts'\nimport { isIP } from 'node:net'\nimport is from '@sindresorhus/is'\nimport proxyaddr from 'proxy-addr'\nimport { safeEqual } from '@poppinss/utils'\nimport Macroable from '@poppinss/macroable'\nimport lodash from '@poppinss/utils/lodash'\nimport { createId } from '@paralleldrive/cuid2'\nimport { parse, UrlWithStringQuery } from 'node:url'\nimport type { Encryption } from '@adonisjs/encryption'\nimport { ServerResponse, IncomingMessage, IncomingHttpHeaders } from 'node:http'\n\nimport type { Qs } from './qs.js'\nimport { trustProxy } from './helpers.js'\nimport { CookieParser } from './cookies/parser.js'\nimport { RequestConfig } from './types/request.js'\nimport type { HttpContext } from './http_context/main.js'\n\n/**\n * HTTP Request class exposes the interface to consistently read values\n * related to a given HTTP request. The class is wrapper over\n * [IncomingMessage](https://nodejs.org/api/http.html#http_class_http_incomingmessage)\n * and has extended API.\n *\n * You can access the original [IncomingMessage](https://nodejs.org/api/http.html#http_class_http_incomingmessage)\n * using `request.request` property.\n */\nexport class Request extends Macroable {\n /**\n * Query string parser\n */\n #qsParser: Qs\n\n /**\n * Encryption module to verify signed URLs and unsign/decrypt\n * cookies\n */\n #encryption: Encryption\n\n /**\n * Request config\n */\n #config: RequestConfig\n\n /**\n * Request body set using `setBody` method\n */\n #requestBody: Record<string, any> = {}\n\n /**\n * A merged copy of `request body` and `querystring`\n */\n #requestData: Record<string, any> = {}\n\n /**\n * Original merged copy of `request body` and `querystring`.\n * Further mutation to this object are not allowed\n */\n #originalRequestData: Record<string, any> = {}\n\n /**\n * Parsed query string\n */\n #requestQs: Record<string, any> = {}\n\n /**\n * Raw request body as text\n */\n #rawRequestBody?: string\n\n /**\n * Cached copy of `accepts` fn to do content\n * negotiation.\n */\n #lazyAccepts?: any\n\n /**\n * Copy of lazily parsed signed and plain cookies.\n */\n #cookieParser?: CookieParser\n\n /**\n * Parses copy of the URL with query string as a string and not\n * object. This is done to build URL's with query string without\n * stringifying the object\n */\n parsedUrl: UrlWithStringQuery\n\n /**\n * The ctx will be set by the context itself. It creates a circular\n * reference\n */\n ctx?: HttpContext\n\n constructor(\n public request: IncomingMessage,\n public response: ServerResponse,\n encryption: Encryption,\n config: RequestConfig,\n qsParser: Qs\n ) {\n super()\n\n this.#qsParser = qsParser\n this.#config = config\n this.#encryption = encryption\n this.parsedUrl = parse(this.request.url!, false)\n this.#parseQueryString()\n }\n\n /**\n * Parses the query string\n */\n #parseQueryString() {\n if (this.parsedUrl.query) {\n this.updateQs(this.#qsParser.parse(this.parsedUrl.query))\n this.#originalRequestData = { ...this.#requestData }\n }\n }\n\n /**\n * Initiates the cookie parser lazily\n */\n #initiateCookieParser() {\n if (!this.#cookieParser) {\n this.#cookieParser = new CookieParser(this.header('cookie')!, this.#encryption)\n }\n }\n\n /**\n * Lazily initiates the `accepts` module to make sure to parse\n * the request headers only when one of the content-negotiation\n * methods are used.\n */\n #initiateAccepts() {\n this.#lazyAccepts = this.#lazyAccepts || accepts(this.request)\n }\n\n /**\n * Returns the request id from the `x-request-id` header. The\n * header is untouched, if it already exists.\n */\n id(): string | undefined {\n let requestId = this.header('x-request-id')\n if (!requestId && this.#config.generateRequestId) {\n requestId = createId()\n this.request.headers['x-request-id'] = requestId\n }\n\n return requestId\n }\n\n /**\n * Set initial request body. A copy of the input will be maintained as the original\n * request body. Since the request body and query string is subject to mutations, we\n * keep one original reference to flash old data (whenever required).\n *\n * This method is supposed to be invoked by the body parser and must be called only\n * once. For further mutations make use of `updateBody` method.\n */\n setInitialBody(body: Record<string, any>) {\n if (this.#originalRequestData && Object.isFrozen(this.#originalRequestData)) {\n throw new Error('Cannot re-set initial body. Use \"request.updateBody\" instead')\n }\n\n this.updateBody(body)\n\n /*\n * Freeze the original object\n */\n this.#originalRequestData = Object.freeze(\n lodash.cloneDeepWith(this.#requestData, (value) => {\n if (is.primitive(value) || Array.isArray(value) || is.plainObject(value)) {\n return undefined\n }\n return null as any\n })\n )\n }\n\n /**\n * Update the request body with new data object. The `all` property\n * will be re-computed by merging the query string and request\n * body.\n */\n updateBody(body: Record<string, any>) {\n this.#requestBody = body\n this.#requestData = { ...this.#requestBody, ...this.#requestQs }\n }\n\n /**\n * Update the request raw body. Bodyparser sets this when unable to parse\n * the request body or when request is multipart/form-data.\n */\n updateRawBody(rawBody: string) {\n this.#rawRequestBody = rawBody\n }\n\n /**\n * Update the query string with the new data object. The `all` property\n * will be re-computed by merging the query and the request body.\n */\n updateQs(data: Record<string, any>) {\n this.#requestQs = data\n this.#requestData = { ...this.#requestBody, ...this.#requestQs }\n }\n\n /**\n * Returns route params\n */\n params(): Record<string, any> {\n return this.ctx?.params || {}\n }\n\n /**\n * Returns the query string object by reference\n */\n qs(): Record<string, any> {\n return this.#requestQs\n }\n\n /**\n * Returns reference to the request body\n */\n body(): Record<string, any> {\n return this.#requestBody\n }\n\n /**\n * Returns reference to the merged copy of request body\n * and query string\n */\n all(): Record<string, any> {\n return this.#requestData\n }\n\n /**\n * Returns reference to the merged copy of original request\n * query string and body\n */\n original(): Record<string, any> {\n return this.#originalRequestData\n }\n\n /**\n * Returns the request raw body (if exists), or returns `null`.\n *\n * Ideally you must be dealing with the parsed body accessed using [[input]], [[all]] or\n * [[post]] methods. The `raw` body is always a string.\n */\n raw(): string | null {\n return this.#rawRequestBody || null\n }\n\n /**\n * Returns value for a given key from the request body or query string.\n * The `defaultValue` is used when original value is `undefined`.\n *\n * @example\n * ```js\n * request.input('username')\n *\n * // with default value\n * request.input('username', 'virk')\n * ```\n */\n input(key: string, defaultValue?: any): any {\n return lodash.get(this.#requestData, key, defaultValue)\n }\n\n /**\n * Returns value for a given key from route params\n *\n * @example\n * ```js\n * request.param('id')\n *\n * // with default value\n * request.param('id', 1)\n * ```\n */\n param(key: string, defaultValue?: any): any {\n return lodash.get(this.params(), key, defaultValue)\n }\n\n /**\n * Get everything from the request body except the given keys.\n *\n * @example\n * ```js\n * request.except(['_csrf'])\n * ```\n */\n except(keys: string[]): Record<string, any> {\n return lodash.omit(this.#requestData, keys)\n }\n\n /**\n * Get value for specified keys.\n *\n * @example\n * ```js\n * request.only(['username', 'age'])\n * ```\n */\n only<T extends string>(keys: T[]): { [K in T]: any } {\n return lodash.pick(this.#requestData, keys) as { [K in T]: any }\n }\n\n /**\n * Returns the HTTP request method. This is the original\n * request method. For spoofed request method, make\n * use of [[method]].\n *\n * @example\n * ```js\n * request.intended()\n * ```\n */\n intended(): string {\n return this.request.method!\n }\n\n /**\n * Returns the request HTTP method by taking method spoofing into account.\n *\n * Method spoofing works when all of the following are true.\n *\n * 1. `app.http.allowMethodSpoofing` config value is true.\n * 2. request query string has `_method`.\n * 3. The [[intended]] request method is `POST`.\n *\n * @example\n * ```js\n * request.method()\n * ```\n */\n method(): string {\n if (this.#config.allowMethodSpoofing && this.intended() === 'POST') {\n return this.input('_method', this.intended()).toUpperCase()\n }\n return this.intended()\n }\n\n /**\n * Returns a copy of headers as an object\n */\n headers(): IncomingHttpHeaders {\n return this.request.headers\n }\n\n /**\n * Returns value for a given header key. The default value is\n * used when original value is `undefined`.\n */\n header(key: string, defaultValue?: any): string | undefined {\n key = key.toLowerCase()\n const headers = this.headers()\n\n switch (key) {\n case 'referer':\n case 'referrer':\n return headers.referrer || headers.referer || defaultValue\n default:\n return headers[key] || defaultValue\n }\n }\n\n /**\n * Returns the ip address of the user. This method is optimize to fetch\n * ip address even when running your AdonisJs app behind a proxy.\n *\n * You can also define your own custom function to compute the ip address by\n * defining `app.http.getIp` as a function inside the config file.\n *\n * ```js\n * {\n * http: {\n * getIp (request) {\n * // I am using nginx as a proxy server and want to trust 'x-real-ip'\n * return request.header('x-real-ip')\n * }\n * }\n * }\n * ```\n *\n * You can control the behavior of trusting the proxy values by defining it\n * inside the `config/app.js` file.\n *\n * ```js\n * {\n * http: {\n * trustProxy: '127.0.0.1'\n * }\n * }\n * ```\n *\n * The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)\n */\n ip(): string {\n const ipFn = this.#config.getIp\n if (typeof ipFn === 'function') {\n return ipFn(this)\n }\n\n return proxyaddr(this.request, this.#config.trustProxy)\n }\n\n /**\n * Returns an array of ip addresses from most to least trusted one.\n * This method is optimize to fetch ip address even when running\n * your AdonisJs app behind a proxy.\n *\n * You can control the behavior of trusting the proxy values by defining it\n * inside the `config/app.js` file.\n *\n * ```js\n * {\n * http: {\n * trustProxy: '127.0.0.1'\n * }\n * }\n * ```\n *\n * The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)\n */\n ips(): string[] {\n return proxyaddr.all(this.request, this.#config.trustProxy)\n }\n\n /**\n * Returns the request protocol by checking for the URL protocol or\n * `X-Forwarded-Proto` header.\n *\n * If the `trust` is evaluated to `false`, then URL protocol is returned,\n * otherwise `X-Forwarded-Proto` header is used (if exists).\n *\n * You can control the behavior of trusting the proxy values by defining it\n * inside the `config/app.js` file.\n *\n * ```js\n * {\n * http: {\n * trustProxy: '127.0.0.1'\n * }\n * }\n * ```\n *\n * The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)\n */\n protocol(): string {\n if ('encrypted' in this.request.socket) {\n return 'https'\n }\n\n if (!trustProxy(this.request.socket.remoteAddress!, this.#config.trustProxy)) {\n return this.parsedUrl.protocol || 'http'\n }\n\n const forwardedProtocol = this.header('X-Forwarded-Proto')\n return forwardedProtocol ? forwardedProtocol.split(/\\s*,\\s*/)[0] : 'http'\n }\n\n /**\n * Returns a boolean telling if request is served over `https`\n * or not. Check [[protocol]] method to know how protocol is\n * fetched.\n */\n secure(): boolean {\n return this.protocol() === 'https'\n }\n\n /**\n * Returns the request host. If proxy headers are trusted, then\n * `X-Forwarded-Host` is given priority over the `Host` header.\n *\n * You can control the behavior of trusting the proxy values by defining it\n * inside the `config/app.js` file.\n *\n * ```js\n * {\n * http: {\n * trustProxy: '127.0.0.1'\n * }\n * }\n * ```\n *\n * The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)\n */\n host(): string | null {\n let host = this.header('host')\n\n /*\n * Use X-Fowarded-Host when we trust the proxy header and it\n * exists\n */\n if (trustProxy(this.request.socket.remoteAddress!, this.#config.trustProxy)) {\n host = this.header('X-Forwarded-Host') || host\n }\n\n if (!host) {\n return null\n }\n\n return host\n }\n\n /**\n * Returns the request hostname. If proxy headers are trusted, then\n * `X-Forwarded-Host` is given priority over the `Host` header.\n *\n * You can control the behavior of trusting the proxy values by defining it\n * inside the `config/app.js` file.\n *\n * ```js\n * {\n * http: {\n * trustProxy: '127.0.0.1'\n * }\n * }\n * ```\n *\n * The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)\n */\n hostname(): string | null {\n const host = this.host()\n\n if (!host) {\n return null\n }\n\n /*\n * Support for IPv6\n * https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2\n * https://github.com/nodejs/node/pull/5314\n */\n const offset = host[0] === '[' ? host.indexOf(']') + 1 : 0\n const index = host.indexOf(':', offset)\n return index !== -1 ? host.substring(0, index) : host\n }\n\n /**\n * Returns an array of subdomains for the given host. An empty array is\n * returned if [[hostname]] is `null` or is an IP address.\n *\n * Also `www` is not considered as a subdomain\n */\n subdomains(): string[] {\n const hostname = this.hostname()\n\n /*\n * Return empty array when hostname is missing or it's\n * an IP address\n */\n if (!hostname || isIP(hostname)) {\n return []\n }\n\n const offset = this.#config.subdomainOffset\n const subdomains = hostname.split('.').reverse().slice(offset)\n\n /*\n * Remove www from the subdomains list\n */\n if (subdomains[subdomains.length - 1] === 'www') {\n subdomains.splice(subdomains.length - 1, 1)\n }\n\n return subdomains\n }\n\n /**\n * Returns a boolean telling, if request `X-Requested-With === 'xmlhttprequest'`\n * or not.\n */\n ajax(): boolean {\n const xRequestedWith = this.header('X-Requested-With', '')\n return xRequestedWith!.toLowerCase() === 'xmlhttprequest'\n }\n\n /**\n * Returns a boolean telling, if request has `X-Pjax` header\n * set or not\n */\n pjax(): boolean {\n return !!this.header('X-Pjax')\n }\n\n /**\n * Returns the request relative URL.\n *\n * @example\n * ```js\n * request.url()\n *\n * // include query string\n * request.url(true)\n * ```\n */\n url(includeQueryString?: boolean): string {\n const pathname = this.parsedUrl.pathname!\n return includeQueryString && this.parsedUrl.query\n ? `${pathname}?${this.parsedUrl.query}`\n : pathname\n }\n\n /**\n * Returns the complete HTTP url by combining\n * [[protocol]]://[[hostname]]/[[url]]\n *\n * @example\n * ```js\n * request.completeUrl()\n *\n * // include query string\n * request.completeUrl(true)\n * ```\n */\n completeUrl(includeQueryString?: boolean): string {\n const protocol = this.protocol()\n const hostname = this.host()\n return `${protocol}://${hostname}${this.url(includeQueryString)}`\n }\n\n /**\n * Find if the current HTTP request is for the given route or the routes\n */\n matchesRoute(routeIdentifier: string | string[]): boolean {\n /**\n * The context is missing inside the HTTP server hooks.\n */\n if (!this.ctx || !this.ctx.route) {\n return false\n }\n\n const route = this.ctx.route\n\n /**\n * Search the identifier(s) against the route \"pattern\", \"name\" and the route handler\n */\n return !!(Array.isArray(routeIdentifier) ? routeIdentifier : [routeIdentifier]).find(\n (identifier) => {\n if (route.pattern === identifier || route.name === identifier) {\n return true\n }\n\n if (typeof route.handler === 'function') {\n return false\n }\n\n return route.handler.reference === identifier\n }\n )\n }\n\n /**\n * Returns the best matching content type of the request by\n * matching against the given types.\n *\n * The content type is picked from the `content-type` header and request\n * must have body.\n *\n * The method response highly depends upon the types array values. Described below:\n *\n * | Type(s) | Return value |\n * |----------|---------------|\n * | ['json'] | json |\n * | ['application/*'] | application/json |\n * | ['vnd+json'] | application/json |\n *\n * @example\n * ```js\n * const bodyType = request.is(['json', 'xml'])\n *\n * if (bodyType === 'json') {\n * // process JSON\n * }\n *\n * if (bodyType === 'xml') {\n * // process XML\n * }\n * ```\n */\n is(types: string[]): string | null {\n return typeIs(this.request, types) || null\n }\n\n /**\n * Returns the best type using `Accept` header and\n * by matching it against the given types.\n *\n * If nothing is matched, then `null` will be returned\n *\n * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package\n * docs too.\n *\n * @example\n * ```js\n * switch (request.accepts(['json', 'html'])) {\n * case 'json':\n * return response.json(user)\n * case 'html':\n * return view.render('user', { user })\n * default:\n * // decide yourself\n * }\n * ```\n */\n accepts<T extends string>(types: T[]): T | null {\n this.#initiateAccepts()\n return this.#lazyAccepts.type(types) || null\n }\n\n /**\n * Return the types that the request accepts, in the order of the\n * client's preference (most preferred first).\n *\n * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package\n * docs too.\n */\n types(): string[] {\n this.#initiateAccepts()\n return this.#lazyAccepts.types()\n }\n\n /**\n * Returns the best language using `Accept-language` header\n * and by matching it against the given languages.\n *\n * If nothing is matched, then `null` will be returned\n *\n * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package\n * docs too.\n *\n * @example\n * ```js\n * switch (request.language(['fr', 'de'])) {\n * case 'fr':\n * return view.render('about', { lang: 'fr' })\n * case 'de':\n * return view.render('about', { lang: 'de' })\n * default:\n * return view.render('about', { lang: 'en' })\n * }\n * ```\n */\n language<T extends string>(languages: T[]): T | null {\n this.#initiateAccepts()\n return this.#lazyAccepts.language(languages) || null\n }\n\n /**\n * Return the languages that the request accepts, in the order of the\n * client's preference (most preferred first).\n *\n * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package\n * docs too.\n */\n languages(): string[] {\n this.#initiateAccepts()\n return this.#lazyAccepts.languages()\n }\n\n /**\n * Returns the best charset using `Accept-charset` header\n * and by matching it against the given charsets.\n *\n * If nothing is matched, then `null` will be returned\n *\n * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package\n * docs too.\n *\n * @example\n * ```js\n * switch (request.charset(['utf-8', 'ISO-8859-1'])) {\n * case 'utf-8':\n * // make utf-8 friendly response\n * case 'ISO-8859-1':\n * // make ISO-8859-1 friendly response\n * }\n * ```\n */\n charset<T extends string>(charsets: T[]): T | null {\n this.#initiateAccepts()\n return this.#lazyAccepts.charset(charsets) || null\n }\n\n /**\n * Return the charsets that the request accepts, in the order of the\n * client's preference (most preferred first).\n *\n * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package\n * docs too.\n */\n charsets(): string[] {\n this.#initiateAccepts()\n return this.#lazyAccepts.charsets()\n }\n\n /**\n * Returns the best encoding using `Accept-encoding` header\n * and by matching it against the given encodings.\n *\n * If nothing is matched, then `null` will be returned\n *\n * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package\n * docs too.\n */\n encoding<T extends string>(encodings: T[]): T | null {\n this.#initiateAccepts()\n return this.#lazyAccepts.encoding(encodings) || null\n }\n\n /**\n * Return the charsets that the request accepts, in the order of the\n * client's preference (most preferred first).\n *\n * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package\n * docs too.\n */\n encodings(): string[] {\n this.#initiateAccepts()\n return this.#lazyAccepts.encodings()\n }\n\n /**\n * Returns a boolean telling if request has body\n */\n hasBody(): boolean {\n return typeIs.hasBody(this.request)\n }\n\n /**\n * Returns a boolean telling if the new response etag evaluates same\n * as the request header `if-none-match`. In case of `true`, the\n * server must return `304` response, telling the browser to\n * use the client cache.\n *\n * You won't have to deal with this method directly, since AdonisJs will\n * handle this for you when `http.etag = true` inside `config/app.js` file.\n *\n * However, this is how you can use it manually.\n *\n * ```js\n * const responseBody = view.render('some-view')\n *\n * // sets the HTTP etag header for response\n * response.setEtag(responseBody)\n *\n * if (request.fresh()) {\n * response.sendStatus(304)\n * } else {\n * response.send(responseBody)\n * }\n * ```\n */\n fresh(): boolean {\n if (['GET', 'HEAD'].indexOf(this.intended()) === -1) {\n return false\n }\n\n const status = this.response.statusCode\n if ((status >= 200 && status < 300) || status === 304) {\n return fresh(this.headers(), this.response.getHeaders())\n }\n\n return false\n }\n\n /**\n * Opposite of [[fresh]]\n */\n stale(): boolean {\n return !this.fresh()\n }\n\n /**\n * Returns all parsed and signed cookies. Signed cookies ensures\n * that their value isn't tampered.\n */\n cookiesList() {\n this.#initiateCookieParser()\n return this.#cookieParser!.list()\n }\n\n /**\n * Returns value for a given key from signed cookies. Optional\n * defaultValue is returned when actual value is undefined.\n */\n cookie(key: string, defaultValue?: string): any {\n this.#initiateCookieParser()\n return this.#cookieParser!.unsign(key) || defaultValue\n }\n\n /**\n * Returns value for a given key from signed cookies. Optional\n * defaultValue is returned when actual value is undefined.\n */\n encryptedCookie(key: string, defaultValue?: string): any {\n this.#initiateCookieParser()\n return this.#cookieParser!.decrypt(key) || defaultValue\n }\n\n /**\n * Returns value for a given key from unsigned cookies. Optional\n * defaultValue is returned when actual value is undefined.\n */\n plainCookie(key: string, options?: { defaultValue?: string; encoded?: boolean }): any\n plainCookie(key: string, defaultValue?: string, encoded?: boolean): any\n plainCookie(\n key: string,\n defaultValueOrOptions?: string | { defaultValue?: string; encoded?: boolean },\n encoded?: boolean\n ): any {\n this.#initiateCookieParser()\n\n if (is.object(defaultValueOrOptions)) {\n return (\n this.#cookieParser!.decode(key, defaultValueOrOptions?.encoded) ||\n defaultValueOrOptions.defaultValue\n )\n }\n\n return this.#cookieParser!.decode(key, encoded) || defaultValueOrOptions\n }\n\n /**\n * Returns a boolean telling if a signed url as a valid signature\n * or not.\n */\n hasValidSignature(purpose?: string) {\n const { signature, ...rest } = this.qs()\n if (!signature) {\n return false\n }\n\n /*\n * Return false when signature fails\n */\n const signedUrl = this.#encryption.verifier.unsign(signature, purpose)\n if (!signedUrl) {\n return false\n }\n\n const queryString = this.#qsParser.stringify(rest)\n\n return queryString\n ? safeEqual(signedUrl, `${this.url()}?${queryString}`)\n : safeEqual(signedUrl, this.url())\n }\n\n /**\n * Serializes request to JSON format\n */\n serialize() {\n return {\n id: this.id(),\n url: this.url(),\n query: this.parsedUrl.query,\n body: this.all(),\n params: this.params(),\n headers: this.headers(),\n method: this.method(),\n protocol: this.protocol(),\n cookies: this.cookiesList(),\n hostname: this.hostname(),\n ip: this.ip(),\n subdomains: this.ctx?.subdomains || {},\n }\n }\n\n /**\n * toJSON copy of the request\n */\n toJSON() {\n return this.serialize()\n }\n}\n","/*\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 cookie from 'cookie'\nimport type { Encryption } from '@adonisjs/encryption'\n\nimport { CookieClient } from './client.js'\n\n/**\n * Cookie parser parses the HTTP `cookie` header and collects all cookies\n * inside an object of `key-value` pair, but doesn't attempt to decrypt\n * or unsign or decode the individual values.\n *\n * The cookie values are lazily decrypted, or unsigned to avoid unncessary\n * processing, which infact can be used as a means to burden the server\n * by sending too many cookies which even doesn't belongs to the\n * server.\n */\nexport class CookieParser {\n #client: CookieClient\n\n /**\n * A copy of cached cookies, they are cached during a request after\n * initial decoding, unsigning or decrypting.\n */\n #cachedCookies: {\n encryptedCookies: Record<string, any>\n signedCookies: Record<string, any>\n plainCookies: Record<string, any>\n } = {\n signedCookies: {},\n plainCookies: {},\n encryptedCookies: {},\n }\n\n /**\n * An object of key-value pair collected by parsing\n * the request cookie header.\n */\n #cookies: Record<string, any>\n\n constructor(cookieHeader: string, encryption: Encryption) {\n this.#client = new CookieClient(encryption)\n this.#cookies = this.#parse(cookieHeader)\n }\n\n /**\n * Parses the request `cookie` header\n */\n #parse(cookieHeader?: string) {\n /*\n * Set to empty object when cookie header is empty string\n */\n if (!cookieHeader) {\n return {}\n }\n\n /*\n * Parse and store reference\n */\n return cookie.parse(cookieHeader)\n }\n\n /**\n * Attempts to decode a cookie by the name. When calling this method,\n * you are assuming that the cookie was just encoded in the first\n * place and not signed or encrypted.\n */\n decode(key: string, encoded = true): any | null {\n /*\n * Ignore when initial value is not defined or null\n */\n const value = this.#cookies[key]\n if (value === null || value === undefined) {\n return null\n }\n\n /*\n * Reference to the cache object. Mainly done to avoid typos,\n * since this object is referenced a handful of times inside\n * this method.\n */\n const cache = this.#cachedCookies.plainCookies\n\n /*\n * Return from cache, when already parsed\n */\n if (cache[key] !== undefined) {\n return cache[key]\n }\n\n /*\n * Attempt to unpack and cache it for future. The value is only\n * when value it is not null.\n */\n const parsed = encoded ? this.#client.decode(key, value) : value\n if (parsed !== null) {\n cache[key] = parsed\n }\n\n return parsed\n }\n\n /**\n * Attempts to unsign a cookie by the name. When calling this method,\n * you are assuming that the cookie was signed in the first place.\n */\n unsign(key: string): null | any {\n /*\n * Ignore when initial value is not defined or null\n */\n const value = this.#cookies[key]\n if (value === null || value === undefined) {\n return null\n }\n\n /*\n * Reference to the cache object. Mainly done to avoid typos,\n * since this object is referenced a handful of times inside\n * this method.\n */\n const cache = this.#cachedCookies.signedCookies\n\n /*\n * Return from cache, when already parsed\n */\n if (cache[key] !== undefined) {\n return cache[key]\n }\n\n /*\n * Attempt to unpack and cache it for future. The value is only\n * when value it is not null.\n */\n const parsed = this.#client.unsign(key, value)\n if (parsed !== null) {\n cache[key] = parsed\n }\n\n return parsed\n }\n\n /**\n * Attempts to decrypt a cookie by the name. When calling this method,\n * you are assuming that the cookie was encrypted in the first place.\n */\n decrypt(key: string): null | any {\n /*\n * Ignore when initial value is not defined or null\n */\n const value = this.#cookies[key]\n if (value === null || value === undefined) {\n return null\n }\n\n /*\n * Reference to the cache object. Mainly done to avoid typos,\n * since this object is referenced a handful of times inside\n * this method.\n */\n const cache = this.#cachedCookies.encryptedCookies\n\n /*\n * Return from cache, when already parsed\n */\n if (cache[key] !== undefined) {\n return cache[key]\n }\n\n /*\n * Attempt to unpack and cache it for future. The value is only\n * when value it is not null.\n */\n const parsed = this.#client.decrypt(key, value)\n if (parsed !== null) {\n cache[key] = parsed\n }\n\n return parsed\n }\n\n /**\n * Returns an object of cookies key-value pair. Do note, the\n * cookies are not decoded, unsigned or decrypted inside this\n * list.\n */\n list() {\n return this.#cookies\n }\n}\n","/*\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 { parse } from 'node:url'\nimport encodeUrl from 'encodeurl'\nimport type { IncomingMessage } from 'node:http'\n\nimport debug from './debug.js'\nimport type { Qs } from './qs.js'\nimport type { Response } from './response.js'\nimport type { Router } from './router/main.js'\nimport type { MakeUrlOptions } from './types/route.js'\n\n/**\n * Exposes the API to construct redirect routes\n */\nexport class Redirect {\n /**\n * A boolean to forward the existing query string\n */\n #forwardQueryString = false\n\n /**\n * The status code for the redirect\n */\n #statusCode = 302\n\n /**\n * A custom query string to forward\n */\n #queryString: Record<string, any> = {}\n\n #request: IncomingMessage\n #response: Response\n #router: Router\n #qs: Qs\n\n constructor(request: IncomingMessage, response: Response, router: Router, qs: Qs) {\n this.#request = request\n this.#response = response\n this.#router = router\n this.#qs = qs\n }\n\n /**\n * Sends response by setting require headers\n */\n #sendResponse(url: string, query: Record<string, any>) {\n const stringified = this.#qs.stringify(query)\n\n url = stringified ? `${url}?${stringified}` : url\n debug('redirecting to url \"%s\"', url)\n\n this.#response.location(encodeUrl(url))\n this.#response.safeStatus(this.#statusCode)\n this.#response.type('text/plain; charset=utf-8')\n this.#response.send(`Redirecting to ${url}`)\n }\n\n /**\n * Returns the referrer url\n */\n #getReferrerUrl(): string {\n let url = this.#request.headers['referer'] || this.#request.headers['referrer'] || '/'\n return Array.isArray(url) ? url[0] : url\n }\n\n /**\n * Set a custom status code.\n */\n status(statusCode: number): this {\n this.#statusCode = statusCode\n return this\n }\n\n /**\n * Clearing query string values added using the\n * \"withQs\" method\n */\n clearQs(): this {\n this.#forwardQueryString = false\n this.#queryString = {}\n return this\n }\n\n /**\n * Define query string for the redirect. Not passing\n * any value will forward the current request query\n * string.\n */\n withQs(): this\n withQs(values: Record<string, any>): this\n withQs(name: string, value: any): this\n withQs(name?: Record<string, any> | string, value?: any): this {\n if (typeof name === 'undefined') {\n this.#forwardQueryString = true\n return this\n }\n\n if (typeof name === 'string') {\n this.#queryString[name] = value\n return this\n }\n\n Object.assign(this.#queryString, name)\n return this\n }\n\n /**\n * Redirect to the previous path.\n */\n back() {\n let query: Record<string, any> = {}\n\n const referrerUrl = this.#getReferrerUrl()\n const url = parse(referrerUrl)\n\n debug('referrer url \"%s\"', referrerUrl)\n debug('referrer base url \"%s\"', url.pathname)\n\n /**\n * Parse query string from the referrer url\n */\n if (this.#forwardQueryString) {\n query = this.#qs.parse(url.query || '')\n }\n\n /**\n * Append custom query string\n */\n Object.assign(query, this.#queryString)\n\n /**\n * Redirect\n */\n this.#sendResponse(url.pathname || '', query)\n }\n\n /**\n * Redirect the request using a route identifier.\n */\n toRoute(routeIdentifier: string, params?: any[] | Record<string, any>, options?: MakeUrlOptions) {\n if (options && options.qs) {\n this.withQs(options.qs)\n options.qs = undefined\n }\n\n const url = this.#router.makeUrl(routeIdentifier, params, options)\n return this.toPath(url)\n }\n\n /**\n * Redirect the request using a path.\n */\n toPath(url: string) {\n let query: Record<string, any> = {}\n\n /**\n * Extract query string from the current URL\n */\n if (this.#forwardQueryString) {\n query = this.#qs.parse(parse(this.#request.url!).query || '')\n }\n\n /**\n * Assign custom query string\n */\n Object.assign(query, this.#queryString)\n\n /**\n * Redirect\n */\n this.#sendResponse(url, query)\n }\n}\n","/*\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 { createError, Exception } from '@poppinss/utils'\nimport type { HttpContext } from './http_context/main.js'\n\nexport const E_ROUTE_NOT_FOUND = createError<[method: string, url: string]>(\n 'Cannot %s:%s',\n 'E_ROUTE_NOT_FOUND',\n 404\n)\n\nexport const E_CANNOT_LOOKUP_ROUTE = createError<[routeIdentifier: string]>(\n 'Cannot lookup route \"%s\"',\n 'E_CANNOT_LOOKUP_ROUTE',\n 500\n)\n\nexport const E_HTTP_EXCEPTION = class HttpException extends Exception {\n body: any\n static code = 'E_HTTP_EXCEPTION'\n\n /**\n * This method returns an instance of the exception class\n */\n static invoke(body: any, status: number, code: string = 'E_HTTP_EXCEPTION'): HttpException {\n if (body === null || body === undefined) {\n const error = new this('HTTP Exception', { status, code })\n error.body = 'Internal server error'\n return error\n }\n\n if (typeof body === 'object') {\n const error = new this(body.message || 'HTTP Exception', { status, code })\n error.body = body\n return error\n }\n\n const error = new this(body, { status, code })\n error.body = body\n return error\n }\n}\n\nexport const E_HTTP_REQUEST_ABORTED = class AbortException extends E_HTTP_EXCEPTION {\n handle(error: AbortException, ctx: HttpContext) {\n ctx.response.status(error.status).send(error.body)\n }\n}\n","/*\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\nexport const ResponseStatus = {\n Continue: 100,\n SwitchingProtocols: 101,\n Processing: 102,\n EarlyHints: 103,\n Ok: 200,\n Created: 201,\n Accepted: 202,\n NonAuthoritativeInformation: 203,\n NoContent: 204,\n ResetContent: 205,\n PartialContent: 206,\n MultiStatus: 207,\n AlreadyReported: 208,\n IMUsed: 226,\n MultipleChoices: 300,\n MovedPermanently: 301,\n Found: 302,\n SeeOther: 303,\n NotModified: 304,\n UseProxy: 305,\n TemporaryRedirect: 307,\n PermanentRedirect: 308,\n BadRequest: 400,\n Unauthorized: 401,\n PaymentRequired: 402,\n Forbidden: 403,\n NotFound: 404,\n MethodNotAllowed: 405,\n NotAcceptable: 406,\n ProxyAuthenticationRequired: 407,\n RequestTimeout: 408,\n Conflict: 409,\n Gone: 410,\n LengthRequired: 411,\n PreconditionFailed: 412,\n PayloadTooLarge: 413,\n URITooLong: 414,\n UnsupportedMediaType: 415,\n RangeNotSatisfiable: 416,\n ExpectationFailed: 417,\n ImATeapot: 418,\n MisdirectedRequest: 421,\n UnprocessableEntity: 422,\n Locked: 423,\n FailedDependency: 424,\n TooEarly: 425,\n UpgradeRequired: 426,\n PreconditionRequired: 428,\n TooManyRequests: 429,\n RequestHeaderFieldsTooLarge: 431,\n UnavailableForLegalReasons: 451,\n InternalServerError: 500,\n NotImplemented: 501,\n BadGateway: 502,\n ServiceUnavailable: 503,\n GatewayTimeout: 504,\n HTTPVersionNotSupported: 505,\n VariantAlsoNegotiates: 506,\n InsufficientStorage: 507,\n LoopDetected: 508,\n NotExtended: 510,\n NetworkAuthenticationRequired: 511,\n} as const\n","/*\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 { Buffer } from 'node:buffer'\nimport etag from 'etag'\nimport vary from 'vary'\nimport fresh from 'fresh'\nimport mime from 'mime-types'\nimport destroy from 'destroy'\nimport { extname } from 'node:path'\nimport onFinished from 'on-finished'\nimport json from '@poppinss/utils/json'\nimport Macroable from '@poppinss/macroable'\nimport { createReadStream } from 'node:fs'\nimport { stat } from 'node:fs/promises'\nimport { RuntimeException } from '@poppinss/utils'\nimport contentDisposition from 'content-disposition'\nimport type { Encryption } from '@adonisjs/encryption'\nimport { ServerResponse, IncomingMessage, OutgoingHttpHeaders } from 'node:http'\n\nimport type { Qs } from './qs.js'\nimport { Redirect } from './redirect.js'\nimport type { Router } from './router/main.js'\nimport type { HttpContext } from './http_context/main.js'\nimport { CookieSerializer } from './cookies/serializer.js'\nimport { E_HTTP_REQUEST_ABORTED } from './exceptions.js'\nimport type {\n CastableHeader,\n CookieOptions,\n ResponseConfig,\n ResponseStream,\n} from './types/response.js'\nimport { ResponseStatus } from './response_status.js'\n\nconst CACHEABLE_HTTP_METHODS = ['GET', 'HEAD']\n\n/**\n * The response is a wrapper over [ServerResponse](https://nodejs.org/api/http.html#http_class_http_serverresponse)\n * streamlining the process of writing response body and automatically setting up appropriate headers.\n */\nexport class Response extends Macroable {\n /**\n * Query string parser\n */\n #qs: Qs\n\n /**\n * Outgoing headers\n */\n #headers: OutgoingHttpHeaders = {}\n\n /**\n * Has explicit status been set\n */\n #hasExplicitStatus = false\n\n /**\n * Cookies serializer to serialize the outgoing cookies\n */\n #cookieSerializer: CookieSerializer\n\n /**\n * Router is used to make the redirect URLs from routes\n */\n #router: Router\n\n /**\n * Response config\n */\n #config: ResponseConfig\n\n /**\n * Does response has body set that will written to the\n * response socket at the end of the request\n */\n get hasLazyBody(): boolean {\n return !!(this.lazyBody.content || this.lazyBody.fileToStream || this.lazyBody.stream)\n }\n\n /**\n * Find if the response has non-stream content\n */\n get hasContent(): boolean {\n return !!this.lazyBody.content\n }\n\n /**\n * Returns true when response body is set using \"response.stream\"\n * method\n */\n get hasStream(): boolean {\n return !!this.lazyBody.stream\n }\n\n /**\n * Returns true when response body is set using \"response.download\"\n * or \"response.attachment\" methods\n */\n get hasFileToStream(): boolean {\n return !!this.lazyBody.fileToStream\n }\n\n /**\n * Returns the response content. Check if the response\n * has content using the \"hasContent\" method\n */\n get content() {\n return this.lazyBody.content\n }\n\n /**\n * Returns reference to the stream set using \"response.stream\"\n * method\n */\n get outgoingStream() {\n return this.lazyBody.stream?.[0]\n }\n\n /**\n * Returns reference to the file path set using \"response.stream\"\n * method.\n */\n get fileToStream() {\n return this.lazyBody.fileToStream\n ? {\n path: this.lazyBody.fileToStream[0],\n generateEtag: this.lazyBody.fileToStream[1],\n }\n : undefined\n }\n\n /**\n * Lazy body is used to set the response body. However, do not\n * write it on the socket immediately unless `response.finish`\n * is called.\n */\n lazyBody: Partial<{\n content: [any, boolean, string?]\n stream: [ResponseStream, ((error: NodeJS.ErrnoException) => [string, number?])?]\n fileToStream: [string, boolean, ((error: NodeJS.ErrnoException) => [string, number?])?]\n }> = {}\n\n /**\n * The ctx will be set by the context itself. It creates a circular\n * reference\n */\n ctx?: HttpContext\n\n constructor(\n public request: IncomingMessage,\n public response: ServerResponse,\n encryption: Encryption,\n config: ResponseConfig,\n router: Router,\n qs: Qs\n ) {\n super()\n\n this.#qs = qs\n this.#config = config\n this.#router = router\n this.#cookieSerializer = new CookieSerializer(encryption)\n }\n\n /**\n * Returns a boolean telling if response is finished or not.\n * Any more attempts to update headers or body will result\n * in raised exceptions.\n */\n get finished(): boolean {\n return this.response.writableFinished\n }\n\n /**\n * Returns a boolean telling if response headers has been sent or not.\n * Any more attempts to update headers will result in raised\n * exceptions.\n */\n get headersSent(): boolean {\n return this.response.headersSent\n }\n\n /**\n * Returns a boolean telling if response headers and body is written\n * or not. When value is `true`, you can feel free to write headers\n * and body.\n */\n get isPending(): boolean {\n return !this.headersSent && !this.finished\n }\n\n /**\n * Normalizes header value to a string or an array of string\n */\n #castHeaderValue(value: any): string | string[] {\n return Array.isArray(value) ? value.map(String) : String(value)\n }\n\n /**\n * Ends the response by flushing headers and writing body\n */\n #endResponse(body?: any, statusCode?: number) {\n this.writeHead(statusCode)\n\n // avoid ArgumentsAdaptorTrampoline from V8 (inspired by fastify)\n const res = this.response as any\n res.end(body, null, null)\n }\n\n /**\n * Returns type for the content body. Only following types are allowed\n *\n * - Dates\n * - Arrays\n * - Booleans\n * - Objects\n * - Strings\n * - Buffer\n */\n #getDataType(content: any) {\n if (content instanceof Uint8Array) {\n return 'buffer'\n }\n\n /**\n * Date instance\n */\n if (content instanceof Date) {\n return 'date'\n }\n\n /**\n * Regular expression\n */\n if (content instanceof RegExp) {\n return 'regexp'\n }\n\n const dataType = typeof content\n if (\n dataType === 'number' ||\n dataType === 'boolean' ||\n dataType === 'string' ||\n dataType === 'bigint'\n ) {\n return dataType\n }\n\n /**\n * Object\n */\n if (dataType === 'object') {\n return 'object'\n }\n\n throw new RuntimeException(`Cannot serialize \"${dataType}\" to HTTP response`)\n }\n\n /**\n * Writes the body with appropriate response headers. Etag header is set\n * when `generateEtag` is set to `true`.\n *\n * Empty body results in `204`.\n */\n protected writeBody(content: any, generateEtag: boolean, jsonpCallbackName?: string): void {\n const hasEmptyBody = content === null || content === undefined || content === ''\n\n /**\n * Set status to \"204\" when body is empty. The `safeStatus` method only\n * sets the status when no explicit status has been set already\n */\n if (hasEmptyBody) {\n this.safeStatus(204)\n }\n\n const statusCode = this.response.statusCode\n\n /**\n * Do not process body when status code is less than 200 or is 204 or 304. As per\n * https://tools.ietf.org/html/rfc7230#section-3.3.2\n */\n if (\n statusCode &&\n (statusCode < ResponseStatus.Ok ||\n statusCode === ResponseStatus.NoContent ||\n statusCode === ResponseStatus.NotModified)\n ) {\n this.removeHeader('Content-Type')\n this.removeHeader('Content-Length')\n this.removeHeader('Transfer-Encoding')\n this.#endResponse()\n return\n }\n\n /**\n * Body is empty and status code is not \"204\", \"304\" and neither under 200.\n */\n if (hasEmptyBody) {\n this.removeHeader('Content-Length')\n this.#endResponse()\n return\n }\n\n /**\n * Javascript data type for the content. We only handle a subset\n * of data types. Check [[this.getDataType]] method for more\n * info\n */\n const dataType = this.#getDataType(content)\n\n /**\n * ----------------------------------------\n * SERIALIZE CONTENT TO A STRING\n * ----------------------------------------\n *\n * Transforming date, number, boolean and object to a string\n */\n if (dataType === 'object') {\n content = json.safeStringify(content)\n } else if (\n dataType === 'number' ||\n dataType === 'boolean' ||\n dataType === 'bigint' ||\n dataType === 'regexp'\n ) {\n content = String(content)\n } else if (dataType === 'date') {\n content = content.toISOString()\n }\n\n /*\n * ----------------------------------------\n * MORE MODIFICATIONS FOR JSONP BODY\n * ----------------------------------------\n *\n * If JSONP callback exists, then update the body to be a\n * valid JSONP response\n */\n if (jsonpCallbackName) {\n /*\n * replace chars not allowed in JavaScript that are in JSON\n * https://github.com/rack/rack-contrib/pull/37\n */\n content = content.replace(/\\u2028/g, '\\\\u2028').replace(/\\u2029/g, '\\\\u2029')\n\n // the /**/ is a specific security mitigation for \"Rosetta Flash JSONP abuse\"\n // https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-4671\n // http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/\n // http://drops.wooyun.org/tips/2554\n content = `/**/ typeof ${jsonpCallbackName} === 'function' && ${jsonpCallbackName}(${content});`\n }\n\n /*\n * ----------------------------------------\n * FINALY GENERATE AN ETAG\n * ----------------------------------------\n *\n * Generate etag if instructed.\n */\n if (generateEtag) {\n this.setEtag(content)\n }\n\n /**\n * End response when cache is fresh\n */\n if (generateEtag && this.fresh()) {\n this.removeHeader('Content-Type')\n this.removeHeader('Content-Length')\n this.removeHeader('Transfer-Encoding')\n this.#endResponse(null, ResponseStatus.NotModified)\n return\n }\n\n /*\n * ----------------------------------------\n * SET X-REQUEST-ID HEADER\n * ----------------------------------------\n */\n this.setRequestId()\n\n /*\n * ----------------------------------------\n * SET CONTENT-LENGTH HEADER\n * ----------------------------------------\n */\n this.header('Content-Length', Buffer.byteLength(content))\n\n /**\n * ----------------------------------------\n * SET CONTENT-TYPE HEADER\n * ----------------------------------------\n *\n * - If it is a JSONP response, then we always set the content type\n * to \"text/javascript\"\n *\n * - String are checked for HTML and \"text/plain\" or \"text/html\" is set\n * accordingly.\n *\n * - \"text/plain\" is set for \"numbers\" and \"booleans\" and \"dates\"\n *\n * - \"application/octet-stream\" is set for buffers\n *\n * - \"application/json\" is set for objects and arrays\n */\n if (jsonpCallbackName) {\n this.header('X-Content-Type-Options', 'nosniff')\n this.safeHeader('Content-Type', 'text/javascript; charset=utf-8')\n } else {\n switch (dataType) {\n case 'string':\n const type = /^\\s*</.test(content) ? 'text/html' : 'text/plain'\n this.safeHeader('Content-Type', `${type}; charset=utf-8`)\n break\n case 'number':\n case 'boolean':\n case 'date':\n case 'bigint':\n case 'regexp':\n this.safeHeader('Content-Type', 'text/plain; charset=utf-8')\n break\n case 'buffer':\n this.safeHeader('Content-Type', 'application/octet-stream; charset=utf-8')\n break\n case 'object':\n this.safeHeader('Content-Type', 'application/json; charset=utf-8')\n break\n }\n }\n\n this.#endResponse(content)\n }\n\n /**\n * Stream the body to the response and handles cleaning up the stream\n */\n protected streamBody(\n body: ResponseStream,\n errorCallback?: (error: NodeJS.ErrnoException) => [string, number?]\n ): Promise<void> {\n return new Promise((resolve) => {\n let finished = false\n\n /*\n * Listen for errors on the stream and properly destroy\n * stream\n */\n body.on('error', (error: NodeJS.ErrnoException) => {\n /* c8 ignore next 3 */\n if (finished) {\n return\n }\n\n finished = true\n destroy(body)\n\n this.type('text')\n\n if (!this.headersSent) {\n if (typeof errorCallback === 'function') {\n this.#endResponse(...errorCallback(error))\n } else {\n this.#endResponse(\n error.code === 'ENOENT' ? 'File not found' : 'Cannot process file',\n error.code === 'ENOENT' ? ResponseStatus.NotFound : ResponseStatus.InternalServerError\n )\n }\n } else {\n this.response.destroy()\n }\n\n resolve()\n })\n\n /*\n * Listen for end and resolve the promise\n */\n body.on('end', () => {\n if (!this.headersSent) {\n this.#endResponse()\n }\n resolve()\n })\n\n /*\n * Cleanup stream when finishing response\n */\n onFinished(this.response, () => {\n finished = true\n destroy(body)\n })\n\n /*\n * Pipe stream\n */\n this.relayHeaders()\n body.pipe(this.response)\n })\n }\n\n /**\n * Downloads a file by streaming it to the response\n */\n protected async streamFileForDownload(\n filePath: string,\n generateEtag: boolean,\n errorCallback?: (error: NodeJS.ErrnoException) => [string, number?]\n ) {\n try {\n const stats = await stat(filePath)\n if (!stats || !stats.isFile()) {\n throw new TypeError('response.download only accepts path to a file')\n }\n\n /*\n * Set appropriate headers\n */\n this.header('Last-Modified', stats.mtime.toUTCString())\n this.type(extname(filePath))\n\n /*\n * Set the etag when instructed.\n */\n if (generateEtag) {\n this.setEtag(stats, true)\n }\n\n /*\n * Do not stream files for HEAD request, but set the appropriate\n * status code.\n *\n * 200: When not using etags or cache is not fresh. This forces browser\n * to always make a GET request\n *\n * 304: When etags are used and cache is fresh\n */\n if (this.request.method === 'HEAD') {\n this.#endResponse(\n null,\n generateEtag && this.fresh() ? ResponseStatus.NotModified : ResponseStatus.Ok\n )\n return\n }\n\n /*\n * Regardless of request method, if we are using etags and\n * cache is fresh, then we must respond with 304\n */\n if (generateEtag && this.fresh()) {\n this.#endResponse(null, ResponseStatus.NotModified)\n return\n }\n\n /*\n * Fix for https://tools.ietf.org/html/rfc7232#section-4.1. It is\n * recommended to ignore headers other than Cache-Control,\n * Content-Location, Date, ETag, Expires, and Vary.\n */\n this.header('Content-length', stats.size)\n\n /*\n * Finally stream the file\n */\n return this.streamBody(createReadStream(filePath), errorCallback)\n } catch (error) {\n this.type('text')\n this.removeHeader('Etag')\n\n if (typeof errorCallback === 'function') {\n this.#endResponse(...errorCallback(error))\n } else {\n this.#endResponse(\n error.code === 'ENOENT' ? 'File not found' : 'Cannot process file',\n error.code === 'ENOENT' ? ResponseStatus.NotFound : ResponseStatus.InternalServerError\n )\n }\n }\n }\n\n /**\n * Listen for the event the response is written\n * to the TCP socket.\n *\n * Under the hood the callback is registered with\n * the \"https://github.com/jshttp/on-finished\" package\n */\n onFinish(callback: (err: Error | null, response: ServerResponse) => void) {\n onFinished(this.response, callback)\n }\n\n /**\n * Writes headers with the Node.js res object using the\n * response.setHeader method\n */\n relayHeaders() {\n if (!this.headersSent) {\n for (let key in this.#headers) {\n const value = this.#headers[key]\n if (value) {\n this.response.setHeader(key, value)\n }\n }\n }\n }\n\n /**\n * Calls res.writeHead on the Node.js res object.\n */\n writeHead(statusCode?: number): this {\n this.response.writeHead(statusCode || this.response.statusCode, this.#headers)\n return this\n }\n\n /**\n * Returns the existing value for a given HTTP response\n * header.\n */\n getHeader(key: string) {\n const value = this.#headers[key.toLowerCase()]\n return value === undefined ? this.response.getHeader(key) : value\n }\n\n /**\n * Get response headers\n */\n getHeaders() {\n return {\n ...this.response.getHeaders(),\n ...this.#headers,\n }\n }\n\n /**\n * Set header on the response. To `append` values to the existing header, we suggest\n * using [[append]] method.\n *\n * If `value` is non existy, then header won't be set.\n *\n * @example\n * ```js\n * response.header('content-type', 'application/json')\n * ```\n */\n header(key: string, value: CastableHeader): this {\n if (value === null || value === undefined) {\n return this\n }\n\n this.#headers[key.toLowerCase()] = this.#castHeaderValue(value)\n return this\n }\n\n /**\n * Append value to an existing header. To replace the value, we suggest using\n * [[header]] method.\n *\n * If `value` is not existy, then header won't be set.\n *\n * @example\n * ```js\n * response.append('set-cookie', 'username=virk')\n * ```\n */\n append(key: string, value: CastableHeader): this {\n if (value === null || value === undefined) {\n return this\n }\n\n key = key.toLowerCase()\n\n let existingHeader = this.getHeader(key)\n let casted = this.#castHeaderValue(value)\n\n /**\n * If there isn't any header, then setHeader right\n * away\n */\n if (!existingHeader) {\n this.#headers[key] = casted\n return this\n }\n\n existingHeader = this.#castHeaderValue(existingHeader)\n casted = Array.isArray(existingHeader)\n ? existingHeader.concat(casted)\n : [existingHeader].concat(casted)\n\n this.#headers[key] = casted\n return this\n }\n\n /**\n * Adds HTTP response header, when it doesn't exists already.\n */\n safeHeader(key: string, value: CastableHeader): this {\n if (!this.getHeader(key)) {\n this.header(key, value)\n }\n return this\n }\n\n /**\n * Removes the existing response header from being sent.\n */\n removeHeader(key: string): this {\n key = key.toLowerCase()\n\n this.response.removeHeader(key)\n if (this.#headers[key]) {\n delete this.#headers[key.toLowerCase()]\n }\n\n return this\n }\n\n /**\n * Returns the status code for the response\n */\n getStatus(): number {\n return this.response.statusCode\n }\n\n /**\n * Set HTTP status code\n */\n status(code: number): this {\n this.#hasExplicitStatus = true\n this.response.statusCode = code\n return this\n }\n\n /**\n * Set's status code only when it's not explictly\n * set\n */\n safeStatus(code: number): this {\n if (this.#hasExplicitStatus) {\n return this\n }\n\n this.response.statusCode = code\n return this\n }\n\n /**\n * Set response type by looking up for the mime-type using\n * partial types like file extensions.\n *\n * Make sure to read [mime-types](https://www.npmjs.com/package/mime-types) docs\n * too.\n *\n * @example\n * ```js\n * response.type('.json') // Content-type: application/json\n * ```\n */\n type(type: string, charset?: string): this {\n type = charset ? `${type}; charset=${charset}` : type\n this.header('Content-Type', mime.contentType(type))\n\n return this\n }\n\n /**\n * Set the Vary HTTP header\n */\n vary(field: string | string[]): this {\n vary(this.response, field)\n return this\n }\n\n /**\n * Set etag by computing hash from the body. This class will set the etag automatically\n * when `etag = true` in the defined config object.\n *\n * Use this function, when you want to compute etag manually for some other resons.\n */\n setEtag(body: any, weak: boolean = false): this {\n this.header('Etag', etag(body, { weak }))\n return this\n }\n\n /**\n * Set X-Request-Id header by copying the header value from the request if it exists.\n *\n */\n setRequestId(): this {\n const requestId = this.request.headers['x-request-id']\n if (requestId) {\n this.header('X-Request-Id', requestId)\n }\n return this\n }\n\n /**\n * Returns a boolean telling if the new response etag evaluates same\n * as the request header `if-none-match`. In case of `true`, the\n * server must return `304` response, telling the browser to\n * use the client cache.\n *\n * You won't have to deal with this method directly, since AdonisJs will\n * handle this for you when `http.etag = true` inside `config/app.js` file.\n *\n * However, this is how you can use it manually.\n *\n * @example\n * ```js\n * const responseBody = view.render('some-view')\n *\n * // sets the HTTP etag header for response\n * response.setEtag(responseBody)\n *\n * if (response.fresh()) {\n * response.sendStatus(304)\n * } else {\n * response.send(responseBody)\n * }\n * ```\n */\n fresh(): boolean {\n if (this.request.method && !CACHEABLE_HTTP_METHODS.includes(this.request.method)) {\n return false\n }\n\n const status = this.response.statusCode\n if (\n (status >= ResponseStatus.Ok && status < ResponseStatus.MultipleChoices) ||\n status === ResponseStatus.NotModified\n ) {\n return fresh(this.request.headers, this.#headers)\n }\n\n return false\n }\n\n /**\n * Returns the response body. Returns null when response\n * body is a stream\n */\n getBody() {\n if (this.lazyBody.content) {\n return this.lazyBody.content[0]\n }\n\n return null\n }\n\n /**\n * Send the body as response and optionally generate etag. The default value\n * is read from `config/app.js` file, using `http.etag` property.\n *\n * This method buffers the body if `explicitEnd = true`, which is the default\n * behavior and do not change, unless you know what you are doing.\n */\n send(body: any, generateEtag: boolean = this.#config.etag): void {\n this.lazyBody.content = [body, generateEtag]\n }\n\n /**\n * Alias of [[send]]\n */\n json(body: any, generateEtag: boolean = this.#config.etag): void {\n return this.send(body, generateEtag)\n }\n\n /**\n * Writes response as JSONP. The callback name is resolved as follows, with priority\n * from top to bottom.\n *\n * 1. Explicitly defined as 2nd Param.\n * 2. Fetch from request query string.\n * 3. Use the config value `http.jsonpCallbackName` from `config/app.js`.\n * 4. Fallback to `callback`.\n *\n * This method buffers the body if `explicitEnd = true`, which is the default\n * behavior and do not change, unless you know what you are doing.\n */\n jsonp(\n body: any,\n callbackName: string = this.#config.jsonpCallbackName,\n generateEtag: boolean = this.#config.etag\n ) {\n this.lazyBody.content = [body, generateEtag, callbackName]\n }\n\n /**\n * Pipe stream to the response. This method will gracefully destroy\n * the stream, avoiding memory leaks.\n *\n * If `raiseErrors=false`, then this method will self handle all the exceptions by\n * writing a generic HTTP response. To have more control over the error, it is\n * recommended to set `raiseErrors=true` and wrap this function inside a\n * `try/catch` statement.\n *\n * Streaming a file from the disk and showing 404 when file is missing.\n *\n * @example\n * ```js\n * // Errors handled automatically with generic HTTP response\n * response.stream(fs.createReadStream('file.txt'))\n *\n * // Manually handle (note the await call)\n * try {\n * await response.stream(fs.createReadStream('file.txt'))\n * } catch () {\n * response.status(404).send('File not found')\n * }\n * ```\n */\n stream(\n body: ResponseStream,\n errorCallback?: (error: NodeJS.ErrnoException) => [string, number?]\n ): void {\n if (typeof body.pipe !== 'function' || !body.readable || typeof body.read !== 'function') {\n throw new TypeError('response.stream accepts a readable stream only')\n }\n\n this.lazyBody.stream = [body, errorCallback]\n }\n\n /**\n * Download file by streaming it from the file path. This method will setup\n * appropriate `Content-type`, `Content-type` and `Last-modified` headers.\n *\n * Unexpected stream errors are handled gracefully to avoid memory leaks.\n *\n * If `raiseErrors=false`, then this method will self handle all the exceptions by\n * writing a generic HTTP response. To have more control over the error, it is\n * recommended to set `raiseErrors=true` and wrap this function inside a\n * `try/catch` statement.\n *\n * @example\n * ```js\n * // Errors handled automatically with generic HTTP response\n * response.download('somefile.jpg')\n *\n * // Manually handle (note the await call)\n * try {\n * await response.download('somefile.jpg')\n * } catch (error) {\n * response.status(error.code === 'ENOENT' ? 404 : 500)\n * response.send('Cannot process file')\n * }\n * ```\n */\n download(\n filePath: string,\n generateEtag: boolean = this.#config.etag,\n errorCallback?: (error: NodeJS.ErrnoException) => [string, number?]\n ): void {\n this.lazyBody.fileToStream = [filePath, generateEtag, errorCallback]\n }\n\n /**\n * Download the file by forcing the user to save the file vs displaying it\n * within the browser.\n *\n * Internally calls [[download]]\n */\n attachment(\n filePath: string,\n name?: string,\n disposition?: string,\n generateEtag?: boolean,\n errorCallback?: (error: NodeJS.ErrnoException) => [string, number?]\n ) {\n name = name || filePath\n this.header('Content-Disposition', contentDisposition(name, { type: disposition }))\n return this.download(filePath, generateEtag, errorCallback)\n }\n\n /**\n * Set the location header.\n *\n * @example\n * ```js\n * response.location('/login')\n * ```\n */\n location(url: string): this {\n this.header('Location', url)\n return this\n }\n\n /**\n * Redirect the request.\n *\n * @example\n * ```js\n * response.redirect('/foo')\n * response.redirect().toRoute('foo.bar')\n * response.redirect().back()\n * ```\n */\n redirect(): Redirect\n redirect(path: string, forwardQueryString?: boolean, statusCode?: number): void\n redirect(\n path?: string,\n forwardQueryString: boolean = false,\n statusCode: number = ResponseStatus.Found\n ): Redirect | void {\n const handler = new Redirect(this.request, this, this.#router, this.#qs)\n\n if (forwardQueryString) {\n handler.withQs()\n }\n\n if (path === 'back') {\n return handler.status(statusCode).back()\n }\n\n if (path) {\n return handler.status(statusCode).toPath(path)\n }\n\n return handler\n }\n\n /**\n * Abort the request with custom body and a status code. 400 is\n * used when status is not defined\n */\n abort(body: any, status?: number): never {\n throw E_HTTP_REQUEST_ABORTED.invoke(body, status || ResponseStatus.BadRequest)\n }\n\n /**\n * Abort the request with custom body and a status code when\n * passed condition returns `true`\n */\n abortIf(\n condition: unknown,\n body: any,\n status?: number\n ): asserts condition is undefined | null | false {\n if (condition) {\n this.abort(body, status)\n }\n }\n\n /**\n * Abort the request with custom body and a status code when\n * passed condition returns `false`\n */\n abortUnless<T>(\n condition: T,\n body: any,\n status?: number\n ): asserts condition is Exclude<T, undefined | null | false> {\n if (!condition) {\n this.abort(body, status)\n }\n }\n\n /**\n * Set signed cookie as the response header. The inline options overrides\n * all options from the config.\n */\n cookie(key: string, value: any, options?: Partial<CookieOptions>): this {\n options = Object.assign({}, this.#config.cookie, options)\n\n const serialized = this.#cookieSerializer.sign(key, value, options)\n if (!serialized) {\n return this\n }\n\n this.append('set-cookie', serialized)\n return this\n }\n\n /**\n * Set encrypted cookie as the response header. The inline options overrides\n * all options from the config.\n */\n encryptedCookie(key: string, value: any, options?: Partial<CookieOptions>): this {\n options = Object.assign({}, this.#config.cookie, options)\n\n const serialized = this.#cookieSerializer.encrypt(key, value, options)\n if (!serialized) {\n return this\n }\n\n this.append('set-cookie', serialized)\n return this\n }\n\n /**\n * Set unsigned cookie as the response header. The inline options overrides\n * all options from the config.\n */\n plainCookie(\n key: string,\n value: any,\n options?: Partial<CookieOptions & { encode: boolean }>\n ): this {\n options = Object.assign({}, this.#config.cookie, options)\n\n const serialized = this.#cookieSerializer.encode(key, value, options)\n if (!serialized) {\n return this\n }\n\n this.append('set-cookie', serialized)\n return this\n }\n\n /**\n * Clear existing cookie.\n */\n clearCookie(key: string, options?: Partial<CookieOptions>): this {\n options = Object.assign({}, this.#config.cookie, options)\n options.expires = new Date(1)\n options.maxAge = -1\n\n const serialized = this.#cookieSerializer.encode(key, '', { ...options, encode: false })\n this.append('set-cookie', serialized!)\n return this\n }\n\n /**\n * Finishes the response by writing the lazy body, when `explicitEnd = true`\n * and response is already pending.\n *\n * Calling this method twice or when `explicitEnd = false` is noop.\n */\n finish() {\n if (!this.isPending) {\n return\n }\n\n if (this.content) {\n this.writeBody(...this.content)\n return\n }\n\n if (this.lazyBody.stream) {\n this.streamBody(...this.lazyBody.stream)\n return\n }\n\n if (this.lazyBody.fileToStream) {\n this.streamFileForDownload(...this.lazyBody.fileToStream)\n return\n }\n\n this.#endResponse()\n }\n\n /**\n * Shorthand method to finish request with \"100\" status code\n */\n continue(): void {\n this.status(ResponseStatus.Continue)\n return this.send(null, false)\n }\n\n /**\n * Shorthand method to finish request with \"101\" status code\n */\n switchingProtocols(): void {\n this.status(ResponseStatus.SwitchingProtocols)\n return this.send(null, false)\n }\n\n /**\n * Shorthand method to finish request with \"200\" status code\n */\n ok(body: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.Ok)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"201\" status code\n */\n created(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.Created)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"202\" status code\n */\n accepted(body: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.Accepted)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"203\" status code\n */\n nonAuthoritativeInformation(body: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.NonAuthoritativeInformation)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"204\" status code\n */\n noContent(): void {\n this.status(ResponseStatus.NoContent)\n return this.send(null, false)\n }\n\n /**\n * Shorthand method to finish request with \"205\" status code\n */\n resetContent(): void {\n this.status(ResponseStatus.ResetContent)\n return this.send(null, false)\n }\n\n /**\n * Shorthand method to finish request with \"206\" status code\n */\n partialContent(body: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.PartialContent)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"300\" status code\n */\n multipleChoices(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.MultipleChoices)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"301\" status code\n */\n movedPermanently(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.MovedPermanently)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"302\" status code\n */\n movedTemporarily(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.Found)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"303\" status code\n */\n seeOther(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.SeeOther)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"304\" status code\n */\n notModified(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.NotModified)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"305\" status code\n */\n useProxy(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.UseProxy)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"307\" status code\n */\n temporaryRedirect(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.TemporaryRedirect)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"400\" status code\n */\n badRequest(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.BadRequest)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"401\" status code\n */\n unauthorized(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.Unauthorized)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"402\" status code\n */\n paymentRequired(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.PaymentRequired)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"403\" status code\n */\n forbidden(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.Forbidden)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"404\" status code\n */\n notFound(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.NotFound)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"405\" status code\n */\n methodNotAllowed(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.MethodNotAllowed)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"406\" status code\n */\n notAcceptable(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.NotAcceptable)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"407\" status code\n */\n proxyAuthenticationRequired(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.ProxyAuthenticationRequired)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"408\" status code\n */\n requestTimeout(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.RequestTimeout)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"409\" status code\n */\n conflict(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.Conflict)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"401\" status code\n */\n gone(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.Gone)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"411\" status code\n */\n lengthRequired(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.LengthRequired)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"412\" status code\n */\n preconditionFailed(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.PreconditionFailed)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"413\" status code\n */\n requestEntityTooLarge(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.PayloadTooLarge)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"414\" status code\n */\n requestUriTooLong(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.URITooLong)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"415\" status code\n */\n unsupportedMediaType(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.UnsupportedMediaType)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"416\" status code\n */\n requestedRangeNotSatisfiable(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.RangeNotSatisfiable)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"417\" status code\n */\n expectationFailed(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.ExpectationFailed)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"422\" status code\n */\n unprocessableEntity(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.UnprocessableEntity)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"429\" status code\n */\n tooManyRequests(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.TooManyRequests)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"500\" status code\n */\n internalServerError(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.InternalServerError)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"501\" status code\n */\n notImplemented(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.NotImplemented)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"502\" status code\n */\n badGateway(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.BadGateway)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"503\" status code\n */\n serviceUnavailable(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.ServiceUnavailable)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"504\" status code\n */\n gatewayTimeout(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.GatewayTimeout)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"505\" status code\n */\n httpVersionNotSupported(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.HTTPVersionNotSupported)\n return this.send(body, generateEtag)\n }\n}\n","/*\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 cookie from 'cookie'\nimport string from '@poppinss/utils/string'\nimport type { Encryption } from '@adonisjs/encryption'\n\nimport { CookieClient } from './client.js'\nimport type { CookieOptions } from '../types/response.js'\n\n/**\n * Cookies serializer is used to serialize a value to be set on the `Set-Cookie`\n * header. You can `encode`, `sign` on `encrypt` cookies using the serializer\n * and then set them individually using the `set-cookie` header.\n */\nexport class CookieSerializer {\n #client: CookieClient\n\n constructor(encryption: Encryption) {\n this.#client = new CookieClient(encryption)\n }\n\n /**\n * Serializes the key-value pair to a string, that can be set on the\n * `Set-Cookie` header.\n */\n #serializeAsCookie(key: string, value: string, options?: Partial<CookieOptions>) {\n /**\n * Invoked expires method to get the date\n */\n let expires = options?.expires\n if (typeof expires === 'function') {\n expires = expires()\n }\n\n /**\n * Parse string based max age to seconds\n */\n let maxAge = options?.maxAge ? string.seconds.parse(options?.maxAge) : undefined\n\n const parsedOptions = Object.assign({}, options, { maxAge, expires })\n return cookie.serialize(key, value, parsedOptions)\n }\n\n /**\n * Encodes value as a plain cookie. By default, the plain value will be converted\n * to a string using \"JSON.stringify\" method and then encoded as a base64 string.\n *\n * You can disable encoding of the cookie by setting `options.encoded = false`.\n *\n * ```ts\n * serializer.encode('name', 'virk')\n * ```\n */\n encode(\n key: string,\n value: any,\n options?: Partial<CookieOptions & { encode: boolean }>\n ): string | null {\n const packedValue = options?.encode === false ? value : this.#client.encode(key, value)\n if (packedValue === null || packedValue === undefined) {\n return null\n }\n\n return this.#serializeAsCookie(key, packedValue, options)\n }\n\n /**\n * Sign a key-value pair to a signed cookie. The signed value has a\n * verification hash attached to it to detect data tampering.\n */\n sign(key: string, value: any, options?: Partial<CookieOptions>): string | null {\n const packedValue = this.#client.sign(key, value)\n if (packedValue === null) {\n return null\n }\n\n return this.#serializeAsCookie(key, packedValue, options)\n }\n\n /**\n * Encrypts a key-value pair to an encrypted cookie.\n */\n encrypt(key: string, value: any, options?: Partial<CookieOptions>): string | null {\n const packedValue = this.#client.encrypt(key, value)\n if (packedValue === null) {\n return null\n }\n\n return this.#serializeAsCookie(key, packedValue, options)\n }\n}\n","/*\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 { moduleImporter } from '@adonisjs/fold'\nimport { RuntimeException } from '@poppinss/utils'\nimport type { Encryption } from '@adonisjs/encryption'\nimport type { Application } from '@adonisjs/application'\n\nimport type { Qs } from '../qs.js'\nimport { Route } from './route.js'\nimport { RouteGroup } from './group.js'\nimport { BriskRoute } from './brisk.js'\nimport { RoutesStore } from './store.js'\nimport { toRoutesJSON } from '../helpers.js'\nimport { RouteResource } from './resource.js'\nimport { LookupStore } from './lookup_store/main.js'\nimport { RouteMatchers as Matchers } from './matchers.js'\nimport type { Constructor, LazyImport } from '../types/base.js'\nimport { defineNamedMiddleware } from '../define_middleware.js'\nimport type { MiddlewareAsClass, ParsedGlobalMiddleware } from '../types/middleware.js'\n\nimport type {\n RouteFn,\n MatchedRoute,\n RouteMatcher,\n RouteMatchers,\n MakeUrlOptions,\n MakeSignedUrlOptions,\n GetControllerHandlers,\n} from '../types/route.js'\nimport debug from '../debug.js'\nimport { parseRoutePattern } from './parser.js'\n\n/**\n * Router class exposes a unified API to register new routes, group them or\n * create route resources.\n *\n * ```ts\n * const router = new Router()\n *\n * router.get('/', async function () {\n * // handle request\n * })\n * ```\n */\nexport class Router extends LookupStore {\n #commited: boolean = false\n\n /**\n * Application is needed to resolve string based controller expressions\n */\n #app: Application<any>\n\n /**\n * Store with tokenized routes\n */\n #store: RoutesStore = new RoutesStore()\n\n /**\n * Global matchers to test route params against regular expressions.\n */\n #globalMatchers: RouteMatchers = {}\n\n /**\n * Middleware store to be shared with the routes\n */\n #middleware: ParsedGlobalMiddleware[] = []\n\n /**\n * A boolean to tell the router that a group is in\n * open state right now\n */\n #openedGroups: RouteGroup[] = []\n\n /**\n * Collection of routes, including route resource and route\n * group. To get a flat list of routes, call `router.toJSON()`\n */\n routes: (Route | RouteResource | RouteGroup | BriskRoute)[] = []\n\n /**\n * A flag to know if routes for explicit domains have been registered.\n * The boolean is computed after calling the \"commit\" method.\n */\n usingDomains: boolean = false\n\n /**\n * Shortcut methods for commonly used route matchers\n */\n matchers = new Matchers()\n\n /**\n * Check if routes have been committed to the store. Once\n * routes are committed, defining new set of routes will\n * have no impact\n */\n get commited() {\n return this.#commited\n }\n\n constructor(app: Application<any>, encryption: Encryption, qsParser: Qs) {\n super(encryption, qsParser)\n this.#app = app\n }\n\n /**\n * Push a give router entity to the list of routes or the\n * recently opened group.\n */\n #pushToRoutes(entity: Route | RouteResource | RouteGroup | BriskRoute) {\n const openedGroup = this.#openedGroups[this.#openedGroups.length - 1]\n if (openedGroup) {\n openedGroup.routes.push(entity)\n return\n }\n\n this.routes.push(entity)\n }\n\n /**\n * Parses the route pattern\n */\n parsePattern(pattern: string, matchers?: RouteMatchers) {\n return parseRoutePattern(pattern, matchers)\n }\n\n /**\n * Define an array of middleware to use on all the routes.\n * Calling this method multiple times pushes to the\n * existing list of middleware\n */\n use(middleware: LazyImport<MiddlewareAsClass>[]): this {\n middleware.forEach((one) =>\n this.#middleware.push(moduleImporter(one, 'handle').toHandleMethod())\n )\n\n return this\n }\n\n /**\n * Define a collection of named middleware. The defined collection is\n * not registered anywhere, but instead converted in a new collection\n * of functions you can apply on the routes, or router groups.\n */\n named<NamedMiddleware extends Record<string, LazyImport<MiddlewareAsClass>>>(\n collection: NamedMiddleware\n ) {\n return defineNamedMiddleware<NamedMiddleware>(collection)\n }\n\n /**\n * Add route for a given pattern and methods\n */\n route<T extends Constructor<any>>(\n pattern: string,\n methods: string[],\n handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]\n ) {\n const route = new Route(this.#app, this.#middleware, {\n pattern,\n methods,\n handler,\n globalMatchers: this.#globalMatchers,\n })\n\n this.#pushToRoutes(route)\n return route\n }\n\n /**\n * Define a route that handles all common HTTP methods\n */\n any<T extends Constructor<any>>(\n pattern: string,\n handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]\n ) {\n return this.route(\n pattern,\n ['HEAD', 'OPTIONS', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE'],\n handler\n )\n }\n\n /**\n * Define `GET` route\n */\n get<T extends Constructor<any>>(\n pattern: string,\n handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]\n ) {\n return this.route(pattern, ['GET', 'HEAD'], handler)\n }\n\n /**\n * Define `POST` route\n */\n post<T extends Constructor<any>>(\n pattern: string,\n handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]\n ) {\n return this.route(pattern, ['POST'], handler)\n }\n\n /**\n * Define `PUT` route\n */\n put<T extends Constructor<any>>(\n pattern: string,\n handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]\n ) {\n return this.route(pattern, ['PUT'], handler)\n }\n\n /**\n * Define `PATCH` route\n */\n patch<T extends Constructor<any>>(\n pattern: string,\n handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]\n ) {\n return this.route(pattern, ['PATCH'], handler)\n }\n\n /**\n * Define `DELETE` route\n */\n delete<T extends Constructor<any>>(\n pattern: string,\n handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]\n ) {\n return this.route(pattern, ['DELETE'], handler)\n }\n\n /**\n * Creates a group of routes. A route group can apply transforms\n * to routes in bulk\n */\n group(callback: () => void) {\n /*\n * Create a new group with empty set of routes\n */\n const group = new RouteGroup([])\n\n /**\n * Track group\n */\n this.#pushToRoutes(group)\n\n /*\n * Track the group, so that the upcoming calls inside the callback\n * can use this group\n */\n this.#openedGroups.push(group)\n\n /*\n * Execute the callback. Now all registered routes will be\n * collected seperately from the `routes` array\n */\n callback()\n\n /*\n * Now the callback is over, get rid of the opened group\n */\n this.#openedGroups.pop()\n\n return group\n }\n\n /**\n * Registers a route resource with conventional set of routes\n */\n resource(resource: string, controller: string | LazyImport<Constructor<any>> | Constructor<any>) {\n const resourceInstance = new RouteResource(this.#app, this.#middleware, {\n resource,\n controller,\n shallow: false,\n globalMatchers: this.#globalMatchers,\n })\n\n this.#pushToRoutes(resourceInstance)\n return resourceInstance\n }\n\n /**\n * Register a route resource with shallow nested routes.\n */\n shallowResource(\n resource: string,\n controller: string | LazyImport<Constructor<any>> | Constructor<any>\n ) {\n const resourceInstance = new RouteResource(this.#app, this.#middleware, {\n resource,\n controller,\n shallow: true,\n globalMatchers: this.#globalMatchers,\n })\n\n this.#pushToRoutes(resourceInstance)\n return resourceInstance\n }\n\n /**\n * Returns a brisk route instance for a given URL pattern\n */\n on(pattern: string) {\n const briskRoute = new BriskRoute(this.#app, this.#middleware, {\n pattern,\n globalMatchers: this.#globalMatchers,\n })\n\n this.#pushToRoutes(briskRoute)\n return briskRoute\n }\n\n /**\n * Define matcher for a given param. The global params are applied\n * on all the routes (unless overridden at the route level).\n */\n where(param: string, matcher: RouteMatcher | string | RegExp): this {\n if (typeof matcher === 'string') {\n this.#globalMatchers[param] = { match: new RegExp(matcher) }\n } else if (is.regExp(matcher)) {\n this.#globalMatchers[param] = { match: matcher }\n } else {\n this.#globalMatchers[param] = matcher\n }\n\n return this\n }\n\n /**\n * Commit routes to the store. The router is freezed after the\n * commit method is called.\n */\n commit() {\n if (this.#commited) {\n return\n }\n\n debug('Committing routes to the routes store')\n const routeNamesByDomain: Map<string, Set<string>> = new Map()\n\n toRoutesJSON(this.routes).forEach((route) => {\n if (!routeNamesByDomain.has(route.domain)) {\n routeNamesByDomain.set(route.domain, new Set())\n }\n\n const routeNames = routeNamesByDomain.get(route.domain)!\n\n /*\n * Raise error when route name is already in use. Route names have to be unique\n * to ensure that only one route is returned during lookup.\n */\n if (route.name && routeNames.has(route.name)) {\n throw new RuntimeException(\n `Route with duplicate name found. A route with name \"${route.name}\" already exists`\n )\n }\n\n /*\n * If route has a unique, then track the name for checking duplicates\n */\n if (route.name) {\n routeNames.add(route.name)\n }\n\n /**\n * Register the route with the lookup store\n */\n this.register(route)\n this.#store.add(route)\n })\n\n routeNamesByDomain.clear()\n\n this.usingDomains = this.#store.usingDomains\n this.routes = []\n this.#globalMatchers = {}\n this.#middleware = []\n this.#commited = true\n }\n\n /**\n * Find route for a given URL, method and optionally domain\n */\n match(url: string, method: string, hostname?: string | null): null | MatchedRoute {\n const matchingDomain = this.#store.matchDomain(hostname)\n\n return matchingDomain.length\n ? this.#store.match(url, method, {\n tokens: matchingDomain,\n hostname: hostname!,\n })\n : this.#store.match(url, method)\n }\n\n /**\n * Make URL to a pre-registered route\n */\n makeUrl(\n routeIdentifier: string,\n params?: any[] | Record<string, any>,\n options?: MakeUrlOptions\n ): string {\n const normalizedOptions = Object.assign({}, options)\n\n const builder = normalizedOptions.domain\n ? this.builderForDomain(normalizedOptions.domain)\n : this.builder()\n\n builder.params(params)\n builder.qs(normalizedOptions.qs)\n\n normalizedOptions.prefixUrl && builder.prefixUrl(normalizedOptions.prefixUrl)\n normalizedOptions.disableRouteLookup && builder.disableRouteLookup()\n\n return builder.make(routeIdentifier)\n }\n\n /**\n * Makes a signed URL to a pre-registered route.\n */\n makeSignedUrl(\n routeIdentifier: string,\n params?: any[] | Record<string, any>,\n options?: MakeSignedUrlOptions\n ): string {\n const normalizedOptions = Object.assign({}, options)\n\n const builder = normalizedOptions.domain\n ? this.builderForDomain(normalizedOptions.domain)\n : this.builder()\n\n builder.params(params)\n builder.qs(normalizedOptions.qs)\n\n normalizedOptions.prefixUrl && builder.prefixUrl(normalizedOptions.prefixUrl)\n normalizedOptions.disableRouteLookup && builder.disableRouteLookup()\n\n return builder.makeSigned(routeIdentifier, normalizedOptions)\n }\n}\n","/*\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\n// @ts-expect-error\nimport matchit from '@poppinss/matchit'\nimport lodash from '@poppinss/utils/lodash'\nimport { RuntimeException } from '@poppinss/utils'\nimport type {\n RouteJSON,\n MatchedRoute,\n StoreRouteNode,\n StoreDomainNode,\n StoreMethodNode,\n StoreRoutesTree,\n MatchItRouteToken,\n} from '../types/route.js'\nimport { parseRoutePattern } from './parser.js'\nimport debug from '../debug.js'\n\n/**\n * Store class is used to store a list of routes, along side with their tokens\n * to match the URLs.\n *\n * ```ts\n * const store = new Store()\n *\n * store.add({\n * pattern: 'posts/:id',\n * handler: function onRoute () {},\n * middleware: [],\n * matchers: {\n * id: '^[0-9]$+'\n * },\n * meta: {},\n * methods: ['GET']\n * })\n *\n * store.match('posts/1', 'GET')\n * ```\n */\nexport class RoutesStore {\n /**\n * A flag to know if routes for explicit domains\n * have been registered\n */\n usingDomains: boolean = false\n\n /**\n * Tree of registered routes and their matchit tokens\n */\n tree: StoreRoutesTree = { tokens: [], domains: {} }\n\n /**\n * Returns the domain node for a given domain.\n */\n #getDomainNode(domain: string): StoreDomainNode {\n if (!this.tree.domains[domain]) {\n this.tree.tokens.push(parseRoutePattern(domain))\n this.tree.domains[domain] = {}\n }\n\n return this.tree.domains[domain]\n }\n\n /**\n * Returns the method node for a given domain and method.\n */\n #getMethodNode(domain: string, method: string): StoreMethodNode {\n const domainNode = this.#getDomainNode(domain)\n if (!domainNode[method]) {\n domainNode[method] = { tokens: [], routes: {}, routeKeys: {} }\n }\n\n return domainNode[method]\n }\n\n /**\n * Collects route params\n */\n #collectRouteParams(route: StoreRouteNode, tokens: MatchItRouteToken[]) {\n const collectedParams: Set<string> = new Set()\n\n for (let token of tokens) {\n if ([1, 3].includes(token.type)) {\n if (collectedParams.has(token.val)) {\n throw new RuntimeException(`Duplicate param \"${token.val}\" found in \"${route.pattern}\"`)\n } else {\n collectedParams.add(token.val)\n }\n }\n }\n\n const params = [...collectedParams]\n collectedParams.clear()\n\n return params\n }\n\n /**\n * Register route for a given domain and method\n */\n #registerRoute(\n domain: string,\n method: string,\n tokens: MatchItRouteToken[],\n route: StoreRouteNode\n ) {\n const methodRoutes = this.#getMethodNode(domain, method)\n\n /*\n * Check for duplicate route for the same domain and method\n */\n if (methodRoutes.routes[route.pattern]) {\n throw new RuntimeException(\n `Duplicate route found. \"${method}: ${route.pattern}\" route already exists`\n )\n }\n\n if (debug.enabled) {\n debug('registering route to the store %O', route)\n debug('route middleware %O', route.middleware.all().entries())\n }\n\n methodRoutes.tokens.push(tokens)\n methodRoutes.routes[route.pattern] = route\n methodRoutes.routeKeys[route.pattern] =\n domain !== 'root' ? `${domain}-${method}-${route.pattern}` : `${method}-${route.pattern}`\n }\n\n /**\n * Add a route to the store\n *\n * ```ts\n * store.add({\n * pattern: 'post/:id',\n * methods: ['GET'],\n * matchers: {},\n * meta: {},\n * handler: function handler () {\n * }\n * })\n * ```\n */\n add(route: RouteJSON): this {\n /**\n * Set flag when a custom domain is used\n */\n if (route.domain !== 'root') {\n this.usingDomains = true\n }\n\n /**\n * Generate tokens for the route\n */\n const tokens = parseRoutePattern(route.pattern, route.matchers)\n\n /**\n * Create route node object for persistence\n */\n const routeNode: StoreRouteNode = lodash.merge(\n { meta: {} },\n lodash.pick(route, ['pattern', 'handler', 'meta', 'middleware', 'name', 'execute'])\n )\n\n /**\n * Set route params\n */\n routeNode.meta.params = this.#collectRouteParams(routeNode, tokens)\n\n /**\n * Register route for every method\n */\n route.methods.forEach((method) => {\n this.#registerRoute(route.domain, method, tokens, routeNode)\n })\n\n return this\n }\n\n /**\n * Matches the url, method and optionally domain to pull the matching\n * route. `null` is returned when unable to match the URL against\n * registered routes.\n *\n * The domain parameter has to be a registered pattern and not the fully\n * qualified runtime domain. You must call `matchDomain` first to fetch\n * the pattern for qualified domain\n */\n match(\n url: string,\n method: string,\n domain?: { tokens: MatchItRouteToken[]; hostname: string }\n ): null | MatchedRoute {\n const domainName = domain?.tokens[0]?.old || 'root'\n\n const matchedDomain = this.tree.domains[domainName]\n if (!matchedDomain) {\n return null\n }\n\n /*\n * Next get the method node for the given method inside the domain. If\n * method node is missing, means no routes ever got registered for that\n * method\n */\n const matchedMethod = this.tree.domains[domainName][method]\n if (!matchedMethod) {\n return null\n }\n\n /*\n * Next, match route for the given url inside the tokens list for the\n * matchedMethod\n */\n const matchedRoute = matchit.match(url, matchedMethod.tokens)\n if (!matchedRoute.length) {\n return null\n }\n\n const route = matchedMethod.routes[matchedRoute[0].old]\n return {\n route: route,\n routeKey: matchedMethod.routeKeys[route.pattern],\n params: matchit.exec(url, matchedRoute),\n subdomains: domain?.hostname ? matchit.exec(domain.hostname, domain.tokens) : {},\n }\n }\n\n /**\n * Match hostname against registered domains.\n */\n matchDomain(hostname?: string | null): MatchItRouteToken[] {\n if (!hostname || !this.usingDomains) {\n return []\n }\n\n return matchit.match(hostname, this.tree.tokens)\n }\n}\n","/*\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\n// @ts-expect-error\nimport matchit from '@poppinss/matchit'\nimport { MatchItRouteToken, RouteMatchers } from '../types/route.js'\n\n/**\n * Parses the route pattern\n */\nexport function parseRoutePattern(pattern: string, matchers?: RouteMatchers): MatchItRouteToken[] {\n const tokens = matchit.parse(pattern, matchers)\n return tokens\n}\n","/*\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 Macroable from '@poppinss/macroable'\nimport type { Encryption } from '@adonisjs/encryption'\n\nimport type { Qs } from '../../qs.js'\nimport { UrlBuilder } from './url_builder.js'\nimport { RouteFinder } from './route_finder.js'\nimport type { RouteJSON } from '../../types/route.js'\nimport { E_CANNOT_LOOKUP_ROUTE } from '../../exceptions.js'\n\n/**\n * Lookup store exposes the API to lookup routes and\n * make URLs for registered routes.\n */\nexport class LookupStore extends Macroable {\n /**\n * List of route finders grouped by domains\n */\n #routes: { [domain: string]: RouteFinder } = {}\n\n /**\n * Encryption for making URLs\n */\n #encryption: Encryption\n\n /**\n * Query string parser for making URLs\n */\n #qsParser: Qs\n\n constructor(encryption: Encryption, qsParser: Qs) {\n super()\n this.#encryption = encryption\n this.#qsParser = qsParser\n }\n\n /**\n * Register route JSON payload\n */\n register(route: RouteJSON) {\n this.#routes[route.domain] = this.#routes[route.domain] || new RouteFinder()\n this.#routes[route.domain].register(route)\n }\n\n /**\n * Returns an instance of the URL builder for making\n * route URIs\n */\n builder() {\n return this.builderForDomain('root')\n }\n\n /**\n * Returns an instance of the URL builder for a specific\n * domain.\n */\n builderForDomain(domain: string) {\n const finder = this.#routes[domain]\n return new UrlBuilder(this.#encryption, finder || new RouteFinder(), this.#qsParser)\n }\n\n /**\n * Finds a route by its identifier. The identifier can be the\n * route name, controller.method name or the route pattern\n * itself.\n */\n find(routeIdentifier: string, domain?: string): RouteJSON | null {\n const finder = this.#routes[domain || 'root']\n if (!finder) {\n return null\n }\n\n return finder.find(routeIdentifier)\n }\n\n /**\n * Finds a route by its identifier. The identifier can be the\n * route name, controller.method name or the route pattern\n * itself.\n *\n * An error is raised when unable to find the route.\n */\n findOrFail(routeIdentifier: string, domain?: string): RouteJSON {\n const finder = this.#routes[domain || 'root']\n if (!finder) {\n throw new E_CANNOT_LOOKUP_ROUTE([routeIdentifier])\n }\n\n return finder.findOrFail(routeIdentifier)\n }\n\n /**\n * Check if a route exists. The identifier can be the\n * route name, controller.method name or the route pattern\n * itself.\n */\n has(routeIdentifier: string, domain?: string): boolean {\n const finder = this.#routes[domain || 'root']\n if (!finder) {\n return false\n }\n\n return finder.has(routeIdentifier)\n }\n\n toJSON() {\n return Object.keys(this.#routes).reduce<Record<string, RouteJSON[]>>((result, domain) => {\n result[domain] = this.#routes[domain].toJSON()\n return result\n }, {})\n }\n}\n","/*\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 { RuntimeException } from '@poppinss/utils'\nimport type { Encryption } from '@adonisjs/encryption'\n\nimport type { Qs } from '../../qs.js'\nimport { parseRoutePattern } from '../parser.js'\nimport type { RouteFinder } from './route_finder.js'\n\n/**\n * URL builder class is used to create URIs for pre-registered\n * routes.\n *\n * ```ts\n * const builder = new UrlBuilder(encryption, routeFinder)\n *\n * builder\n * .qs({ sort: 'id' })\n * .params([category.id])\n * .make('categories.posts.index')\n * ```\n */\nexport class UrlBuilder {\n /**\n * Query string parser\n */\n #qsParser: Qs\n\n /**\n * The parameters to apply on the route\n */\n #params: any[] | Record<string, any> = {}\n\n /**\n * Query string to append to the route\n */\n #qs: Record<string, any> = {}\n\n /**\n * Should we perform the route lookup or just build the\n * given pattern as it is.\n */\n #shouldPerformLookup = true\n\n /**\n * BaseURL to append to the constructored URL\n */\n #baseUrl?: string\n\n /**\n * Encryption class for making signed URLs\n */\n #encryption: Encryption\n\n /**\n * Route finder for finding route pattern\n */\n #routeFinder: RouteFinder\n\n constructor(encryption: Encryption, routeFinder: RouteFinder, qsParser: Qs) {\n this.#qsParser = qsParser\n this.#encryption = encryption\n this.#routeFinder = routeFinder\n }\n\n /**\n * Raises exception when wildcard values array is missing or\n * has length of zero.\n */\n #ensureHasWildCardValues(pattern: string, values?: string[]) {\n if (!values || !Array.isArray(values) || !values.length) {\n throw new RuntimeException(\n `Cannot make URL for \"${pattern}\" route. Invalid value provided for wildcard param`\n )\n }\n }\n\n /*\n * Raises exception when value is not defined\n */\n #ensureHasParamValue(pattern: string, param: string, value: string) {\n if (value === undefined || value === null) {\n throw new RuntimeException(\n `Cannot make URL for \"${pattern}\" route. Missing value for \"${param}\" param`\n )\n }\n }\n\n /**\n * Processes the pattern against the params\n */\n #processPattern(pattern: string): string {\n const uriSegments: string[] = []\n const paramsArray = Array.isArray(this.#params) ? this.#params : null\n const paramsObject = !Array.isArray(this.#params) ? this.#params : {}\n\n let paramsIndex = 0\n const tokens = parseRoutePattern(pattern)\n\n for (const token of tokens) {\n /**\n * Expected wildcard param to be at the end always and hence\n * we must break out from the loop\n */\n if (token.type === 0) {\n uriSegments.push(token.val === '/' ? '' : `${token.val}${token.end}`)\n } else if (token.type === 2) {\n const values: string[] = paramsArray ? paramsArray.slice(paramsIndex) : paramsObject['*']\n this.#ensureHasWildCardValues(pattern, values)\n uriSegments.push(`${values.join('/')}${token.end}`)\n break\n } else {\n const paramName = token.val\n const value = paramsArray ? paramsArray[paramsIndex] : paramsObject[paramName]\n\n /**\n * Type = 1 means param is required\n */\n if (token.type === 1) {\n this.#ensureHasParamValue(pattern, paramName, value)\n }\n\n paramsIndex++\n if (value !== undefined && value !== null) {\n uriSegments.push(`${value}${token.end}`)\n }\n }\n }\n\n return `/${uriSegments.join('/')}`\n }\n\n /**\n * Suffix the query string to the URL\n */\n #suffixQueryString(url: string, qs?: Record<string, any>): string {\n if (qs) {\n const queryString = this.#qsParser.stringify(qs)\n url = queryString ? `${url}?${queryString}` : url\n }\n\n return url\n }\n\n /**\n * Prefixes base URL to the uri string\n */\n #prefixBaseUrl(uri: string) {\n return this.#baseUrl ? `${this.#baseUrl}${uri}` : uri\n }\n\n /**\n * Prefix a custom base URL to the final URI\n */\n prefixUrl(url: string): this {\n this.#baseUrl = url\n return this\n }\n\n /**\n * Disable route lookup. Calling this method considers\n * the \"identifier\" as the route pattern\n */\n disableRouteLookup(): this {\n this.#shouldPerformLookup = false\n return this\n }\n\n /**\n * Append query string to the final URI\n */\n qs(queryString?: Record<string, any>): this {\n if (!queryString) {\n return this\n }\n\n this.#qs = queryString\n return this\n }\n\n /**\n * Specify params to apply to the route pattern\n */\n params(params?: any[] | Record<string, any>): this {\n if (!params) {\n return this\n }\n\n this.#params = params\n return this\n }\n\n /**\n * Generate URL for the given route identifier. The identifier can be the\n * route name, controller.method name or the route pattern\n * itself.\n */\n make(identifier: string) {\n let url: string\n\n if (this.#shouldPerformLookup) {\n const route = this.#routeFinder.findOrFail(identifier)\n url = this.#processPattern(route.pattern)\n } else {\n url = this.#processPattern(identifier)\n }\n\n return this.#suffixQueryString(this.#prefixBaseUrl(url), this.#qs)\n }\n\n /**\n * Generate a signed URL for the given route identifier. The identifier can be the\n * route name, controller.method name or the route pattern\n * itself.\n */\n makeSigned(identifier: string, options?: { expiresIn?: string | number; purpose?: string }) {\n let url: string\n\n if (this.#shouldPerformLookup) {\n const route = this.#routeFinder.findOrFail(identifier)\n url = this.#processPattern(route.pattern)\n } else {\n url = this.#processPattern(identifier)\n }\n\n /*\n * Making the signature from the qualified url. We do not prefix the domain when\n * making signature, since it just makes the signature big.\n *\n * There might be a case, when someone wants to generate signature for the same route\n * on their 2 different domains, but we ignore that case for now and can consider\n * it later (when someone asks for it)\n */\n const signature = this.#encryption.verifier.sign(\n this.#suffixQueryString(url, this.#qs),\n options?.expiresIn,\n options?.purpose\n )\n\n const qs = Object.assign({}, this.#qs, { signature })\n return this.#suffixQueryString(this.#prefixBaseUrl(url), qs)\n }\n}\n","/*\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 * as errors from '../../exceptions.js'\nimport type { RouteJSON } from '../../types/route.js'\n\n/**\n * Route finder is used to find a route by its name, route pattern\n * or the controller.method name.\n */\nexport class RouteFinder {\n #routes: RouteJSON[] = []\n\n register(route: RouteJSON) {\n this.#routes.push(route)\n }\n\n /**\n * Find a route by indentifier\n */\n find(routeIdentifier: string): RouteJSON | null {\n return (\n this.#routes.find(({ name, pattern, handler }) => {\n if (name === routeIdentifier || pattern === routeIdentifier) {\n return true\n }\n\n if (typeof handler === 'function') {\n return false\n }\n\n return handler.reference === routeIdentifier\n }) || null\n )\n }\n\n /**\n * Find a route by indentifier or fail\n */\n findOrFail(routeIdentifier: string): RouteJSON {\n const route = this.find(routeIdentifier)\n if (!route) {\n throw new errors.E_CANNOT_LOOKUP_ROUTE([routeIdentifier])\n }\n\n return route\n }\n\n /**\n * Find if a route exists\n */\n has(routeIdentifier: string): boolean {\n return !!this.find(routeIdentifier)\n }\n\n /**\n * Returns an array of registered routes\n */\n toJSON() {\n return this.#routes\n }\n}\n","/*\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 Macroable from '@poppinss/macroable'\n\n/**\n * Shortcut methods for commonly used route matchers\n */\nexport class RouteMatchers extends Macroable {\n /**\n * Enforce value to be a number and also casts it to number data\n * type\n */\n number() {\n return { match: /^[0-9]+$/, cast: (value: string) => Number(value) }\n }\n\n /**\n * Enforce value to be formatted as uuid\n */\n uuid() {\n return {\n match: /^[0-9a-zA-F]{8}-[0-9a-zA-F]{4}-[0-9a-zA-F]{4}-[0-9a-zA-F]{4}-[0-9a-zA-F]{12}$/,\n cast: (value: string) => value.toLowerCase(),\n }\n }\n\n /**\n * Enforce value to be formatted as slug\n */\n slug() {\n return { match: /^[^\\s-_](?!.*?[-_]{2,})([a-z0-9-\\\\]{1,})[^\\s]*[^-_\\s]$/ }\n }\n}\n","/*\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 { moduleImporter } from '@adonisjs/fold'\nimport type { LazyImport, UnWrapLazyImport } from './types/base.js'\nimport type {\n GetMiddlewareArgs,\n MiddlewareAsClass,\n ParsedGlobalMiddleware,\n} from './types/middleware.js'\n\n/**\n * Converts a middleware name and its lazy import to a factory function. The function\n * can than later be used to reference the middleware with different arguments\n * every time.\n */\nfunction middlewareReferenceBuilder(\n name: string | number | symbol,\n middleware: LazyImport<MiddlewareAsClass>\n) {\n const handler = moduleImporter(middleware, 'handle').toHandleMethod()\n return function (...args: any[]) {\n return {\n ...handler,\n name,\n args: args[0],\n }\n }\n}\n\n/**\n * Define an collection of named middleware. The collection gets converted\n * into a collection of factory functions. Calling the function returns\n * a reference to the executable middleware.\n */\nexport function defineNamedMiddleware<\n NamedMiddleware extends Record<string | number | symbol, LazyImport<MiddlewareAsClass>>,\n>(collection: NamedMiddleware) {\n return Object.keys(collection).reduce(\n (result, key: keyof NamedMiddleware) => {\n result[key] = middlewareReferenceBuilder(key, collection[key])\n return result\n },\n {} as {\n [K in keyof NamedMiddleware]: <\n Args extends GetMiddlewareArgs<UnWrapLazyImport<NamedMiddleware[K]>>,\n >(\n ...args: Args\n ) => {\n name: K\n args: Args[0]\n handle: ParsedGlobalMiddleware['handle']\n }\n }\n )\n}\n","/*\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 { inspect } from 'node:util'\nimport Macroable from '@poppinss/macroable'\nimport type { Logger } from '@adonisjs/logger'\nimport { RuntimeException } from '@poppinss/utils'\nimport { ContainerResolver } from '@adonisjs/fold'\n\nimport type { Request } from '../request.js'\nimport type { Response } from '../response.js'\nimport { asyncLocalStorage } from './local_storage.js'\nimport type { StoreRouteNode } from '../types/route.js'\n\n/**\n * Http context encapsulates properties for a given HTTP request. The\n * context class can be extended using macros and getters.\n */\nexport class HttpContext extends Macroable {\n /**\n * Find if async localstorage is enabled for HTTP requests\n * or not\n */\n static get usingAsyncLocalStorage() {\n return asyncLocalStorage.isEnabled\n }\n\n /**\n * Get access to the HTTP context. Available only when\n * \"usingAsyncLocalStorage\" is true\n */\n static get(): HttpContext | null {\n if (!this.usingAsyncLocalStorage || !asyncLocalStorage.storage) {\n return null\n }\n\n return asyncLocalStorage.storage.getStore() || null\n }\n\n /**\n * Get the HttpContext instance or raise an exception if not\n * available\n */\n static getOrFail(): HttpContext {\n /**\n * Localstorage is not enabled\n */\n if (!this.usingAsyncLocalStorage || !asyncLocalStorage.storage) {\n throw new RuntimeException(\n 'HTTP context is not available. Enable \"useAsyncLocalStorage\" inside \"config/app.ts\" file'\n )\n }\n\n const store = this.get()\n if (!store) {\n throw new RuntimeException('Http context is not available outside of an HTTP request')\n }\n\n return store\n }\n\n /**\n * Run a method that doesn't have access to HTTP context from\n * the async local storage.\n */\n static runOutsideContext<T>(callback: (...args: any[]) => T, ...args: any[]): T {\n if (!asyncLocalStorage.storage) {\n return callback(...args)\n }\n\n return asyncLocalStorage.storage.exit(callback, ...args)\n }\n\n /**\n * Reference to the current route. Not available inside\n * server middleware\n */\n route?: StoreRouteNode\n\n /**\n * A unique key for the current route\n */\n routeKey?: string\n\n /**\n * Route params\n */\n params: Record<string, any> = {}\n\n /**\n * Route subdomains\n */\n subdomains: Record<string, any> = {}\n\n constructor(\n public request: Request,\n public response: Response,\n public logger: Logger,\n public containerResolver: ContainerResolver<any>\n ) {\n super()\n\n /*\n * Creating the circular reference. We do this, since request and response\n * are meant to be extended and at times people would want to access\n * other ctx properties like `logger`, `profiler` inside those\n * extended methods.\n */\n this.request.ctx = this\n this.response.ctx = this\n }\n\n /**\n * A helper to see top level properties on the context object\n */\n /* c8 ignore next 3 */\n inspect() {\n return inspect(this, false, 1, true)\n }\n}\n","/*\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 { AsyncLocalStorage } from 'node:async_hooks'\nimport type { HttpContext } from './main.js'\n\n/**\n * Async local storage for HTTP context\n */\nexport const asyncLocalStorage: {\n isEnabled: boolean\n storage: null | AsyncLocalStorage<HttpContext>\n create(): AsyncLocalStorage<HttpContext>\n destroy(): void\n} = {\n /**\n * Check if the async local storage for the HTTP\n * context is enabled or not\n */\n isEnabled: false,\n\n /**\n * HTTP context storage instance for the current scope\n */\n storage: null,\n\n /**\n * Create the storage instance. This method must be called only\n * once.\n */\n create() {\n this.isEnabled = true\n this.storage = new AsyncLocalStorage<HttpContext>()\n return this.storage\n },\n\n /**\n * Destroy the create storage instance\n */\n destroy() {\n this.isEnabled = false\n this.storage = null\n },\n}\n","/*\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 onFinished from 'on-finished'\nimport Middleware from '@poppinss/middleware'\nimport type { Logger } from '@adonisjs/logger'\nimport type { Encryption } from '@adonisjs/encryption'\nimport type { Server as HttpsServer } from 'node:https'\nimport type { Application } from '@adonisjs/application'\nimport type { EmitterLike } from '@adonisjs/events/types'\nimport { ContainerResolver, moduleCaller, moduleImporter } from '@adonisjs/fold'\nimport type { ServerResponse, IncomingMessage, Server as HttpServer } from 'node:http'\n\nimport type { LazyImport } from '../types/base.js'\nimport type { MiddlewareAsClass, ParsedGlobalMiddleware } from '../types/middleware.js'\nimport type {\n ServerConfig,\n HttpServerEvents,\n ServerErrorHandler,\n ErrorHandlerAsAClass,\n TestingMiddlewarePipeline,\n} from '../types/server.js'\n\nimport { Qs } from '../qs.js'\nimport debug from '../debug.js'\nimport { Request } from '../request.js'\nimport { Response } from '../response.js'\nimport { Router } from '../router/main.js'\nimport { HttpContext } from '../http_context/main.js'\nimport { finalHandler } from './factories/final_handler.js'\nimport { writeResponse } from './factories/write_response.js'\nimport { asyncLocalStorage } from '../http_context/local_storage.js'\nimport { middlewareHandler } from './factories/middleware_handler.js'\n\n/**\n * The HTTP server implementation to handle incoming requests and respond using the\n * registered routes.\n */\nexport class Server {\n #booted: boolean = false\n\n /**\n * The default error handler to use\n */\n #defaultErrorHandler: ServerErrorHandler = {\n report() {},\n handle(error, ctx) {\n ctx.response.status(error.status || 500).send(error.message || 'Internal server error')\n },\n }\n\n /**\n * Logger instance, a child logger is added\n * to the context to have request specific\n * logging capabilities.\n */\n #logger: Logger\n\n /**\n * Registered error handler (if any)\n */\n #errorHandler?: LazyImport<ErrorHandlerAsAClass>\n\n /**\n * Resolved error handler is an instance of the lazily imported error\n * handler class.\n */\n #resolvedErrorHandler: ServerErrorHandler = this.#defaultErrorHandler\n\n /**\n * Emitter is required to notify when a request finishes\n */\n #emitter: EmitterLike<HttpServerEvents>\n\n /**\n * The application instance to be shared with the router\n */\n #app: Application<any>\n\n /**\n * The encryption instance to be shared with the router\n */\n #encryption: Encryption\n\n /**\n * Server config\n */\n #config: ServerConfig\n\n /**\n * Query string parser used by the server\n */\n #qsParser: Qs\n\n /**\n * Server middleware stack runs on every incoming HTTP request\n */\n #serverMiddlewareStack?: Middleware<ParsedGlobalMiddleware>\n\n /**\n * Reference to the router used by the server\n */\n #router: Router\n\n /**\n * Reference to the underlying Node HTTP server in use\n */\n #nodeHttpServer?: HttpServer | HttpsServer\n\n /**\n * Middleware store to be shared with the routes\n */\n #middleware: ParsedGlobalMiddleware[] = []\n\n /**\n * The request error response is attached to the middleware\n * pipeline to intercept errors and invoke the user\n * registered error handler.\n *\n * We share this with the route middleware pipeline as well,\n * so that it does not throw any exceptions\n */\n #requestErrorResponder: ServerErrorHandler['handle'] = (error, ctx) => {\n this.#resolvedErrorHandler.report(error, ctx)\n return this.#resolvedErrorHandler.handle(error, ctx)\n }\n\n /**\n * Check if the server has already been booted\n */\n get booted() {\n return this.#booted\n }\n\n /**\n * Know if async local storage is enabled or not.\n */\n get usingAsyncLocalStorage() {\n return asyncLocalStorage.isEnabled\n }\n\n constructor(\n app: Application<any>,\n encryption: Encryption,\n emitter: EmitterLike<HttpServerEvents>,\n logger: Logger,\n config: ServerConfig\n ) {\n this.#app = app\n this.#emitter = emitter\n this.#config = config\n this.#logger = logger\n this.#encryption = encryption\n this.#qsParser = new Qs(this.#config.qs)\n this.#router = new Router(this.#app, this.#encryption, this.#qsParser)\n this.#createAsyncLocalStore()\n\n debug('server config: %O', this.#config)\n }\n\n /**\n * Create async local storage store when enabled\n */\n #createAsyncLocalStore() {\n if (this.#config.useAsyncLocalStorage) {\n debug('creating ALS store for HTTP context')\n asyncLocalStorage.create()\n } else {\n asyncLocalStorage.destroy()\n }\n }\n\n /**\n * Creates an instance of the server middleware stack\n */\n #createServerMiddlewareStack() {\n this.#serverMiddlewareStack = new Middleware()\n this.#middleware.forEach((middleware) => this.#serverMiddlewareStack!.add(middleware))\n this.#serverMiddlewareStack.freeze()\n this.#middleware = []\n }\n\n /**\n * Handles the HTTP request\n */\n #handleRequest(ctx: HttpContext, resolver: ContainerResolver<any>) {\n return this.#serverMiddlewareStack!.runner()\n .errorHandler((error) => this.#requestErrorResponder(error, ctx))\n .finalHandler(finalHandler(this.#router!, resolver, ctx, this.#requestErrorResponder))\n .run(middlewareHandler(resolver, ctx))\n .catch((error) => {\n ctx.logger.fatal({ err: error }, 'Exception raised by error handler')\n return this.#defaultErrorHandler.handle(error, ctx)\n })\n .finally(writeResponse(ctx))\n }\n\n /**\n * Creates a pipeline of middleware.\n */\n pipeline(middleware: MiddlewareAsClass[]): TestingMiddlewarePipeline {\n const middlewareStack = new Middleware<ParsedGlobalMiddleware>()\n middleware.forEach((one) => {\n middlewareStack.add(moduleCaller(one, 'handle').toHandleMethod())\n })\n\n middlewareStack.freeze()\n const stackRunner = middlewareStack.runner()\n\n return {\n finalHandler(handler) {\n stackRunner.finalHandler(handler)\n return this\n },\n errorHandler(handler) {\n stackRunner.errorHandler(handler)\n return this\n },\n run(ctx) {\n return stackRunner.run((handler, next) => {\n return handler.handle(ctx.containerResolver, ctx, next)\n })\n },\n }\n }\n\n /**\n * Define an array of middleware to use on all the incoming HTTP request.\n * Calling this method multiple times pushes to the existing list\n * of middleware\n */\n use(middleware: LazyImport<MiddlewareAsClass>[]): this {\n middleware.forEach((one) =>\n this.#middleware.push(moduleImporter(one, 'handle').toHandleMethod())\n )\n\n return this\n }\n\n /**\n * Register a custom error handler for HTTP requests.\n * All errors will be reported to this method\n */\n errorHandler(handler: LazyImport<ErrorHandlerAsAClass>): this {\n this.#errorHandler = handler\n return this\n }\n\n /**\n * Boot the server. Calling this method performs the following actions.\n *\n * - Register routes with the store.\n * - Resolve and construct the error handler.\n */\n async boot() {\n if (this.#booted) {\n return\n }\n\n debug('booting HTTP server')\n\n /**\n * Creates the middleware stack for the server\n */\n this.#createServerMiddlewareStack()\n\n /**\n * Commit routes\n */\n this.#router.commit()\n\n /**\n * Register custom error handler\n */\n if (this.#errorHandler) {\n if (debug.enabled) {\n debug('using custom error handler \"%s\"', this.#errorHandler)\n }\n\n const moduleExports = await this.#errorHandler()\n this.#resolvedErrorHandler = await this.#app.container.make(moduleExports.default)\n }\n\n this.#booted = true\n }\n\n /**\n * Set the HTTP server instance used to listen for requests.\n */\n setNodeServer(server: HttpServer | HttpsServer) {\n server.timeout = this.#config.timeout ?? server.timeout\n server.keepAliveTimeout = this.#config.keepAliveTimeout ?? server.keepAliveTimeout\n server.headersTimeout = this.#config.headersTimeout ?? server.headersTimeout\n server.requestTimeout = this.#config.requestTimeout ?? server.requestTimeout\n this.#nodeHttpServer = server\n }\n\n /**\n * Returns reference to the underlying HTTP server\n * in use\n */\n getNodeServer() {\n return this.#nodeHttpServer\n }\n\n /**\n * Returns reference to the router instance used\n * by the server.\n */\n getRouter(): Router {\n return this.#router\n }\n\n /**\n * Creates an instance of the [[Request]] class\n */\n createRequest(req: IncomingMessage, res: ServerResponse) {\n return new Request(req, res, this.#encryption, this.#config, this.#qsParser)\n }\n\n /**\n * Creates an instance of the [[Response]] class\n */\n createResponse(req: IncomingMessage, res: ServerResponse) {\n return new Response(req, res, this.#encryption, this.#config, this.#router, this.#qsParser)\n }\n\n /**\n * Creates an instance of the [[HttpContext]] class\n */\n createHttpContext(request: Request, response: Response, resolver: ContainerResolver<any>) {\n return new HttpContext(\n request,\n response,\n this.#logger.child({ request_id: request.id() }),\n resolver\n )\n }\n\n /**\n * Handle request\n */\n handle(req: IncomingMessage, res: ServerResponse) {\n /**\n * Setup for the \"http:request_finished\" event\n */\n const hasRequestListener = this.#emitter.hasListeners('http:request_completed')\n const startTime = hasRequestListener ? process.hrtime() : null\n\n /**\n * Creating essential instances\n */\n const resolver = this.#app.container.createResolver()\n const ctx = this.createHttpContext(\n this.createRequest(req, res),\n this.createResponse(req, res),\n resolver\n )\n\n /**\n * Emit event when listening for the request_finished event\n */\n if (startTime) {\n onFinished(res, () => {\n this.#emitter.emit('http:request_completed', {\n ctx: ctx,\n duration: process.hrtime(startTime),\n })\n })\n }\n\n /**\n * Handle request\n */\n if (this.usingAsyncLocalStorage) {\n return asyncLocalStorage.storage!.run(ctx, () => this.#handleRequest(ctx, resolver))\n }\n return this.#handleRequest(ctx, resolver)\n }\n}\n","/*\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 { parse, stringify } from 'qs'\nimport { QSParserConfig } from './types/qs.js'\n\n/**\n * Query string parser used to parse and stringify query\n * strings.\n */\nexport class Qs {\n #config: QSParserConfig\n\n constructor(config: QSParserConfig) {\n this.#config = config\n }\n\n parse(value: string) {\n return parse(value, this.#config.parse)\n }\n\n stringify(value: any) {\n return stringify(value, this.#config.stringify)\n }\n}\n","/*\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 type { ContainerResolver } from '@adonisjs/fold'\n\nimport * as errors from '../../exceptions.js'\nimport type { Router } from '../../router/main.js'\nimport type { HttpContext } from '../../http_context/main.js'\nimport type { ServerErrorHandler } from '../../types/server.js'\n\n/**\n * The final handler is executed after the server middleware stack.\n * It looks for a matching route and executes the route middleware\n * stack.\n */\nexport function finalHandler(\n router: Router,\n resolver: ContainerResolver<any>,\n ctx: HttpContext,\n errorResponder: ServerErrorHandler['handle']\n) {\n return function () {\n const url = ctx.request.url()\n const method = ctx.request.method()\n const hostname = router.usingDomains ? ctx.request.hostname() : undefined\n const route = router.match(url, method, hostname)\n\n if (route) {\n ctx.params = route.params\n ctx.subdomains = route.subdomains\n ctx.route = route.route\n ctx.routeKey = route.routeKey\n return route.route.execute(route.route, resolver, ctx, errorResponder)\n }\n\n return Promise.reject(new errors.E_ROUTE_NOT_FOUND([method, url]))\n }\n}\n","/*\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 type { HttpContext } from '../../http_context/main.js'\n\n/**\n * Writes the response to the socket. The \"finish\" method can\n * raise error when unable to serialize the response.\n */\nexport function writeResponse(ctx: HttpContext) {\n return function () {\n try {\n ctx.response.finish()\n } catch (error) {\n ctx.logger.fatal({ err: error }, 'Response serialization failed')\n ctx.response.internalServerError(error.message)\n ctx.response.finish()\n }\n }\n}\n","/*\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 type { NextFn } from '@poppinss/middleware/types'\nimport type { ContainerResolver } from '@adonisjs/fold'\n\nimport type { HttpContext } from '../../http_context/main.js'\nimport { ParsedGlobalMiddleware } from '../../types/middleware.js'\nimport debug from '../../debug.js'\n\n/**\n * The middleware handler invokes the middleware functions.\n */\nexport function middlewareHandler(resolver: ContainerResolver<any>, ctx: HttpContext) {\n return function (fn: ParsedGlobalMiddleware, next: NextFn) {\n debug('executing middleware %s', fn.name)\n return fn.handle(resolver, ctx, next)\n }\n}\n","/*\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 proxyAddr from 'proxy-addr'\nimport string from '@poppinss/utils/string'\nimport type { ServerConfig } from './types/server.js'\nimport lodash from '@poppinss/utils/lodash'\n\ntype DeepPartial<T> = {\n [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]\n}\n\ntype UserDefinedServerConfig = DeepPartial<\n Omit<ServerConfig, 'trustProxy'> & {\n trustProxy: ((address: string, distance: number) => boolean) | boolean | string\n }\n>\n\n/**\n * Define configuration for the HTTP server\n */\nexport function defineConfig(config: UserDefinedServerConfig): ServerConfig {\n const { trustProxy, ...rest } = config\n\n const defaults = {\n allowMethodSpoofing: false,\n trustProxy: proxyAddr.compile('loopback'),\n subdomainOffset: 2,\n generateRequestId: false,\n useAsyncLocalStorage: false,\n etag: false,\n jsonpCallbackName: 'callback',\n cookie: {\n maxAge: '2h',\n path: '/',\n httpOnly: true,\n secure: true,\n sameSite: 'lax' as const,\n },\n qs: {\n parse: {\n depth: 5,\n parameterLimit: 1000,\n allowSparse: false,\n arrayLimit: 20,\n comma: true,\n },\n stringify: {\n encode: true,\n encodeValuesOnly: false,\n arrayFormat: 'indices' as const,\n skipNulls: false,\n },\n },\n } satisfies ServerConfig\n\n const normalizedConfig: ServerConfig = lodash.merge({}, defaults, rest)\n\n /**\n * Normalizing maxAge property on cookies to be a number in\n * seconds\n */\n if (normalizedConfig.cookie.maxAge) {\n normalizedConfig.cookie.maxAge = string.seconds.parse(normalizedConfig.cookie.maxAge)\n }\n\n /**\n * Normalizing trust proxy setting to allow boolean and\n * string values\n */\n if (typeof trustProxy === 'boolean') {\n const tpValue = trustProxy\n normalizedConfig.trustProxy = (_, __) => tpValue\n } else if (typeof trustProxy === 'string') {\n const tpValue = trustProxy\n normalizedConfig.trustProxy = proxyAddr.compile(tpValue)\n } else if (trustProxy) {\n normalizedConfig.trustProxy = trustProxy\n }\n\n return normalizedConfig\n}\n"],"mappings":";;;;;;;AASA,OAAO,QAAQ;AACf,OAAOA,gBAAe;AACtB,OAAO,gBAAgB;AACvB,SAAS,oBAAAC,y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AO;AACT;","names":["Macroable","RuntimeException","Macroable","Macroable","Macroable","Macroable","Macroable","RuntimeException","pack","canUnpack","unpack","pack","canUnpack","unpack","pack","canUnpack","unpack","is","Macroable","Macroable","is","parse","parse","error","Buffer","fresh","Macroable","RuntimeException","cookie","string","string","cookie","Macroable","RuntimeException","Buffer","fresh","is","moduleImporter","RuntimeException","matchit","lodash","RuntimeException","RuntimeException","lodash","matchit","Macroable","RuntimeException","RuntimeException","Macroable","Macroable","moduleImporter","moduleImporter","is","RuntimeException","Macroable","RuntimeException","Macroable","RuntimeException","onFinished","Middleware","moduleCaller","moduleImporter","parse","Middleware","moduleCaller","moduleImporter","onFinished","string","lodash","trustProxy"]}
1
+ {"version":3,"sources":["../src/router/route.ts","../src/router/factories/use_return_value.ts","../src/router/executor.ts","../src/helpers.ts","../src/router/brisk.ts","../src/router/group.ts","../src/router/resource.ts","../src/debug.ts","../src/cookies/drivers/plain.ts","../src/cookies/drivers/signed.ts","../src/cookies/drivers/encrypted.ts","../src/cookies/client.ts","../src/request.ts","../src/cookies/parser.ts","../src/redirect.ts","../src/exceptions.ts","../src/response_status.ts","../src/response.ts","../src/cookies/serializer.ts","../src/router/main.ts","../src/router/store.ts","../src/router/parser.ts","../src/router/lookup_store/main.ts","../src/router/lookup_store/url_builder.ts","../src/router/lookup_store/route_finder.ts","../src/router/matchers.ts","../src/define_middleware.ts","../src/http_context/main.ts","../src/http_context/local_storage.ts","../src/server/main.ts","../src/qs.ts","../src/server/factories/final_handler.ts","../src/server/factories/write_response.ts","../src/server/factories/middleware_handler.ts","../src/define_config.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 Middleware from '@poppinss/middleware'\nimport { RuntimeException } from '@poppinss/utils'\nimport type { Application } from '@adonisjs/application'\nimport { moduleCaller, moduleImporter } from '@adonisjs/fold'\n\nimport { execute } from './executor.js'\nimport { dropSlash } from '../helpers.js'\nimport type { Constructor, LazyImport, OneOrMore } from '../types/base.js'\n\nimport type {\n MiddlewareFn,\n ParsedNamedMiddleware,\n ParsedGlobalMiddleware,\n} from '../types/middleware.js'\n\nimport type {\n GetControllerHandlers,\n RouteFn,\n RouteJSON,\n RouteMatcher,\n RouteMatchers,\n StoreRouteHandler,\n StoreRouteMiddleware,\n} from '../types/route.js'\nimport debug from '../debug.js'\n\n/**\n * The route class exposes the APIs for constructing a route using the\n * fluent API.\n */\nexport class Route<Controller extends Constructor<any> = any> extends Macroable {\n /**\n * Route pattern\n */\n #pattern: string\n\n /**\n * HTTP Methods for the route\n */\n #methods: string[]\n\n /**\n * A unique name for the route\n */\n #name?: string\n\n /**\n * A boolean to prevent route from getting registered within\n * the store.\n *\n * This flag must be set before \"Router.commit\" method\n */\n #isDeleted: boolean = false\n\n /**\n * Route handler\n */\n #handler: StoreRouteHandler\n\n /**\n * Matchers inherited from the router\n */\n #globalMatchers: RouteMatchers\n\n /**\n * Reference to the AdonisJS application\n */\n #app: Application<any>\n\n /**\n * Middleware registered on the router\n */\n #routerMiddleware: ParsedGlobalMiddleware[]\n\n /**\n * By default the route is part of the `root` domain. Root domain is used\n * when no domain is defined\n */\n #routeDomain: string = 'root'\n\n /**\n * An object of matchers to be forwarded to the store. The matchers\n * list is populated by calling `where` method\n */\n #matchers: RouteMatchers = {}\n\n /**\n * Custom prefixes defined on the route or the route parent\n * groups\n */\n #prefixes: string[] = []\n\n /**\n * Middleware defined directly on the route or the route parent\n * routes. We mantain an array for each layer of the stack\n */\n #middleware: StoreRouteMiddleware[][] = []\n\n constructor(\n app: Application<any>,\n routerMiddleware: ParsedGlobalMiddleware[],\n options: {\n pattern: string\n methods: string[]\n handler:\n | RouteFn\n | string\n | [LazyImport<Controller> | Controller, GetControllerHandlers<Controller>?]\n globalMatchers: RouteMatchers\n }\n ) {\n super()\n this.#app = app\n this.#routerMiddleware = routerMiddleware\n this.#pattern = options.pattern\n this.#methods = options.methods\n this.#handler = this.#resolveRouteHandle(options.handler)\n this.#globalMatchers = options.globalMatchers\n }\n\n /**\n * Resolves the route handler string expression to a\n * handler method object\n */\n #resolveRouteHandle(\n handler:\n | RouteFn\n | string\n | [LazyImport<Controller> | Controller, GetControllerHandlers<Controller>?]\n ) {\n /**\n * Convert magic string to handle method call\n */\n if (typeof handler === 'string') {\n const parts = handler.split('.')\n const method = parts.length === 1 ? 'handle' : parts.pop()!\n const moduleRefId = parts.join('.')\n\n return {\n reference: handler,\n ...moduleImporter(() => this.#app.import(moduleRefId), method).toHandleMethod(),\n name: handler,\n }\n }\n\n /**\n * Using a lazily imported controller\n */\n if (Array.isArray(handler)) {\n /**\n * The first item of the tuple is a class constructor\n */\n if (is.class(handler[0])) {\n return {\n reference: handler,\n ...moduleCaller(handler[0], (handler[1] || 'handle') as string).toHandleMethod(),\n }\n }\n\n /**\n * The first item of the tuple is a function that lazily\n * loads the controller\n */\n return {\n reference: handler,\n ...moduleImporter(handler[0], (handler[1] || 'handle') as string).toHandleMethod(),\n }\n }\n\n return handler\n }\n\n /**\n * Returns an object of param matchers by merging global and local\n * matchers. The local copy is given preference over the global\n * one's\n */\n #getMatchers() {\n return { ...this.#globalMatchers, ...this.#matchers }\n }\n\n /**\n * Returns a normalized pattern string by prefixing the `prefix` (if defined).\n */\n #computePattern(): string {\n const pattern = dropSlash(this.#pattern)\n const prefix = this.#prefixes\n .slice()\n .reverse()\n .map((one) => dropSlash(one))\n .join('')\n\n return prefix ? `${prefix}${pattern === '/' ? '' : pattern}` : pattern\n }\n\n /**\n * Define matcher for a given param. If a matcher exists, then we do not\n * override that, since the routes inside a group will set matchers\n * before the group, so they should have priority over the group\n * matchers.\n *\n * ```ts\n * Route.group(() => {\n * Route.get('/:id', 'handler').where('id', /^[0-9]$/)\n * }).where('id', /[^a-z$]/)\n * ```\n *\n * The `/^[0-9]$/` will win over the matcher defined by the group\n */\n where(param: string, matcher: RouteMatcher | string | RegExp): this {\n if (this.#matchers[param]) {\n return this\n }\n\n if (typeof matcher === 'string') {\n this.#matchers[param] = { match: new RegExp(matcher) }\n } else if (is.regExp(matcher)) {\n this.#matchers[param] = { match: matcher }\n } else {\n this.#matchers[param] = matcher\n }\n\n return this\n }\n\n /**\n * Define prefix for the route. Calling this method multiple times\n * applies multiple prefixes in the reverse order.\n */\n prefix(prefix: string): this {\n this.#prefixes.push(prefix)\n return this\n }\n\n /**\n * Define a custom domain for the route. We do not overwrite the domain\n * unless `overwrite` flag is set to true.\n */\n domain(domain: string, overwrite: boolean = false): this {\n if (this.#routeDomain === 'root' || overwrite) {\n this.#routeDomain = domain\n }\n return this\n }\n\n /**\n * Define one or more middleware to be executed before the route\n * handler.\n *\n * Named middleware can be referenced using the name registered with\n * the router middleware store.\n */\n use(middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this {\n this.#middleware.push(Array.isArray(middleware) ? middleware : [middleware])\n return this\n }\n\n /**\n * @alias use\n */\n middleware(middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this {\n return this.use(middleware)\n }\n\n /**\n * Give a unique name to the route. Assinging a new unique removes the\n * existing name of the route.\n *\n * Setting prepends to true prefixes the name to the existing name.\n */\n as(name: string, prepend = false): this {\n if (prepend) {\n if (!this.#name) {\n throw new RuntimeException(\n `Routes inside a group must have names before calling \"router.group.as\"`\n )\n }\n\n this.#name = `${name}.${this.#name}`\n return this\n }\n\n this.#name = name\n return this\n }\n\n /**\n * Check if the route was marked to be deleted\n */\n isDeleted(): boolean {\n return this.#isDeleted\n }\n\n /**\n * Mark route as deleted. Deleted routes are not registered\n * with the route store\n */\n markAsDeleted() {\n this.#isDeleted = true\n }\n\n /**\n * Get the route name\n */\n getName(): string | undefined {\n return this.#name\n }\n\n /**\n * Get the route pattern\n */\n getPattern(): string {\n return this.#pattern\n }\n\n /**\n * Set the route pattern\n */\n setPattern(pattern: string): this {\n this.#pattern = pattern\n return this\n }\n\n /**\n * Returns the stack of middleware registered on the route.\n * The value is shared by reference.\n */\n getMiddleware() {\n return this.#middleware\n }\n\n /**\n * Returns the middleware instance for persistence inside the\n * store\n */\n #getMiddlewareForStore() {\n const middleware = new Middleware<StoreRouteMiddleware>()\n\n this.#routerMiddleware.forEach((one) => {\n debug('adding global middleware to route %s, %O', this.#pattern, one)\n middleware.add(one)\n })\n this.#middleware.flat().forEach((one) => {\n debug('adding named middleware to route %s, %O', this.#pattern, one)\n middleware.add(one)\n })\n\n return middleware\n }\n\n /**\n * Returns JSON representation of the route\n */\n toJSON(): RouteJSON {\n return {\n domain: this.#routeDomain,\n pattern: this.#computePattern(),\n matchers: this.#getMatchers(),\n meta: {},\n name: this.#name,\n handler: this.#handler,\n methods: this.#methods,\n middleware: this.#getMiddlewareForStore(),\n execute: execute,\n }\n }\n}\n","/*\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 type { HttpContext } from '../../http_context/main.js'\n\n/**\n * A factory function that uses the return value of the request\n * pipeline as the response\n */\nexport function useReturnValue(ctx: HttpContext) {\n return function (value: any) {\n if (\n value !== undefined && // Return value is explicitly defined\n !ctx.response.hasLazyBody && // Lazy body is not set\n value !== ctx.response // Return value is not the instance of response object\n ) {\n ctx.response.send(value)\n }\n }\n}\n","/*\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 type { ContainerResolver } from '@adonisjs/fold'\nimport type { StoreRouteNode } from '../types/route.js'\nimport type { HttpContext } from '../http_context/main.js'\nimport type { ServerErrorHandler } from '../types/server.js'\nimport { useReturnValue } from './factories/use_return_value.js'\n\n/**\n * Executor to execute the route middleware pipeline the route\n * handler\n */\nexport function execute(\n route: StoreRouteNode,\n resolver: ContainerResolver<any>,\n ctx: HttpContext,\n errorResponder: ServerErrorHandler['handle']\n) {\n return route.middleware\n .runner()\n .errorHandler((error) => errorResponder(error, ctx))\n .finalHandler(async () => {\n if (typeof route.handler === 'function') {\n return Promise.resolve(route.handler(ctx)).then(useReturnValue(ctx))\n }\n\n return route.handler.handle(resolver, ctx).then(useReturnValue(ctx))\n })\n .run(async (middleware, next) => {\n if (typeof middleware === 'function') {\n return middleware(ctx, next)\n }\n\n return middleware.handle(resolver, ctx, next, middleware.args)\n })\n}\n","/*\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 Cache from 'tmp-cache'\nimport { InvalidArgumentsException } from '@poppinss/utils'\n\nimport { Route } from './router/route.js'\nimport { BriskRoute } from './router/brisk.js'\nimport { RouteGroup } from './router/group.js'\nimport type { RouteJSON } from './types/route.js'\nimport { RouteResource } from './router/resource.js'\n\nconst proxyCache = new Cache({ max: 200 })\n\n/**\n * Makes input string consistent by having only the starting\n * slash\n */\nexport function dropSlash(input: string): string {\n if (input === '/') {\n return '/'\n }\n\n return `/${input.replace(/^\\//, '').replace(/\\/$/, '')}`\n}\n\n/**\n * Returns a flat list of routes from the route groups and resources\n */\nexport function toRoutesJSON(\n routes: (RouteGroup | Route | RouteResource | BriskRoute)[]\n): RouteJSON[] {\n return routes.reduce((list: RouteJSON[], route) => {\n if (route instanceof RouteGroup) {\n list = list.concat(toRoutesJSON(route.routes))\n return list\n }\n\n if (route instanceof RouteResource) {\n list = list.concat(toRoutesJSON(route.routes))\n return list\n }\n\n if (route instanceof BriskRoute) {\n if (route.route && !route.route.isDeleted()) {\n list.push(route.route.toJSON())\n }\n return list\n }\n\n if (!route.isDeleted()) {\n list.push(route.toJSON())\n }\n\n return list\n }, [])\n}\n\n/**\n * Helper to know if the remote address should\n * be trusted.\n */\nexport function trustProxy(\n remoteAddress: string,\n proxyFn: (addr: string, distance: number) => boolean\n): boolean {\n if (proxyCache.has(remoteAddress)) {\n return proxyCache.get(remoteAddress) as boolean\n }\n\n const result = proxyFn(remoteAddress, 0)\n proxyCache.set(remoteAddress, result)\n return result\n}\n\n/**\n * Parses a range expression to an object filled with the range\n */\nexport function parseRange<T>(range: string, value: T): Record<number, T> {\n const parts = range.split('..')\n const min = Number(parts[0])\n const max = Number(parts[1])\n\n /**\n * The ending status code does not exists\n */\n if (parts.length === 1 && !Number.isNaN(min)) {\n return {\n [min]: value,\n }\n }\n\n /**\n * The starting status code is not a number\n */\n if (Number.isNaN(min) || Number.isNaN(max)) {\n return {}\n }\n\n /**\n * Min and max are same\n */\n if (min === max) {\n return {\n [min]: value,\n }\n }\n\n /**\n * Max cannot be smaller than min\n */\n if (max < min) {\n throw new InvalidArgumentsException(`Invalid range \"${range}\"`)\n }\n\n /**\n * Loop over the range and create a collection\n * of status codes\n */\n return [...Array(max - min + 1).keys()].reduce(\n (result, step) => {\n result[min + step] = value\n return result\n },\n {} as Record<number, T>\n )\n}\n","/*\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 Macroable from '@poppinss/macroable'\nimport type { Application } from '@adonisjs/application'\n\nimport { Route } from './route.js'\nimport type { HttpContext } from '../http_context/main.js'\nimport type { ParsedGlobalMiddleware } from '../types/middleware.js'\nimport type { MakeUrlOptions, RouteFn, RouteMatchers } from '../types/route.js'\n\n/**\n * Brisk routes exposes the API to configure the route handler by chaining\n * one of the pre-defined methods.\n *\n * For example: Instead of defining the redirect logic as a callback, one can\n * chain the `.redirect` method.\n *\n * Brisk routes are always registered under the `GET` HTTP method.\n */\nexport class BriskRoute extends Macroable {\n /**\n * Route pattern\n */\n #pattern: string\n\n /**\n * Matchers inherited from the router\n */\n #globalMatchers: RouteMatchers\n\n /**\n * Reference to the AdonisJS application\n */\n #app: Application<any>\n\n /**\n * Middleware registered on the router\n */\n #routerMiddleware: ParsedGlobalMiddleware[]\n\n /**\n * Reference to route instance. Set after `setHandler` is called\n */\n route: null | Route = null\n\n constructor(\n app: Application<any>,\n routerMiddleware: ParsedGlobalMiddleware[],\n options: {\n pattern: string\n globalMatchers: RouteMatchers\n }\n ) {\n super()\n this.#app = app\n this.#routerMiddleware = routerMiddleware\n this.#pattern = options.pattern\n this.#globalMatchers = options.globalMatchers\n }\n\n /**\n * Set handler for the brisk route\n */\n setHandler(handler: RouteFn): Route {\n this.route = new Route(this.#app, this.#routerMiddleware, {\n pattern: this.#pattern,\n globalMatchers: this.#globalMatchers,\n methods: ['GET', 'HEAD'],\n handler: handler,\n })\n\n return this.route\n }\n\n /**\n * Redirects to a given route. Params from the original request will\n * be used when no custom params are defined.\n */\n redirect(\n identifier: string,\n params?: any[] | Record<string, any>,\n options?: MakeUrlOptions & { status: number }\n ): Route {\n function redirectsToRoute(ctx: HttpContext) {\n const redirector = ctx.response.redirect()\n if (options?.status) {\n redirector.status(options.status)\n }\n\n return redirector.toRoute(identifier, params || ctx.params, options)\n }\n Object.defineProperty(redirectsToRoute, 'listArgs', { value: identifier, writable: false })\n\n return this.setHandler(redirectsToRoute)\n }\n\n /**\n * Redirect request to a fixed URL\n */\n redirectToPath(url: string, options?: { status: number }): Route {\n function redirectsToPath(ctx: HttpContext) {\n const redirector = ctx.response.redirect()\n if (options?.status) {\n redirector.status(options.status)\n }\n\n return redirector.toPath(url)\n }\n Object.defineProperty(redirectsToPath, 'listArgs', { value: url, writable: false })\n\n return this.setHandler(redirectsToPath)\n }\n}\n","/*\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 Macroable from '@poppinss/macroable'\nimport type { RouteMatcher, StoreRouteMiddleware } from '../types/route.js'\nimport type { MiddlewareFn, ParsedNamedMiddleware } from '../types/middleware.js'\n\nimport { Route } from './route.js'\nimport { BriskRoute } from './brisk.js'\nimport { RouteResource } from './resource.js'\nimport { OneOrMore } from '../types/base.js'\n\n/**\n * Group class exposes the API to take action on a group of routes.\n * The group routes must be pre-defined using the constructor.\n */\nexport class RouteGroup extends Macroable {\n /**\n * Array of middleware registered on the group.\n */\n #middleware: StoreRouteMiddleware[] = []\n\n constructor(public routes: (Route | RouteGroup | RouteResource | BriskRoute)[]) {\n super()\n }\n\n /**\n * Shares midldeware stack with the routes. The method is invoked recursively\n * to only register middleware with the route class and not with the\n * resource or the child group\n */\n #shareMiddlewareStackWithRoutes(route: RouteGroup | Route | RouteResource | BriskRoute) {\n if (route instanceof RouteGroup) {\n route.routes.forEach((child) => this.#shareMiddlewareStackWithRoutes(child))\n return\n }\n\n if (route instanceof RouteResource) {\n route.routes.forEach((child) => child.getMiddleware().unshift(this.#middleware))\n return\n }\n\n if (route instanceof BriskRoute) {\n route.route!.getMiddleware().unshift(this.#middleware)\n return\n }\n\n route.getMiddleware().unshift(this.#middleware)\n }\n\n /**\n * Updates the route name. The method is invoked recursively to only update\n * the name with the route class and not with the resource or the child\n * group.\n */\n #updateRouteName(route: RouteGroup | Route | RouteResource | BriskRoute, name: string) {\n if (route instanceof RouteGroup) {\n route.routes.forEach((child) => this.#updateRouteName(child, name))\n return\n }\n\n if (route instanceof RouteResource) {\n route.routes.forEach((child) => child.as(name, true))\n return\n }\n\n if (route instanceof BriskRoute) {\n route.route!.as(name, true)\n return\n }\n\n route.as(name, true)\n }\n\n /**\n * Sets prefix on the route. The method is invoked recursively to only set\n * the prefix with the route class and not with the resource or the\n * child group.\n */\n #setRoutePrefix(route: RouteGroup | Route | RouteResource | BriskRoute, prefix: string) {\n if (route instanceof RouteGroup) {\n route.routes.forEach((child) => this.#setRoutePrefix(child, prefix))\n return\n }\n\n if (route instanceof RouteResource) {\n route.routes.forEach((child) => child.prefix(prefix))\n return\n }\n\n if (route instanceof BriskRoute) {\n route.route!.prefix(prefix)\n return\n }\n\n route.prefix(prefix)\n }\n\n /**\n * Updates domain on the route. The method is invoked recursively to only update\n * the domain with the route class and not with the resource or the child\n * group.\n */\n #updateRouteDomain(route: RouteGroup | Route | RouteResource | BriskRoute, domain: string) {\n if (route instanceof RouteGroup) {\n route.routes.forEach((child) => this.#updateRouteDomain(child, domain))\n return\n }\n\n if (route instanceof RouteResource) {\n route.routes.forEach((child) => child.domain(domain))\n return\n }\n\n if (route instanceof BriskRoute) {\n route.route!.domain(domain, false)\n return\n }\n\n route.domain(domain, false)\n }\n\n /**\n * Updates matchers on the route. The method is invoked recursively to only update\n * the matchers with the route class and not with the resource or the child\n * group.\n */\n #updateRouteMatchers(\n route: RouteGroup | Route | RouteResource | BriskRoute,\n param: string,\n matcher: RouteMatcher | string | RegExp\n ) {\n if (route instanceof RouteGroup) {\n route.routes.forEach((child) => this.#updateRouteMatchers(child, param, matcher))\n return\n }\n\n if (route instanceof RouteResource) {\n route.routes.forEach((child) => child.where(param, matcher))\n return\n }\n\n if (route instanceof BriskRoute) {\n route.route!.where(param, matcher)\n return\n }\n\n route.where(param, matcher)\n }\n\n /**\n * Define route param matcher\n *\n * ```ts\n * Route.group(() => {\n * }).where('id', /^[0-9]+/)\n * ```\n */\n where(param: string, matcher: RouteMatcher | string | RegExp): this {\n this.routes.forEach((route) => this.#updateRouteMatchers(route, param, matcher))\n return this\n }\n\n /**\n * Define prefix all the routes in the group.\n *\n * ```ts\n * Route.group(() => {\n * }).prefix('v1')\n * ```\n */\n prefix(prefix: string): this {\n this.routes.forEach((route) => this.#setRoutePrefix(route, prefix))\n return this\n }\n\n /**\n * Define domain for all the routes.\n *\n * ```ts\n * Route.group(() => {\n * }).domain(':name.adonisjs.com')\n * ```\n */\n domain(domain: string): this {\n this.routes.forEach((route) => this.#updateRouteDomain(route, domain))\n return this\n }\n\n /**\n * Prepend name to the routes name.\n *\n * ```ts\n * Route.group(() => {\n * }).as('version1')\n * ```\n */\n as(name: string): this {\n this.routes.forEach((route) => this.#updateRouteName(route, name))\n return this\n }\n /**\n * Prepend an array of middleware to all routes middleware.\n *\n * ```ts\n * Route.group(() => {\n * }).use(middleware.auth())\n * ```\n */\n use(middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this {\n /**\n * Register middleware with children. We share the group middleware\n * array by reference, therefore have to register it only for the\n * first time.\n */\n if (!this.#middleware.length) {\n this.routes.forEach((route) => this.#shareMiddlewareStackWithRoutes(route))\n }\n\n if (Array.isArray(middleware)) {\n for (let one of middleware) {\n this.#middleware.push(one)\n }\n } else {\n this.#middleware.push(middleware)\n }\n\n return this\n }\n\n /**\n * @alias use\n */\n middleware(middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this {\n return this.use(middleware)\n }\n}\n","/*\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 string from '@poppinss/utils/string'\nimport Macroable from '@poppinss/macroable'\nimport { RuntimeException } from '@poppinss/utils'\nimport type { Application } from '@adonisjs/application'\n\nimport { Route } from './route.js'\nimport type { Constructor, LazyImport, OneOrMore } from '../types/base.js'\nimport type {\n MiddlewareFn,\n ParsedGlobalMiddleware,\n ParsedNamedMiddleware,\n} from '../types/middleware.js'\nimport type { ResourceActionNames, RouteMatcher, RouteMatchers } from '../types/route.js'\n\n/**\n * Route resource exposes the API to register multiple routes for a resource.\n */\nexport class RouteResource<\n ActionNames extends ResourceActionNames = ResourceActionNames,\n> extends Macroable {\n /**\n * Resource identifier. Nested resources are separated\n * with a dot notation\n */\n #resource: string\n\n /**\n * The controller to handle resource routing requests\n */\n #controller: string | LazyImport<Constructor<any>> | Constructor<any>\n\n /**\n * Is it a shallow resource? Shallow resources URLs do not have parent\n * resource name and id once they can be identified with the id.\n */\n #shallow: boolean = false\n\n /**\n * Matchers inherited from the router\n */\n #globalMatchers: RouteMatchers\n\n /**\n * Reference to the AdonisJS application\n */\n #app: Application<any>\n\n /**\n * Middleware registered on the router\n */\n #routerMiddleware: ParsedGlobalMiddleware[]\n\n /**\n * Parameter names for the resources. Defaults to `id` for\n * a singular resource and `resource_id` for nested\n * resources.\n */\n #params: Record<string, string> = {}\n\n /**\n * Base name for the routes. We suffix action names\n * on top of the base name\n */\n #routesBaseName: string\n\n /**\n * A collection of routes instances that belongs to this resource\n */\n routes: Route[] = []\n\n constructor(\n app: Application<any>,\n routerMiddleware: ParsedGlobalMiddleware[],\n options: {\n resource: string\n controller: string | LazyImport<Constructor<any>> | Constructor<any>\n globalMatchers: RouteMatchers\n shallow: boolean\n }\n ) {\n super()\n this.#validateResourceName(options.resource)\n\n this.#app = app\n this.#shallow = options.shallow\n this.#routerMiddleware = routerMiddleware\n this.#controller = options.controller\n this.#globalMatchers = options.globalMatchers\n this.#resource = this.#normalizeResourceName(options.resource)\n this.#routesBaseName = this.#getRoutesBaseName()\n this.#buildRoutes()\n }\n\n /**\n * Normalizes the resource name to dropping leading and trailing\n * slashes.\n */\n #normalizeResourceName(resource: string) {\n return resource.replace(/^\\//, '').replace(/\\/$/, '')\n }\n\n /**\n * Ensure resource name is not an empty string\n */\n #validateResourceName(resource: string) {\n if (!resource || resource === '/') {\n throw new RuntimeException(`Invalid resource name \"${resource}\"`)\n }\n }\n\n /**\n * Converting segments of a resource to snake case to\n * make the route name.\n */\n #getRoutesBaseName() {\n return this.#resource\n .split('.')\n .map((token) => string.snakeCase(token))\n .join('.')\n }\n\n /**\n * Create a new route for the given pattern, methods and controller action\n */\n #createRoute(pattern: string, methods: string[], action: ResourceActionNames) {\n const route = new Route(this.#app, this.#routerMiddleware, {\n pattern,\n methods,\n handler:\n typeof this.#controller === 'string'\n ? `${this.#controller}.${action}`\n : [this.#controller, action],\n globalMatchers: this.#globalMatchers,\n })\n\n route.as(`${this.#routesBaseName}.${action}`)\n this.routes.push(route)\n }\n\n /**\n * Returns the `resource_id` name for a given resource. The\n * resource name is converted to singular form and\n * transformed to snake case.\n *\n * photos becomes photo_id\n * users becomes user_id\n */\n #getResourceId(resource: string) {\n return `${string.snakeCase(string.singular(resource))}_id`\n }\n\n /**\n * Build routes for the given resource\n */\n #buildRoutes() {\n const resources = this.#resource.split('.')\n\n const mainResource = resources.pop()!\n this.#params[mainResource] = ':id'\n\n const baseURI = `${resources\n .map((resource) => {\n const paramName = `:${this.#getResourceId(resource)}`\n this.#params[resource] = paramName\n\n return `${resource}/${paramName}`\n })\n .join('/')}/${mainResource}`\n\n this.#createRoute(baseURI, ['GET', 'HEAD'], 'index')\n this.#createRoute(`${baseURI}/create`, ['GET', 'HEAD'], 'create')\n this.#createRoute(baseURI, ['POST'], 'store')\n this.#createRoute(`${this.#shallow ? mainResource : baseURI}/:id`, ['GET', 'HEAD'], 'show')\n this.#createRoute(`${this.#shallow ? mainResource : baseURI}/:id/edit`, ['GET', 'HEAD'], 'edit')\n this.#createRoute(`${this.#shallow ? mainResource : baseURI}/:id`, ['PUT', 'PATCH'], 'update')\n this.#createRoute(`${this.#shallow ? mainResource : baseURI}/:id`, ['DELETE'], 'destroy')\n }\n\n /**\n * Filter the routes based on their partial names\n */\n #filter(names: ActionNames | ActionNames[], inverse: boolean) {\n const actions = Array.isArray(names) ? names : [names]\n return this.routes.filter((route) => {\n const match = actions.find((name) => route.getName()!.endsWith(name))\n return inverse ? !match : match\n })\n }\n\n /**\n * Register only given routes and remove others\n */\n only<Name extends ActionNames>(names: Name[]): RouteResource<Name> {\n this.#filter(names, true).forEach((route) => route.markAsDeleted())\n return this\n }\n\n /**\n * Register all routes, except the one's defined\n */\n except<Name extends ActionNames>(names: Name[]): RouteResource<Exclude<ActionNames, Name>> {\n this.#filter(names, false).forEach((route) => route.markAsDeleted())\n return this\n }\n\n /**\n * Register api only routes. The `create` and `edit` routes, which\n * are meant to show forms will not be registered\n */\n apiOnly(): RouteResource<Exclude<ActionNames, 'create' | 'edit'>> {\n return this.except(['create', 'edit'] as ActionNames[])\n }\n\n /**\n * Define matcher for params inside the resource\n */\n where(key: string, matcher: RouteMatcher | string | RegExp): this {\n this.routes.forEach((route) => {\n route.where(key, matcher)\n })\n\n return this\n }\n\n /**\n * Tap into multiple routes to configure them by their name\n */\n tap(callback: (route: Route) => void): this\n tap(actions: ActionNames | ActionNames[], callback: (route: Route) => void): this\n tap(\n actions: ((route: Route) => void) | ActionNames | ActionNames[],\n callback?: (route: Route) => void\n ): this {\n if (typeof actions === 'function') {\n this.routes.forEach((route) => {\n if (!route.isDeleted()) {\n actions(route)\n }\n })\n return this\n }\n\n this.#filter(actions, false).forEach((route) => {\n if (!route.isDeleted()) {\n callback!(route)\n }\n })\n return this\n }\n\n /**\n * Set the param name for a given resource\n */\n params(resources: { [resource: string]: string }): this {\n Object.keys(resources).forEach((resource) => {\n const param = resources[resource]\n const existingParam = this.#params[resource]\n this.#params[resource] = `:${param}`\n\n this.routes.forEach((route) => {\n route.setPattern(\n route.getPattern().replace(`${resource}/${existingParam}`, `${resource}/:${param}`)\n )\n })\n })\n\n return this\n }\n\n /**\n * Define one or more middleware on the routes created by\n * the resource.\n *\n * Calling this method multiple times will append middleware\n * to existing list.\n */\n use(\n actions: ActionNames | ActionNames[] | '*',\n middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>\n ): this {\n if (actions === '*') {\n this.tap((route) => route.use(middleware))\n } else {\n this.tap(actions, (route) => route.use(middleware))\n }\n return this\n }\n\n /**\n * @alias use\n */\n middleware(\n actions: ActionNames | ActionNames[] | '*',\n middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>\n ): this {\n return this.use(actions, middleware)\n }\n\n /**\n * Prepend name to all the routes\n */\n as(name: string, normalizeName: boolean = true): this {\n name = normalizeName ? string.snakeCase(name) : name\n this.routes.forEach((route) => {\n route.as(route.getName()!.replace(this.#routesBaseName, name), false)\n })\n\n this.#routesBaseName = name\n return this\n }\n}\n","/*\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 { debuglog } from 'node:util'\nexport default debuglog('adonisjs:http')\n","/*\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 { base64, MessageBuilder } from '@poppinss/utils'\n\n/**\n * Encodes a value into a base64 url encoded string to\n * be set as cookie\n */\nexport function pack(value: any): null | string {\n if (value === undefined || value === null) {\n return null\n }\n return base64.urlEncode(new MessageBuilder().build(value))\n}\n\n/**\n * Returns true when this `unpack` method of this module can attempt\n * to unpack the encode value.\n */\nexport function canUnpack(encodedValue: string) {\n return typeof encodedValue === 'string'\n}\n\n/**\n * Attempts to unpack the value by decoding it. Make sure to call, `canUnpack`\n * before calling this method\n */\nexport function unpack(encodedValue: string): null | any {\n return new MessageBuilder().verify(base64.urlDecode(encodedValue, 'utf-8', false))\n}\n","/*\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 type { Encryption } from '@adonisjs/encryption'\n\n/**\n * Signs a value to be shared as a cookie. The signed output has a\n * hash to verify tampering with the original value\n */\nexport function pack(key: string, value: any, encryption: Encryption): null | string {\n if (value === undefined || value === null) {\n return null\n }\n return `s:${encryption.verifier.sign(value, undefined, key)}`\n}\n\n/**\n * Returns a boolean, if the unpack method from this module can attempt\n * to unpack the signed value.\n */\nexport function canUnpack(signedValue: string) {\n return typeof signedValue === 'string' && signedValue.substring(0, 2) === 's:'\n}\n\n/**\n * Attempts to unpack the signed value. Make sure to call `canUnpack` before\n * calling this method.\n */\nexport function unpack(key: string, signedValue: string, encryption: Encryption): null | any {\n const value = signedValue.slice(2)\n if (!value) {\n return null\n }\n\n return encryption.verifier.unsign(value, key)\n}\n","/*\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 type { Encryption } from '@adonisjs/encryption'\n\n/**\n * Encrypt a value to be set as cookie\n */\nexport function pack(key: string, value: any, encryption: Encryption): null | string {\n if (value === undefined || value === null) {\n return null\n }\n return `e:${encryption.encrypt(value, undefined, key)}`\n}\n\n/**\n * Returns a boolean, if the unpack method from this module can attempt\n * to unpack encrypted value.\n */\nexport function canUnpack(encryptedValue: string) {\n return typeof encryptedValue === 'string' && encryptedValue.substring(0, 2) === 'e:'\n}\n\n/**\n * Attempts to unpack the encrypted cookie value. Returns null, when fails to do so.\n * Only call this method, when `canUnpack` returns true, otherwise runtime\n * exceptions can be raised.\n */\nexport function unpack(key: string, encryptedValue: string, encryption: Encryption): null | any {\n const value = encryptedValue.slice(2)\n if (!value) {\n return null\n }\n\n return encryption.decrypt(value, key)\n}\n","/*\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 type { Encryption } from '@adonisjs/encryption'\n\nimport * as plainCookiesDriver from './drivers/plain.js'\nimport * as signedCookiesDriver from './drivers/signed.js'\nimport * as encryptedCookiesDriver from './drivers/encrypted.js'\n\n/**\n * Cookie client exposes the API to parse/set AdonisJS cookies\n * as a client.\n */\nexport class CookieClient {\n #encryption: Encryption\n\n constructor(encryption: Encryption) {\n this.#encryption = encryption\n }\n\n /**\n * Encrypt a key value pair to be sent in the cookie header\n */\n encrypt(key: string, value: any): string | null {\n return encryptedCookiesDriver.pack(key, value, this.#encryption)\n }\n\n /**\n * Sign a key value pair to be sent in the cookie header\n */\n sign(key: string, value: any): string | null {\n return signedCookiesDriver.pack(key, value, this.#encryption)\n }\n\n /**\n * Encode a key value pair to be sent in the cookie header\n */\n encode(_: string, value: any): string | null {\n return plainCookiesDriver.pack(value)\n }\n\n /**\n * Unsign a signed cookie value\n */\n unsign(key: string, value: string) {\n return signedCookiesDriver.canUnpack(value)\n ? signedCookiesDriver.unpack(key, value, this.#encryption)\n : null\n }\n\n /**\n * Decrypt an encrypted cookie value\n */\n decrypt(key: string, value: string) {\n return encryptedCookiesDriver.canUnpack(value)\n ? encryptedCookiesDriver.unpack(key, value, this.#encryption)\n : null\n }\n\n /**\n * Decode an encoded cookie value\n */\n decode(_: string, value: string) {\n return plainCookiesDriver.canUnpack(value) ? plainCookiesDriver.unpack(value) : null\n }\n\n /**\n * Parse response cookie\n */\n parse(key: string, value: any) {\n /**\n * Unsign signed cookie\n */\n if (signedCookiesDriver.canUnpack(value)) {\n return signedCookiesDriver.unpack(key, value, this.#encryption)\n }\n\n /**\n * Decrypted encrypted cookie\n */\n if (encryptedCookiesDriver.canUnpack(value)) {\n return encryptedCookiesDriver.unpack(key, value, this.#encryption)\n }\n\n /**\n * Decode encoded cookie\n */\n if (plainCookiesDriver.canUnpack(value)) {\n return plainCookiesDriver.unpack(value)\n }\n }\n}\n","/*\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 fresh from 'fresh'\nimport typeIs from 'type-is'\nimport accepts from 'accepts'\nimport { isIP } from 'node:net'\nimport is from '@sindresorhus/is'\nimport proxyaddr from 'proxy-addr'\nimport { safeEqual } from '@poppinss/utils'\nimport Macroable from '@poppinss/macroable'\nimport lodash from '@poppinss/utils/lodash'\nimport { createId } from '@paralleldrive/cuid2'\nimport { parse, UrlWithStringQuery } from 'node:url'\nimport type { Encryption } from '@adonisjs/encryption'\nimport { ServerResponse, IncomingMessage, IncomingHttpHeaders } from 'node:http'\n\nimport type { Qs } from './qs.js'\nimport { trustProxy } from './helpers.js'\nimport { CookieParser } from './cookies/parser.js'\nimport { RequestConfig } from './types/request.js'\nimport type { HttpContext } from './http_context/main.js'\n\n/**\n * HTTP Request class exposes the interface to consistently read values\n * related to a given HTTP request. The class is wrapper over\n * [IncomingMessage](https://nodejs.org/api/http.html#http_class_http_incomingmessage)\n * and has extended API.\n *\n * You can access the original [IncomingMessage](https://nodejs.org/api/http.html#http_class_http_incomingmessage)\n * using `request.request` property.\n */\nexport class Request extends Macroable {\n /**\n * Query string parser\n */\n #qsParser: Qs\n\n /**\n * Encryption module to verify signed URLs and unsign/decrypt\n * cookies\n */\n #encryption: Encryption\n\n /**\n * Request config\n */\n #config: RequestConfig\n\n /**\n * Request body set using `setBody` method\n */\n #requestBody: Record<string, any> = {}\n\n /**\n * A merged copy of `request body` and `querystring`\n */\n #requestData: Record<string, any> = {}\n\n /**\n * Original merged copy of `request body` and `querystring`.\n * Further mutation to this object are not allowed\n */\n #originalRequestData: Record<string, any> = {}\n\n /**\n * Parsed query string\n */\n #requestQs: Record<string, any> = {}\n\n /**\n * Raw request body as text\n */\n #rawRequestBody?: string\n\n /**\n * Cached copy of `accepts` fn to do content\n * negotiation.\n */\n #lazyAccepts?: any\n\n /**\n * Copy of lazily parsed signed and plain cookies.\n */\n #cookieParser?: CookieParser\n\n /**\n * Parses copy of the URL with query string as a string and not\n * object. This is done to build URL's with query string without\n * stringifying the object\n */\n parsedUrl: UrlWithStringQuery\n\n /**\n * The ctx will be set by the context itself. It creates a circular\n * reference\n */\n ctx?: HttpContext\n\n constructor(\n public request: IncomingMessage,\n public response: ServerResponse,\n encryption: Encryption,\n config: RequestConfig,\n qsParser: Qs\n ) {\n super()\n\n this.#qsParser = qsParser\n this.#config = config\n this.#encryption = encryption\n this.parsedUrl = parse(this.request.url!, false)\n this.#parseQueryString()\n }\n\n /**\n * Parses the query string\n */\n #parseQueryString() {\n if (this.parsedUrl.query) {\n this.updateQs(this.#qsParser.parse(this.parsedUrl.query))\n this.#originalRequestData = { ...this.#requestData }\n }\n }\n\n /**\n * Initiates the cookie parser lazily\n */\n #initiateCookieParser() {\n if (!this.#cookieParser) {\n this.#cookieParser = new CookieParser(this.header('cookie')!, this.#encryption)\n }\n }\n\n /**\n * Lazily initiates the `accepts` module to make sure to parse\n * the request headers only when one of the content-negotiation\n * methods are used.\n */\n #initiateAccepts() {\n this.#lazyAccepts = this.#lazyAccepts || accepts(this.request)\n }\n\n /**\n * Returns the request id from the `x-request-id` header. The\n * header is untouched, if it already exists.\n */\n id(): string | undefined {\n let requestId = this.header('x-request-id')\n if (!requestId && this.#config.generateRequestId) {\n requestId = createId()\n this.request.headers['x-request-id'] = requestId\n }\n\n return requestId\n }\n\n /**\n * Set initial request body. A copy of the input will be maintained as the original\n * request body. Since the request body and query string is subject to mutations, we\n * keep one original reference to flash old data (whenever required).\n *\n * This method is supposed to be invoked by the body parser and must be called only\n * once. For further mutations make use of `updateBody` method.\n */\n setInitialBody(body: Record<string, any>) {\n if (this.#originalRequestData && Object.isFrozen(this.#originalRequestData)) {\n throw new Error('Cannot re-set initial body. Use \"request.updateBody\" instead')\n }\n\n this.updateBody(body)\n\n /*\n * Freeze the original object\n */\n this.#originalRequestData = Object.freeze(\n lodash.cloneDeepWith(this.#requestData, (value) => {\n if (is.primitive(value) || Array.isArray(value) || is.plainObject(value)) {\n return undefined\n }\n return null as any\n })\n )\n }\n\n /**\n * Update the request body with new data object. The `all` property\n * will be re-computed by merging the query string and request\n * body.\n */\n updateBody(body: Record<string, any>) {\n this.#requestBody = body\n this.#requestData = { ...this.#requestBody, ...this.#requestQs }\n }\n\n /**\n * Update the request raw body. Bodyparser sets this when unable to parse\n * the request body or when request is multipart/form-data.\n */\n updateRawBody(rawBody: string) {\n this.#rawRequestBody = rawBody\n }\n\n /**\n * Update the query string with the new data object. The `all` property\n * will be re-computed by merging the query and the request body.\n */\n updateQs(data: Record<string, any>) {\n this.#requestQs = data\n this.#requestData = { ...this.#requestBody, ...this.#requestQs }\n }\n\n /**\n * Returns route params\n */\n params(): Record<string, any> {\n return this.ctx?.params || {}\n }\n\n /**\n * Returns the query string object by reference\n */\n qs(): Record<string, any> {\n return this.#requestQs\n }\n\n /**\n * Returns reference to the request body\n */\n body(): Record<string, any> {\n return this.#requestBody\n }\n\n /**\n * Returns reference to the merged copy of request body\n * and query string\n */\n all(): Record<string, any> {\n return this.#requestData\n }\n\n /**\n * Returns reference to the merged copy of original request\n * query string and body\n */\n original(): Record<string, any> {\n return this.#originalRequestData\n }\n\n /**\n * Returns the request raw body (if exists), or returns `null`.\n *\n * Ideally you must be dealing with the parsed body accessed using [[input]], [[all]] or\n * [[post]] methods. The `raw` body is always a string.\n */\n raw(): string | null {\n return this.#rawRequestBody || null\n }\n\n /**\n * Returns value for a given key from the request body or query string.\n * The `defaultValue` is used when original value is `undefined`.\n *\n * @example\n * ```js\n * request.input('username')\n *\n * // with default value\n * request.input('username', 'virk')\n * ```\n */\n input(key: string, defaultValue?: any): any {\n return lodash.get(this.#requestData, key, defaultValue)\n }\n\n /**\n * Returns value for a given key from route params\n *\n * @example\n * ```js\n * request.param('id')\n *\n * // with default value\n * request.param('id', 1)\n * ```\n */\n param(key: string, defaultValue?: any): any {\n return lodash.get(this.params(), key, defaultValue)\n }\n\n /**\n * Get everything from the request body except the given keys.\n *\n * @example\n * ```js\n * request.except(['_csrf'])\n * ```\n */\n except(keys: string[]): Record<string, any> {\n return lodash.omit(this.#requestData, keys)\n }\n\n /**\n * Get value for specified keys.\n *\n * @example\n * ```js\n * request.only(['username', 'age'])\n * ```\n */\n only<T extends string>(keys: T[]): { [K in T]: any } {\n return lodash.pick(this.#requestData, keys) as { [K in T]: any }\n }\n\n /**\n * Returns the HTTP request method. This is the original\n * request method. For spoofed request method, make\n * use of [[method]].\n *\n * @example\n * ```js\n * request.intended()\n * ```\n */\n intended(): string {\n return this.request.method!\n }\n\n /**\n * Returns the request HTTP method by taking method spoofing into account.\n *\n * Method spoofing works when all of the following are true.\n *\n * 1. `app.http.allowMethodSpoofing` config value is true.\n * 2. request query string has `_method`.\n * 3. The [[intended]] request method is `POST`.\n *\n * @example\n * ```js\n * request.method()\n * ```\n */\n method(): string {\n if (this.#config.allowMethodSpoofing && this.intended() === 'POST') {\n return this.input('_method', this.intended()).toUpperCase()\n }\n return this.intended()\n }\n\n /**\n * Returns a copy of headers as an object\n */\n headers(): IncomingHttpHeaders {\n return this.request.headers\n }\n\n /**\n * Returns value for a given header key. The default value is\n * used when original value is `undefined`.\n */\n header(key: string, defaultValue?: any): string | undefined {\n key = key.toLowerCase()\n const headers = this.headers()\n\n switch (key) {\n case 'referer':\n case 'referrer':\n return headers.referrer || headers.referer || defaultValue\n default:\n return headers[key] || defaultValue\n }\n }\n\n /**\n * Returns the ip address of the user. This method is optimize to fetch\n * ip address even when running your AdonisJs app behind a proxy.\n *\n * You can also define your own custom function to compute the ip address by\n * defining `app.http.getIp` as a function inside the config file.\n *\n * ```js\n * {\n * http: {\n * getIp (request) {\n * // I am using nginx as a proxy server and want to trust 'x-real-ip'\n * return request.header('x-real-ip')\n * }\n * }\n * }\n * ```\n *\n * You can control the behavior of trusting the proxy values by defining it\n * inside the `config/app.js` file.\n *\n * ```js\n * {\n * http: {\n * trustProxy: '127.0.0.1'\n * }\n * }\n * ```\n *\n * The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)\n */\n ip(): string {\n const ipFn = this.#config.getIp\n if (typeof ipFn === 'function') {\n return ipFn(this)\n }\n\n return proxyaddr(this.request, this.#config.trustProxy)\n }\n\n /**\n * Returns an array of ip addresses from most to least trusted one.\n * This method is optimize to fetch ip address even when running\n * your AdonisJs app behind a proxy.\n *\n * You can control the behavior of trusting the proxy values by defining it\n * inside the `config/app.js` file.\n *\n * ```js\n * {\n * http: {\n * trustProxy: '127.0.0.1'\n * }\n * }\n * ```\n *\n * The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)\n */\n ips(): string[] {\n return proxyaddr.all(this.request, this.#config.trustProxy)\n }\n\n /**\n * Returns the request protocol by checking for the URL protocol or\n * `X-Forwarded-Proto` header.\n *\n * If the `trust` is evaluated to `false`, then URL protocol is returned,\n * otherwise `X-Forwarded-Proto` header is used (if exists).\n *\n * You can control the behavior of trusting the proxy values by defining it\n * inside the `config/app.js` file.\n *\n * ```js\n * {\n * http: {\n * trustProxy: '127.0.0.1'\n * }\n * }\n * ```\n *\n * The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)\n */\n protocol(): string {\n if ('encrypted' in this.request.socket) {\n return 'https'\n }\n\n if (!trustProxy(this.request.socket.remoteAddress!, this.#config.trustProxy)) {\n return this.parsedUrl.protocol || 'http'\n }\n\n const forwardedProtocol = this.header('X-Forwarded-Proto')\n return forwardedProtocol ? forwardedProtocol.split(/\\s*,\\s*/)[0] : 'http'\n }\n\n /**\n * Returns a boolean telling if request is served over `https`\n * or not. Check [[protocol]] method to know how protocol is\n * fetched.\n */\n secure(): boolean {\n return this.protocol() === 'https'\n }\n\n /**\n * Returns the request host. If proxy headers are trusted, then\n * `X-Forwarded-Host` is given priority over the `Host` header.\n *\n * You can control the behavior of trusting the proxy values by defining it\n * inside the `config/app.js` file.\n *\n * ```js\n * {\n * http: {\n * trustProxy: '127.0.0.1'\n * }\n * }\n * ```\n *\n * The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)\n */\n host(): string | null {\n let host = this.header('host')\n\n /*\n * Use X-Fowarded-Host when we trust the proxy header and it\n * exists\n */\n if (trustProxy(this.request.socket.remoteAddress!, this.#config.trustProxy)) {\n host = this.header('X-Forwarded-Host') || host\n }\n\n if (!host) {\n return null\n }\n\n return host\n }\n\n /**\n * Returns the request hostname. If proxy headers are trusted, then\n * `X-Forwarded-Host` is given priority over the `Host` header.\n *\n * You can control the behavior of trusting the proxy values by defining it\n * inside the `config/app.js` file.\n *\n * ```js\n * {\n * http: {\n * trustProxy: '127.0.0.1'\n * }\n * }\n * ```\n *\n * The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)\n */\n hostname(): string | null {\n const host = this.host()\n\n if (!host) {\n return null\n }\n\n /*\n * Support for IPv6\n * https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2\n * https://github.com/nodejs/node/pull/5314\n */\n const offset = host[0] === '[' ? host.indexOf(']') + 1 : 0\n const index = host.indexOf(':', offset)\n return index !== -1 ? host.substring(0, index) : host\n }\n\n /**\n * Returns an array of subdomains for the given host. An empty array is\n * returned if [[hostname]] is `null` or is an IP address.\n *\n * Also `www` is not considered as a subdomain\n */\n subdomains(): string[] {\n const hostname = this.hostname()\n\n /*\n * Return empty array when hostname is missing or it's\n * an IP address\n */\n if (!hostname || isIP(hostname)) {\n return []\n }\n\n const offset = this.#config.subdomainOffset\n const subdomains = hostname.split('.').reverse().slice(offset)\n\n /*\n * Remove www from the subdomains list\n */\n if (subdomains[subdomains.length - 1] === 'www') {\n subdomains.splice(subdomains.length - 1, 1)\n }\n\n return subdomains\n }\n\n /**\n * Returns a boolean telling, if request `X-Requested-With === 'xmlhttprequest'`\n * or not.\n */\n ajax(): boolean {\n const xRequestedWith = this.header('X-Requested-With', '')\n return xRequestedWith!.toLowerCase() === 'xmlhttprequest'\n }\n\n /**\n * Returns a boolean telling, if request has `X-Pjax` header\n * set or not\n */\n pjax(): boolean {\n return !!this.header('X-Pjax')\n }\n\n /**\n * Returns the request relative URL.\n *\n * @example\n * ```js\n * request.url()\n *\n * // include query string\n * request.url(true)\n * ```\n */\n url(includeQueryString?: boolean): string {\n const pathname = this.parsedUrl.pathname!\n return includeQueryString && this.parsedUrl.query\n ? `${pathname}?${this.parsedUrl.query}`\n : pathname\n }\n\n /**\n * Returns the complete HTTP url by combining\n * [[protocol]]://[[hostname]]/[[url]]\n *\n * @example\n * ```js\n * request.completeUrl()\n *\n * // include query string\n * request.completeUrl(true)\n * ```\n */\n completeUrl(includeQueryString?: boolean): string {\n const protocol = this.protocol()\n const hostname = this.host()\n return `${protocol}://${hostname}${this.url(includeQueryString)}`\n }\n\n /**\n * Find if the current HTTP request is for the given route or the routes\n */\n matchesRoute(routeIdentifier: string | string[]): boolean {\n /**\n * The context is missing inside the HTTP server hooks.\n */\n if (!this.ctx || !this.ctx.route) {\n return false\n }\n\n const route = this.ctx.route\n\n /**\n * Search the identifier(s) against the route \"pattern\", \"name\" and the route handler\n */\n return !!(Array.isArray(routeIdentifier) ? routeIdentifier : [routeIdentifier]).find(\n (identifier) => {\n if (route.pattern === identifier || route.name === identifier) {\n return true\n }\n\n if (typeof route.handler === 'function') {\n return false\n }\n\n return route.handler.reference === identifier\n }\n )\n }\n\n /**\n * Returns the best matching content type of the request by\n * matching against the given types.\n *\n * The content type is picked from the `content-type` header and request\n * must have body.\n *\n * The method response highly depends upon the types array values. Described below:\n *\n * | Type(s) | Return value |\n * |----------|---------------|\n * | ['json'] | json |\n * | ['application/*'] | application/json |\n * | ['vnd+json'] | application/json |\n *\n * @example\n * ```js\n * const bodyType = request.is(['json', 'xml'])\n *\n * if (bodyType === 'json') {\n * // process JSON\n * }\n *\n * if (bodyType === 'xml') {\n * // process XML\n * }\n * ```\n */\n is(types: string[]): string | null {\n return typeIs(this.request, types) || null\n }\n\n /**\n * Returns the best type using `Accept` header and\n * by matching it against the given types.\n *\n * If nothing is matched, then `null` will be returned\n *\n * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package\n * docs too.\n *\n * @example\n * ```js\n * switch (request.accepts(['json', 'html'])) {\n * case 'json':\n * return response.json(user)\n * case 'html':\n * return view.render('user', { user })\n * default:\n * // decide yourself\n * }\n * ```\n */\n accepts<T extends string>(types: T[]): T | null {\n this.#initiateAccepts()\n return this.#lazyAccepts.type(types) || null\n }\n\n /**\n * Return the types that the request accepts, in the order of the\n * client's preference (most preferred first).\n *\n * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package\n * docs too.\n */\n types(): string[] {\n this.#initiateAccepts()\n return this.#lazyAccepts.types()\n }\n\n /**\n * Returns the best language using `Accept-language` header\n * and by matching it against the given languages.\n *\n * If nothing is matched, then `null` will be returned\n *\n * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package\n * docs too.\n *\n * @example\n * ```js\n * switch (request.language(['fr', 'de'])) {\n * case 'fr':\n * return view.render('about', { lang: 'fr' })\n * case 'de':\n * return view.render('about', { lang: 'de' })\n * default:\n * return view.render('about', { lang: 'en' })\n * }\n * ```\n */\n language<T extends string>(languages: T[]): T | null {\n this.#initiateAccepts()\n return this.#lazyAccepts.language(languages) || null\n }\n\n /**\n * Return the languages that the request accepts, in the order of the\n * client's preference (most preferred first).\n *\n * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package\n * docs too.\n */\n languages(): string[] {\n this.#initiateAccepts()\n return this.#lazyAccepts.languages()\n }\n\n /**\n * Returns the best charset using `Accept-charset` header\n * and by matching it against the given charsets.\n *\n * If nothing is matched, then `null` will be returned\n *\n * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package\n * docs too.\n *\n * @example\n * ```js\n * switch (request.charset(['utf-8', 'ISO-8859-1'])) {\n * case 'utf-8':\n * // make utf-8 friendly response\n * case 'ISO-8859-1':\n * // make ISO-8859-1 friendly response\n * }\n * ```\n */\n charset<T extends string>(charsets: T[]): T | null {\n this.#initiateAccepts()\n return this.#lazyAccepts.charset(charsets) || null\n }\n\n /**\n * Return the charsets that the request accepts, in the order of the\n * client's preference (most preferred first).\n *\n * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package\n * docs too.\n */\n charsets(): string[] {\n this.#initiateAccepts()\n return this.#lazyAccepts.charsets()\n }\n\n /**\n * Returns the best encoding using `Accept-encoding` header\n * and by matching it against the given encodings.\n *\n * If nothing is matched, then `null` will be returned\n *\n * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package\n * docs too.\n */\n encoding<T extends string>(encodings: T[]): T | null {\n this.#initiateAccepts()\n return this.#lazyAccepts.encoding(encodings) || null\n }\n\n /**\n * Return the charsets that the request accepts, in the order of the\n * client's preference (most preferred first).\n *\n * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package\n * docs too.\n */\n encodings(): string[] {\n this.#initiateAccepts()\n return this.#lazyAccepts.encodings()\n }\n\n /**\n * Returns a boolean telling if request has body\n */\n hasBody(): boolean {\n return typeIs.hasBody(this.request)\n }\n\n /**\n * Returns a boolean telling if the new response etag evaluates same\n * as the request header `if-none-match`. In case of `true`, the\n * server must return `304` response, telling the browser to\n * use the client cache.\n *\n * You won't have to deal with this method directly, since AdonisJs will\n * handle this for you when `http.etag = true` inside `config/app.js` file.\n *\n * However, this is how you can use it manually.\n *\n * ```js\n * const responseBody = view.render('some-view')\n *\n * // sets the HTTP etag header for response\n * response.setEtag(responseBody)\n *\n * if (request.fresh()) {\n * response.sendStatus(304)\n * } else {\n * response.send(responseBody)\n * }\n * ```\n */\n fresh(): boolean {\n if (['GET', 'HEAD'].indexOf(this.intended()) === -1) {\n return false\n }\n\n const status = this.response.statusCode\n if ((status >= 200 && status < 300) || status === 304) {\n return fresh(this.headers(), this.response.getHeaders())\n }\n\n return false\n }\n\n /**\n * Opposite of [[fresh]]\n */\n stale(): boolean {\n return !this.fresh()\n }\n\n /**\n * Returns all parsed and signed cookies. Signed cookies ensures\n * that their value isn't tampered.\n */\n cookiesList() {\n this.#initiateCookieParser()\n return this.#cookieParser!.list()\n }\n\n /**\n * Returns value for a given key from signed cookies. Optional\n * defaultValue is returned when actual value is undefined.\n */\n cookie(key: string, defaultValue?: string): any {\n this.#initiateCookieParser()\n return this.#cookieParser!.unsign(key) || defaultValue\n }\n\n /**\n * Returns value for a given key from signed cookies. Optional\n * defaultValue is returned when actual value is undefined.\n */\n encryptedCookie(key: string, defaultValue?: string): any {\n this.#initiateCookieParser()\n return this.#cookieParser!.decrypt(key) || defaultValue\n }\n\n /**\n * Returns value for a given key from unsigned cookies. Optional\n * defaultValue is returned when actual value is undefined.\n */\n plainCookie(key: string, options?: { defaultValue?: string; encoded?: boolean }): any\n plainCookie(key: string, defaultValue?: string, encoded?: boolean): any\n plainCookie(\n key: string,\n defaultValueOrOptions?: string | { defaultValue?: string; encoded?: boolean },\n encoded?: boolean\n ): any {\n this.#initiateCookieParser()\n\n if (is.object(defaultValueOrOptions)) {\n return (\n this.#cookieParser!.decode(key, defaultValueOrOptions?.encoded) ||\n defaultValueOrOptions.defaultValue\n )\n }\n\n return this.#cookieParser!.decode(key, encoded) || defaultValueOrOptions\n }\n\n /**\n * Returns a boolean telling if a signed url as a valid signature\n * or not.\n */\n hasValidSignature(purpose?: string) {\n const { signature, ...rest } = this.qs()\n if (!signature) {\n return false\n }\n\n /*\n * Return false when signature fails\n */\n const signedUrl = this.#encryption.verifier.unsign(signature, purpose)\n if (!signedUrl) {\n return false\n }\n\n const queryString = this.#qsParser.stringify(rest)\n\n return queryString\n ? safeEqual(signedUrl, `${this.url()}?${queryString}`)\n : safeEqual(signedUrl, this.url())\n }\n\n /**\n * Serializes request to JSON format\n */\n serialize() {\n return {\n id: this.id(),\n url: this.url(),\n query: this.parsedUrl.query,\n body: this.all(),\n params: this.params(),\n headers: this.headers(),\n method: this.method(),\n protocol: this.protocol(),\n cookies: this.cookiesList(),\n hostname: this.hostname(),\n ip: this.ip(),\n subdomains: this.ctx?.subdomains || {},\n }\n }\n\n /**\n * toJSON copy of the request\n */\n toJSON() {\n return this.serialize()\n }\n}\n","/*\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 cookie from 'cookie'\nimport type { Encryption } from '@adonisjs/encryption'\n\nimport { CookieClient } from './client.js'\n\n/**\n * Cookie parser parses the HTTP `cookie` header and collects all cookies\n * inside an object of `key-value` pair, but doesn't attempt to decrypt\n * or unsign or decode the individual values.\n *\n * The cookie values are lazily decrypted, or unsigned to avoid unncessary\n * processing, which infact can be used as a means to burden the server\n * by sending too many cookies which even doesn't belongs to the\n * server.\n */\nexport class CookieParser {\n #client: CookieClient\n\n /**\n * A copy of cached cookies, they are cached during a request after\n * initial decoding, unsigning or decrypting.\n */\n #cachedCookies: {\n encryptedCookies: Record<string, any>\n signedCookies: Record<string, any>\n plainCookies: Record<string, any>\n } = {\n signedCookies: {},\n plainCookies: {},\n encryptedCookies: {},\n }\n\n /**\n * An object of key-value pair collected by parsing\n * the request cookie header.\n */\n #cookies: Record<string, any>\n\n constructor(cookieHeader: string, encryption: Encryption) {\n this.#client = new CookieClient(encryption)\n this.#cookies = this.#parse(cookieHeader)\n }\n\n /**\n * Parses the request `cookie` header\n */\n #parse(cookieHeader?: string) {\n /*\n * Set to empty object when cookie header is empty string\n */\n if (!cookieHeader) {\n return {}\n }\n\n /*\n * Parse and store reference\n */\n return cookie.parse(cookieHeader)\n }\n\n /**\n * Attempts to decode a cookie by the name. When calling this method,\n * you are assuming that the cookie was just encoded in the first\n * place and not signed or encrypted.\n */\n decode(key: string, encoded = true): any | null {\n /*\n * Ignore when initial value is not defined or null\n */\n const value = this.#cookies[key]\n if (value === null || value === undefined) {\n return null\n }\n\n /*\n * Reference to the cache object. Mainly done to avoid typos,\n * since this object is referenced a handful of times inside\n * this method.\n */\n const cache = this.#cachedCookies.plainCookies\n\n /*\n * Return from cache, when already parsed\n */\n if (cache[key] !== undefined) {\n return cache[key]\n }\n\n /*\n * Attempt to unpack and cache it for future. The value is only\n * when value it is not null.\n */\n const parsed = encoded ? this.#client.decode(key, value) : value\n if (parsed !== null) {\n cache[key] = parsed\n }\n\n return parsed\n }\n\n /**\n * Attempts to unsign a cookie by the name. When calling this method,\n * you are assuming that the cookie was signed in the first place.\n */\n unsign(key: string): null | any {\n /*\n * Ignore when initial value is not defined or null\n */\n const value = this.#cookies[key]\n if (value === null || value === undefined) {\n return null\n }\n\n /*\n * Reference to the cache object. Mainly done to avoid typos,\n * since this object is referenced a handful of times inside\n * this method.\n */\n const cache = this.#cachedCookies.signedCookies\n\n /*\n * Return from cache, when already parsed\n */\n if (cache[key] !== undefined) {\n return cache[key]\n }\n\n /*\n * Attempt to unpack and cache it for future. The value is only\n * when value it is not null.\n */\n const parsed = this.#client.unsign(key, value)\n if (parsed !== null) {\n cache[key] = parsed\n }\n\n return parsed\n }\n\n /**\n * Attempts to decrypt a cookie by the name. When calling this method,\n * you are assuming that the cookie was encrypted in the first place.\n */\n decrypt(key: string): null | any {\n /*\n * Ignore when initial value is not defined or null\n */\n const value = this.#cookies[key]\n if (value === null || value === undefined) {\n return null\n }\n\n /*\n * Reference to the cache object. Mainly done to avoid typos,\n * since this object is referenced a handful of times inside\n * this method.\n */\n const cache = this.#cachedCookies.encryptedCookies\n\n /*\n * Return from cache, when already parsed\n */\n if (cache[key] !== undefined) {\n return cache[key]\n }\n\n /*\n * Attempt to unpack and cache it for future. The value is only\n * when value it is not null.\n */\n const parsed = this.#client.decrypt(key, value)\n if (parsed !== null) {\n cache[key] = parsed\n }\n\n return parsed\n }\n\n /**\n * Returns an object of cookies key-value pair. Do note, the\n * cookies are not decoded, unsigned or decrypted inside this\n * list.\n */\n list() {\n return this.#cookies\n }\n}\n","/*\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 { parse } from 'node:url'\nimport encodeUrl from 'encodeurl'\nimport type { IncomingMessage } from 'node:http'\n\nimport debug from './debug.js'\nimport type { Qs } from './qs.js'\nimport type { Response } from './response.js'\nimport type { Router } from './router/main.js'\nimport type { MakeUrlOptions } from './types/route.js'\n\n/**\n * Exposes the API to construct redirect routes\n */\nexport class Redirect {\n /**\n * A boolean to forward the existing query string\n */\n #forwardQueryString = false\n\n /**\n * The status code for the redirect\n */\n #statusCode = 302\n\n /**\n * A custom query string to forward\n */\n #queryString: Record<string, any> = {}\n\n #request: IncomingMessage\n #response: Response\n #router: Router\n #qs: Qs\n\n constructor(request: IncomingMessage, response: Response, router: Router, qs: Qs) {\n this.#request = request\n this.#response = response\n this.#router = router\n this.#qs = qs\n }\n\n /**\n * Sends response by setting require headers\n */\n #sendResponse(url: string, query: Record<string, any>) {\n const stringified = this.#qs.stringify(query)\n\n url = stringified ? `${url}?${stringified}` : url\n debug('redirecting to url \"%s\"', url)\n\n this.#response.location(encodeUrl(url))\n this.#response.safeStatus(this.#statusCode)\n this.#response.type('text/plain; charset=utf-8')\n this.#response.send(`Redirecting to ${url}`)\n }\n\n /**\n * Returns the referrer url\n */\n #getReferrerUrl(): string {\n let url = this.#request.headers['referer'] || this.#request.headers['referrer'] || '/'\n return Array.isArray(url) ? url[0] : url\n }\n\n /**\n * Set a custom status code.\n */\n status(statusCode: number): this {\n this.#statusCode = statusCode\n return this\n }\n\n /**\n * Clearing query string values added using the\n * \"withQs\" method\n */\n clearQs(): this {\n this.#forwardQueryString = false\n this.#queryString = {}\n return this\n }\n\n /**\n * Define query string for the redirect. Not passing\n * any value will forward the current request query\n * string.\n */\n withQs(): this\n withQs(values: Record<string, any>): this\n withQs(name: string, value: any): this\n withQs(name?: Record<string, any> | string, value?: any): this {\n if (typeof name === 'undefined') {\n this.#forwardQueryString = true\n return this\n }\n\n if (typeof name === 'string') {\n this.#queryString[name] = value\n return this\n }\n\n Object.assign(this.#queryString, name)\n return this\n }\n\n /**\n * Redirect to the previous path.\n */\n back() {\n let query: Record<string, any> = {}\n\n const referrerUrl = this.#getReferrerUrl()\n const url = parse(referrerUrl)\n\n debug('referrer url \"%s\"', referrerUrl)\n debug('referrer base url \"%s\"', url.pathname)\n\n /**\n * Parse query string from the referrer url\n */\n if (this.#forwardQueryString) {\n query = this.#qs.parse(url.query || '')\n }\n\n /**\n * Append custom query string\n */\n Object.assign(query, this.#queryString)\n\n /**\n * Redirect\n */\n this.#sendResponse(url.pathname || '', query)\n }\n\n /**\n * Redirect the request using a route identifier.\n */\n toRoute(routeIdentifier: string, params?: any[] | Record<string, any>, options?: MakeUrlOptions) {\n if (options && options.qs) {\n this.withQs(options.qs)\n options.qs = undefined\n }\n\n const url = this.#router.makeUrl(routeIdentifier, params, options)\n return this.toPath(url)\n }\n\n /**\n * Redirect the request using a path.\n */\n toPath(url: string) {\n let query: Record<string, any> = {}\n\n /**\n * Extract query string from the current URL\n */\n if (this.#forwardQueryString) {\n query = this.#qs.parse(parse(this.#request.url!).query || '')\n }\n\n /**\n * Assign custom query string\n */\n Object.assign(query, this.#queryString)\n\n /**\n * Redirect\n */\n this.#sendResponse(url, query)\n }\n}\n","/*\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 { createError, Exception } from '@poppinss/utils'\nimport type { HttpContext } from './http_context/main.js'\n\nexport const E_ROUTE_NOT_FOUND = createError<[method: string, url: string]>(\n 'Cannot %s:%s',\n 'E_ROUTE_NOT_FOUND',\n 404\n)\n\nexport const E_CANNOT_LOOKUP_ROUTE = createError<[routeIdentifier: string]>(\n 'Cannot lookup route \"%s\"',\n 'E_CANNOT_LOOKUP_ROUTE',\n 500\n)\n\nexport const E_HTTP_EXCEPTION = class HttpException extends Exception {\n body: any\n static code = 'E_HTTP_EXCEPTION'\n\n /**\n * This method returns an instance of the exception class\n */\n static invoke(body: any, status: number, code: string = 'E_HTTP_EXCEPTION'): HttpException {\n if (body === null || body === undefined) {\n const error = new this('HTTP Exception', { status, code })\n error.body = 'Internal server error'\n return error\n }\n\n if (typeof body === 'object') {\n const error = new this(body.message || 'HTTP Exception', { status, code })\n error.body = body\n return error\n }\n\n const error = new this(body, { status, code })\n error.body = body\n return error\n }\n}\n\nexport const E_HTTP_REQUEST_ABORTED = class AbortException extends E_HTTP_EXCEPTION {\n handle(error: AbortException, ctx: HttpContext) {\n ctx.response.status(error.status).send(error.body)\n }\n}\n","/*\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\nexport const ResponseStatus = {\n Continue: 100,\n SwitchingProtocols: 101,\n Processing: 102,\n EarlyHints: 103,\n Ok: 200,\n Created: 201,\n Accepted: 202,\n NonAuthoritativeInformation: 203,\n NoContent: 204,\n ResetContent: 205,\n PartialContent: 206,\n MultiStatus: 207,\n AlreadyReported: 208,\n IMUsed: 226,\n MultipleChoices: 300,\n MovedPermanently: 301,\n Found: 302,\n SeeOther: 303,\n NotModified: 304,\n UseProxy: 305,\n TemporaryRedirect: 307,\n PermanentRedirect: 308,\n BadRequest: 400,\n Unauthorized: 401,\n PaymentRequired: 402,\n Forbidden: 403,\n NotFound: 404,\n MethodNotAllowed: 405,\n NotAcceptable: 406,\n ProxyAuthenticationRequired: 407,\n RequestTimeout: 408,\n Conflict: 409,\n Gone: 410,\n LengthRequired: 411,\n PreconditionFailed: 412,\n PayloadTooLarge: 413,\n URITooLong: 414,\n UnsupportedMediaType: 415,\n RangeNotSatisfiable: 416,\n ExpectationFailed: 417,\n ImATeapot: 418,\n MisdirectedRequest: 421,\n UnprocessableEntity: 422,\n Locked: 423,\n FailedDependency: 424,\n TooEarly: 425,\n UpgradeRequired: 426,\n PreconditionRequired: 428,\n TooManyRequests: 429,\n RequestHeaderFieldsTooLarge: 431,\n UnavailableForLegalReasons: 451,\n InternalServerError: 500,\n NotImplemented: 501,\n BadGateway: 502,\n ServiceUnavailable: 503,\n GatewayTimeout: 504,\n HTTPVersionNotSupported: 505,\n VariantAlsoNegotiates: 506,\n InsufficientStorage: 507,\n LoopDetected: 508,\n NotExtended: 510,\n NetworkAuthenticationRequired: 511,\n} as const\n","/*\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 { Buffer } from 'node:buffer'\nimport etag from 'etag'\nimport vary from 'vary'\nimport fresh from 'fresh'\nimport mime from 'mime-types'\nimport destroy from 'destroy'\nimport { extname } from 'node:path'\nimport onFinished from 'on-finished'\nimport json from '@poppinss/utils/json'\nimport Macroable from '@poppinss/macroable'\nimport { createReadStream } from 'node:fs'\nimport { stat } from 'node:fs/promises'\nimport { RuntimeException } from '@poppinss/utils'\nimport contentDisposition from 'content-disposition'\nimport type { Encryption } from '@adonisjs/encryption'\nimport { ServerResponse, IncomingMessage, OutgoingHttpHeaders } from 'node:http'\n\nimport type { Qs } from './qs.js'\nimport { Redirect } from './redirect.js'\nimport type { Router } from './router/main.js'\nimport type { HttpContext } from './http_context/main.js'\nimport { CookieSerializer } from './cookies/serializer.js'\nimport { E_HTTP_REQUEST_ABORTED } from './exceptions.js'\nimport type {\n CastableHeader,\n CookieOptions,\n ResponseConfig,\n ResponseStream,\n} from './types/response.js'\nimport { ResponseStatus } from './response_status.js'\n\nconst CACHEABLE_HTTP_METHODS = ['GET', 'HEAD']\n\n/**\n * The response is a wrapper over [ServerResponse](https://nodejs.org/api/http.html#http_class_http_serverresponse)\n * streamlining the process of writing response body and automatically setting up appropriate headers.\n */\nexport class Response extends Macroable {\n /**\n * Query string parser\n */\n #qs: Qs\n\n /**\n * Outgoing headers\n */\n #headers: OutgoingHttpHeaders = {}\n\n /**\n * Has explicit status been set\n */\n #hasExplicitStatus = false\n\n /**\n * Cookies serializer to serialize the outgoing cookies\n */\n #cookieSerializer: CookieSerializer\n\n /**\n * Router is used to make the redirect URLs from routes\n */\n #router: Router\n\n /**\n * Response config\n */\n #config: ResponseConfig\n\n /**\n * Does response has body set that will written to the\n * response socket at the end of the request\n */\n get hasLazyBody(): boolean {\n return !!(this.lazyBody.content || this.lazyBody.fileToStream || this.lazyBody.stream)\n }\n\n /**\n * Find if the response has non-stream content\n */\n get hasContent(): boolean {\n return !!this.lazyBody.content\n }\n\n /**\n * Returns true when response body is set using \"response.stream\"\n * method\n */\n get hasStream(): boolean {\n return !!this.lazyBody.stream\n }\n\n /**\n * Returns true when response body is set using \"response.download\"\n * or \"response.attachment\" methods\n */\n get hasFileToStream(): boolean {\n return !!this.lazyBody.fileToStream\n }\n\n /**\n * Returns the response content. Check if the response\n * has content using the \"hasContent\" method\n */\n get content() {\n return this.lazyBody.content\n }\n\n /**\n * Returns reference to the stream set using \"response.stream\"\n * method\n */\n get outgoingStream() {\n return this.lazyBody.stream?.[0]\n }\n\n /**\n * Returns reference to the file path set using \"response.stream\"\n * method.\n */\n get fileToStream() {\n return this.lazyBody.fileToStream\n ? {\n path: this.lazyBody.fileToStream[0],\n generateEtag: this.lazyBody.fileToStream[1],\n }\n : undefined\n }\n\n /**\n * Lazy body is used to set the response body. However, do not\n * write it on the socket immediately unless `response.finish`\n * is called.\n */\n lazyBody: Partial<{\n content: [any, boolean, string?]\n stream: [ResponseStream, ((error: NodeJS.ErrnoException) => [string, number?])?]\n fileToStream: [string, boolean, ((error: NodeJS.ErrnoException) => [string, number?])?]\n }> = {}\n\n /**\n * The ctx will be set by the context itself. It creates a circular\n * reference\n */\n ctx?: HttpContext\n\n constructor(\n public request: IncomingMessage,\n public response: ServerResponse,\n encryption: Encryption,\n config: ResponseConfig,\n router: Router,\n qs: Qs\n ) {\n super()\n\n this.#qs = qs\n this.#config = config\n this.#router = router\n this.#cookieSerializer = new CookieSerializer(encryption)\n }\n\n /**\n * Returns a boolean telling if response is finished or not.\n * Any more attempts to update headers or body will result\n * in raised exceptions.\n */\n get finished(): boolean {\n return this.response.writableFinished\n }\n\n /**\n * Returns a boolean telling if response headers has been sent or not.\n * Any more attempts to update headers will result in raised\n * exceptions.\n */\n get headersSent(): boolean {\n return this.response.headersSent\n }\n\n /**\n * Returns a boolean telling if response headers and body is written\n * or not. When value is `true`, you can feel free to write headers\n * and body.\n */\n get isPending(): boolean {\n return !this.headersSent && !this.finished\n }\n\n /**\n * Normalizes header value to a string or an array of string\n */\n #castHeaderValue(value: any): string | string[] {\n return Array.isArray(value) ? value.map(String) : String(value)\n }\n\n /**\n * Ends the response by flushing headers and writing body\n */\n #endResponse(body?: any, statusCode?: number) {\n this.writeHead(statusCode)\n\n // avoid ArgumentsAdaptorTrampoline from V8 (inspired by fastify)\n const res = this.response as any\n res.end(body, null, null)\n }\n\n /**\n * Returns type for the content body. Only following types are allowed\n *\n * - Dates\n * - Arrays\n * - Booleans\n * - Objects\n * - Strings\n * - Buffer\n */\n #getDataType(content: any) {\n if (content instanceof Uint8Array) {\n return 'buffer'\n }\n\n /**\n * Date instance\n */\n if (content instanceof Date) {\n return 'date'\n }\n\n /**\n * Regular expression\n */\n if (content instanceof RegExp) {\n return 'regexp'\n }\n\n const dataType = typeof content\n if (\n dataType === 'number' ||\n dataType === 'boolean' ||\n dataType === 'string' ||\n dataType === 'bigint'\n ) {\n return dataType\n }\n\n /**\n * Object\n */\n if (dataType === 'object') {\n return 'object'\n }\n\n throw new RuntimeException(`Cannot serialize \"${dataType}\" to HTTP response`)\n }\n\n /**\n * Writes the body with appropriate response headers. Etag header is set\n * when `generateEtag` is set to `true`.\n *\n * Empty body results in `204`.\n */\n protected writeBody(content: any, generateEtag: boolean, jsonpCallbackName?: string): void {\n const hasEmptyBody = content === null || content === undefined || content === ''\n\n /**\n * Set status to \"204\" when body is empty. The `safeStatus` method only\n * sets the status when no explicit status has been set already\n */\n if (hasEmptyBody) {\n this.safeStatus(204)\n }\n\n const statusCode = this.response.statusCode\n\n /**\n * Do not process body when status code is less than 200 or is 204 or 304. As per\n * https://tools.ietf.org/html/rfc7230#section-3.3.2\n */\n if (\n statusCode &&\n (statusCode < ResponseStatus.Ok ||\n statusCode === ResponseStatus.NoContent ||\n statusCode === ResponseStatus.NotModified)\n ) {\n this.removeHeader('Content-Type')\n this.removeHeader('Content-Length')\n this.removeHeader('Transfer-Encoding')\n this.#endResponse()\n return\n }\n\n /**\n * Body is empty and status code is not \"204\", \"304\" and neither under 200.\n */\n if (hasEmptyBody) {\n this.removeHeader('Content-Length')\n this.#endResponse()\n return\n }\n\n /**\n * Javascript data type for the content. We only handle a subset\n * of data types. Check [[this.getDataType]] method for more\n * info\n */\n const dataType = this.#getDataType(content)\n\n /**\n * ----------------------------------------\n * SERIALIZE CONTENT TO A STRING\n * ----------------------------------------\n *\n * Transforming date, number, boolean and object to a string\n */\n if (dataType === 'object') {\n content = json.safeStringify(content)\n } else if (\n dataType === 'number' ||\n dataType === 'boolean' ||\n dataType === 'bigint' ||\n dataType === 'regexp'\n ) {\n content = String(content)\n } else if (dataType === 'date') {\n content = content.toISOString()\n }\n\n /*\n * ----------------------------------------\n * MORE MODIFICATIONS FOR JSONP BODY\n * ----------------------------------------\n *\n * If JSONP callback exists, then update the body to be a\n * valid JSONP response\n */\n if (jsonpCallbackName) {\n /*\n * replace chars not allowed in JavaScript that are in JSON\n * https://github.com/rack/rack-contrib/pull/37\n */\n content = content.replace(/\\u2028/g, '\\\\u2028').replace(/\\u2029/g, '\\\\u2029')\n\n // the /**/ is a specific security mitigation for \"Rosetta Flash JSONP abuse\"\n // https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-4671\n // http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/\n // http://drops.wooyun.org/tips/2554\n content = `/**/ typeof ${jsonpCallbackName} === 'function' && ${jsonpCallbackName}(${content});`\n }\n\n /*\n * ----------------------------------------\n * FINALY GENERATE AN ETAG\n * ----------------------------------------\n *\n * Generate etag if instructed.\n */\n if (generateEtag) {\n this.setEtag(content)\n }\n\n /**\n * End response when cache is fresh\n */\n if (generateEtag && this.fresh()) {\n this.removeHeader('Content-Type')\n this.removeHeader('Content-Length')\n this.removeHeader('Transfer-Encoding')\n this.#endResponse(null, ResponseStatus.NotModified)\n return\n }\n\n /*\n * ----------------------------------------\n * SET X-REQUEST-ID HEADER\n * ----------------------------------------\n */\n this.setRequestId()\n\n /*\n * ----------------------------------------\n * SET CONTENT-LENGTH HEADER\n * ----------------------------------------\n */\n this.header('Content-Length', Buffer.byteLength(content))\n\n /**\n * ----------------------------------------\n * SET CONTENT-TYPE HEADER\n * ----------------------------------------\n *\n * - If it is a JSONP response, then we always set the content type\n * to \"text/javascript\"\n *\n * - String are checked for HTML and \"text/plain\" or \"text/html\" is set\n * accordingly.\n *\n * - \"text/plain\" is set for \"numbers\" and \"booleans\" and \"dates\"\n *\n * - \"application/octet-stream\" is set for buffers\n *\n * - \"application/json\" is set for objects and arrays\n */\n if (jsonpCallbackName) {\n this.header('X-Content-Type-Options', 'nosniff')\n this.safeHeader('Content-Type', 'text/javascript; charset=utf-8')\n } else {\n switch (dataType) {\n case 'string':\n const type = /^\\s*</.test(content) ? 'text/html' : 'text/plain'\n this.safeHeader('Content-Type', `${type}; charset=utf-8`)\n break\n case 'number':\n case 'boolean':\n case 'date':\n case 'bigint':\n case 'regexp':\n this.safeHeader('Content-Type', 'text/plain; charset=utf-8')\n break\n case 'buffer':\n this.safeHeader('Content-Type', 'application/octet-stream; charset=utf-8')\n break\n case 'object':\n this.safeHeader('Content-Type', 'application/json; charset=utf-8')\n break\n }\n }\n\n this.#endResponse(content)\n }\n\n /**\n * Stream the body to the response and handles cleaning up the stream\n */\n protected streamBody(\n body: ResponseStream,\n errorCallback?: (error: NodeJS.ErrnoException) => [string, number?]\n ): Promise<void> {\n return new Promise((resolve) => {\n let finished = false\n\n /*\n * Listen for errors on the stream and properly destroy\n * stream\n */\n body.on('error', (error: NodeJS.ErrnoException) => {\n /* c8 ignore next 3 */\n if (finished) {\n return\n }\n\n finished = true\n destroy(body)\n\n this.type('text')\n\n if (!this.headersSent) {\n if (typeof errorCallback === 'function') {\n this.#endResponse(...errorCallback(error))\n } else {\n this.#endResponse(\n error.code === 'ENOENT' ? 'File not found' : 'Cannot process file',\n error.code === 'ENOENT' ? ResponseStatus.NotFound : ResponseStatus.InternalServerError\n )\n }\n } else {\n this.response.destroy()\n }\n\n resolve()\n })\n\n /*\n * Listen for end and resolve the promise\n */\n body.on('end', () => {\n if (!this.headersSent) {\n this.#endResponse()\n }\n resolve()\n })\n\n /*\n * Cleanup stream when finishing response\n */\n onFinished(this.response, () => {\n finished = true\n destroy(body)\n })\n\n /*\n * Pipe stream\n */\n this.relayHeaders()\n body.pipe(this.response)\n })\n }\n\n /**\n * Downloads a file by streaming it to the response\n */\n protected async streamFileForDownload(\n filePath: string,\n generateEtag: boolean,\n errorCallback?: (error: NodeJS.ErrnoException) => [string, number?]\n ) {\n try {\n const stats = await stat(filePath)\n if (!stats || !stats.isFile()) {\n throw new TypeError('response.download only accepts path to a file')\n }\n\n /*\n * Set appropriate headers\n */\n this.header('Last-Modified', stats.mtime.toUTCString())\n this.type(extname(filePath))\n\n /*\n * Set the etag when instructed.\n */\n if (generateEtag) {\n this.setEtag(stats, true)\n }\n\n /*\n * Do not stream files for HEAD request, but set the appropriate\n * status code.\n *\n * 200: When not using etags or cache is not fresh. This forces browser\n * to always make a GET request\n *\n * 304: When etags are used and cache is fresh\n */\n if (this.request.method === 'HEAD') {\n this.#endResponse(\n null,\n generateEtag && this.fresh() ? ResponseStatus.NotModified : ResponseStatus.Ok\n )\n return\n }\n\n /*\n * Regardless of request method, if we are using etags and\n * cache is fresh, then we must respond with 304\n */\n if (generateEtag && this.fresh()) {\n this.#endResponse(null, ResponseStatus.NotModified)\n return\n }\n\n /*\n * Fix for https://tools.ietf.org/html/rfc7232#section-4.1. It is\n * recommended to ignore headers other than Cache-Control,\n * Content-Location, Date, ETag, Expires, and Vary.\n */\n this.header('Content-length', stats.size)\n\n /*\n * Finally stream the file\n */\n return this.streamBody(createReadStream(filePath), errorCallback)\n } catch (error) {\n this.type('text')\n this.removeHeader('Etag')\n\n if (typeof errorCallback === 'function') {\n this.#endResponse(...errorCallback(error))\n } else {\n this.#endResponse(\n error.code === 'ENOENT' ? 'File not found' : 'Cannot process file',\n error.code === 'ENOENT' ? ResponseStatus.NotFound : ResponseStatus.InternalServerError\n )\n }\n }\n }\n\n /**\n * Listen for the event the response is written\n * to the TCP socket.\n *\n * Under the hood the callback is registered with\n * the \"https://github.com/jshttp/on-finished\" package\n */\n onFinish(callback: (err: Error | null, response: ServerResponse) => void) {\n onFinished(this.response, callback)\n }\n\n /**\n * Writes headers with the Node.js res object using the\n * response.setHeader method\n */\n relayHeaders() {\n if (!this.headersSent) {\n for (let key in this.#headers) {\n const value = this.#headers[key]\n if (value) {\n this.response.setHeader(key, value)\n }\n }\n }\n }\n\n /**\n * Calls res.writeHead on the Node.js res object.\n */\n writeHead(statusCode?: number): this {\n this.response.writeHead(statusCode || this.response.statusCode, this.#headers)\n return this\n }\n\n /**\n * Returns the existing value for a given HTTP response\n * header.\n */\n getHeader(key: string) {\n const value = this.#headers[key.toLowerCase()]\n return value === undefined ? this.response.getHeader(key) : value\n }\n\n /**\n * Get response headers\n */\n getHeaders() {\n return {\n ...this.response.getHeaders(),\n ...this.#headers,\n }\n }\n\n /**\n * Set header on the response. To `append` values to the existing header, we suggest\n * using [[append]] method.\n *\n * If `value` is non existy, then header won't be set.\n *\n * @example\n * ```js\n * response.header('content-type', 'application/json')\n * ```\n */\n header(key: string, value: CastableHeader): this {\n if (value === null || value === undefined) {\n return this\n }\n\n this.#headers[key.toLowerCase()] = this.#castHeaderValue(value)\n return this\n }\n\n /**\n * Append value to an existing header. To replace the value, we suggest using\n * [[header]] method.\n *\n * If `value` is not existy, then header won't be set.\n *\n * @example\n * ```js\n * response.append('set-cookie', 'username=virk')\n * ```\n */\n append(key: string, value: CastableHeader): this {\n if (value === null || value === undefined) {\n return this\n }\n\n key = key.toLowerCase()\n\n let existingHeader = this.getHeader(key)\n let casted = this.#castHeaderValue(value)\n\n /**\n * If there isn't any header, then setHeader right\n * away\n */\n if (!existingHeader) {\n this.#headers[key] = casted\n return this\n }\n\n existingHeader = this.#castHeaderValue(existingHeader)\n casted = Array.isArray(existingHeader)\n ? existingHeader.concat(casted)\n : [existingHeader].concat(casted)\n\n this.#headers[key] = casted\n return this\n }\n\n /**\n * Adds HTTP response header, when it doesn't exists already.\n */\n safeHeader(key: string, value: CastableHeader): this {\n if (!this.getHeader(key)) {\n this.header(key, value)\n }\n return this\n }\n\n /**\n * Removes the existing response header from being sent.\n */\n removeHeader(key: string): this {\n key = key.toLowerCase()\n\n this.response.removeHeader(key)\n if (this.#headers[key]) {\n delete this.#headers[key.toLowerCase()]\n }\n\n return this\n }\n\n /**\n * Returns the status code for the response\n */\n getStatus(): number {\n return this.response.statusCode\n }\n\n /**\n * Set HTTP status code\n */\n status(code: number): this {\n this.#hasExplicitStatus = true\n this.response.statusCode = code\n return this\n }\n\n /**\n * Set's status code only when it's not explictly\n * set\n */\n safeStatus(code: number): this {\n if (this.#hasExplicitStatus) {\n return this\n }\n\n this.response.statusCode = code\n return this\n }\n\n /**\n * Set response type by looking up for the mime-type using\n * partial types like file extensions.\n *\n * Make sure to read [mime-types](https://www.npmjs.com/package/mime-types) docs\n * too.\n *\n * @example\n * ```js\n * response.type('.json') // Content-type: application/json\n * ```\n */\n type(type: string, charset?: string): this {\n type = charset ? `${type}; charset=${charset}` : type\n this.header('Content-Type', mime.contentType(type))\n\n return this\n }\n\n /**\n * Set the Vary HTTP header\n */\n vary(field: string | string[]): this {\n vary(this.response, field)\n return this\n }\n\n /**\n * Set etag by computing hash from the body. This class will set the etag automatically\n * when `etag = true` in the defined config object.\n *\n * Use this function, when you want to compute etag manually for some other resons.\n */\n setEtag(body: any, weak: boolean = false): this {\n this.header('Etag', etag(body, { weak }))\n return this\n }\n\n /**\n * Set X-Request-Id header by copying the header value from the request if it exists.\n *\n */\n setRequestId(): this {\n const requestId = this.request.headers['x-request-id']\n if (requestId) {\n this.header('X-Request-Id', requestId)\n }\n return this\n }\n\n /**\n * Returns a boolean telling if the new response etag evaluates same\n * as the request header `if-none-match`. In case of `true`, the\n * server must return `304` response, telling the browser to\n * use the client cache.\n *\n * You won't have to deal with this method directly, since AdonisJs will\n * handle this for you when `http.etag = true` inside `config/app.js` file.\n *\n * However, this is how you can use it manually.\n *\n * @example\n * ```js\n * const responseBody = view.render('some-view')\n *\n * // sets the HTTP etag header for response\n * response.setEtag(responseBody)\n *\n * if (response.fresh()) {\n * response.sendStatus(304)\n * } else {\n * response.send(responseBody)\n * }\n * ```\n */\n fresh(): boolean {\n if (this.request.method && !CACHEABLE_HTTP_METHODS.includes(this.request.method)) {\n return false\n }\n\n const status = this.response.statusCode\n if (\n (status >= ResponseStatus.Ok && status < ResponseStatus.MultipleChoices) ||\n status === ResponseStatus.NotModified\n ) {\n return fresh(this.request.headers, this.#headers)\n }\n\n return false\n }\n\n /**\n * Returns the response body. Returns null when response\n * body is a stream\n */\n getBody() {\n if (this.lazyBody.content) {\n return this.lazyBody.content[0]\n }\n\n return null\n }\n\n /**\n * Send the body as response and optionally generate etag. The default value\n * is read from `config/app.js` file, using `http.etag` property.\n *\n * This method buffers the body if `explicitEnd = true`, which is the default\n * behavior and do not change, unless you know what you are doing.\n */\n send(body: any, generateEtag: boolean = this.#config.etag): void {\n this.lazyBody.content = [body, generateEtag]\n }\n\n /**\n * Alias of [[send]]\n */\n json(body: any, generateEtag: boolean = this.#config.etag): void {\n return this.send(body, generateEtag)\n }\n\n /**\n * Writes response as JSONP. The callback name is resolved as follows, with priority\n * from top to bottom.\n *\n * 1. Explicitly defined as 2nd Param.\n * 2. Fetch from request query string.\n * 3. Use the config value `http.jsonpCallbackName` from `config/app.js`.\n * 4. Fallback to `callback`.\n *\n * This method buffers the body if `explicitEnd = true`, which is the default\n * behavior and do not change, unless you know what you are doing.\n */\n jsonp(\n body: any,\n callbackName: string = this.#config.jsonpCallbackName,\n generateEtag: boolean = this.#config.etag\n ) {\n this.lazyBody.content = [body, generateEtag, callbackName]\n }\n\n /**\n * Pipe stream to the response. This method will gracefully destroy\n * the stream, avoiding memory leaks.\n *\n * If `raiseErrors=false`, then this method will self handle all the exceptions by\n * writing a generic HTTP response. To have more control over the error, it is\n * recommended to set `raiseErrors=true` and wrap this function inside a\n * `try/catch` statement.\n *\n * Streaming a file from the disk and showing 404 when file is missing.\n *\n * @example\n * ```js\n * // Errors handled automatically with generic HTTP response\n * response.stream(fs.createReadStream('file.txt'))\n *\n * // Manually handle (note the await call)\n * try {\n * await response.stream(fs.createReadStream('file.txt'))\n * } catch () {\n * response.status(404).send('File not found')\n * }\n * ```\n */\n stream(\n body: ResponseStream,\n errorCallback?: (error: NodeJS.ErrnoException) => [string, number?]\n ): void {\n if (typeof body.pipe !== 'function' || !body.readable || typeof body.read !== 'function') {\n throw new TypeError('response.stream accepts a readable stream only')\n }\n\n this.lazyBody.stream = [body, errorCallback]\n }\n\n /**\n * Download file by streaming it from the file path. This method will setup\n * appropriate `Content-type`, `Content-type` and `Last-modified` headers.\n *\n * Unexpected stream errors are handled gracefully to avoid memory leaks.\n *\n * If `raiseErrors=false`, then this method will self handle all the exceptions by\n * writing a generic HTTP response. To have more control over the error, it is\n * recommended to set `raiseErrors=true` and wrap this function inside a\n * `try/catch` statement.\n *\n * @example\n * ```js\n * // Errors handled automatically with generic HTTP response\n * response.download('somefile.jpg')\n *\n * // Manually handle (note the await call)\n * try {\n * await response.download('somefile.jpg')\n * } catch (error) {\n * response.status(error.code === 'ENOENT' ? 404 : 500)\n * response.send('Cannot process file')\n * }\n * ```\n */\n download(\n filePath: string,\n generateEtag: boolean = this.#config.etag,\n errorCallback?: (error: NodeJS.ErrnoException) => [string, number?]\n ): void {\n this.lazyBody.fileToStream = [filePath, generateEtag, errorCallback]\n }\n\n /**\n * Download the file by forcing the user to save the file vs displaying it\n * within the browser.\n *\n * Internally calls [[download]]\n */\n attachment(\n filePath: string,\n name?: string,\n disposition?: string,\n generateEtag?: boolean,\n errorCallback?: (error: NodeJS.ErrnoException) => [string, number?]\n ) {\n name = name || filePath\n this.header('Content-Disposition', contentDisposition(name, { type: disposition }))\n return this.download(filePath, generateEtag, errorCallback)\n }\n\n /**\n * Set the location header.\n *\n * @example\n * ```js\n * response.location('/login')\n * ```\n */\n location(url: string): this {\n this.header('Location', url)\n return this\n }\n\n /**\n * Redirect the request.\n *\n * @example\n * ```js\n * response.redirect('/foo')\n * response.redirect().toRoute('foo.bar')\n * response.redirect().back()\n * ```\n */\n redirect(): Redirect\n redirect(path: string, forwardQueryString?: boolean, statusCode?: number): void\n redirect(\n path?: string,\n forwardQueryString: boolean = false,\n statusCode: number = ResponseStatus.Found\n ): Redirect | void {\n const handler = new Redirect(this.request, this, this.#router, this.#qs)\n\n if (forwardQueryString) {\n handler.withQs()\n }\n\n if (path === 'back') {\n return handler.status(statusCode).back()\n }\n\n if (path) {\n return handler.status(statusCode).toPath(path)\n }\n\n return handler\n }\n\n /**\n * Abort the request with custom body and a status code. 400 is\n * used when status is not defined\n */\n abort(body: any, status?: number): never {\n throw E_HTTP_REQUEST_ABORTED.invoke(body, status || ResponseStatus.BadRequest)\n }\n\n /**\n * Abort the request with custom body and a status code when\n * passed condition returns `true`\n */\n abortIf(\n condition: unknown,\n body: any,\n status?: number\n ): asserts condition is undefined | null | false {\n if (condition) {\n this.abort(body, status)\n }\n }\n\n /**\n * Abort the request with custom body and a status code when\n * passed condition returns `false`\n */\n abortUnless<T>(\n condition: T,\n body: any,\n status?: number\n ): asserts condition is Exclude<T, undefined | null | false> {\n if (!condition) {\n this.abort(body, status)\n }\n }\n\n /**\n * Set signed cookie as the response header. The inline options overrides\n * all options from the config.\n */\n cookie(key: string, value: any, options?: Partial<CookieOptions>): this {\n options = Object.assign({}, this.#config.cookie, options)\n\n const serialized = this.#cookieSerializer.sign(key, value, options)\n if (!serialized) {\n return this\n }\n\n this.append('set-cookie', serialized)\n return this\n }\n\n /**\n * Set encrypted cookie as the response header. The inline options overrides\n * all options from the config.\n */\n encryptedCookie(key: string, value: any, options?: Partial<CookieOptions>): this {\n options = Object.assign({}, this.#config.cookie, options)\n\n const serialized = this.#cookieSerializer.encrypt(key, value, options)\n if (!serialized) {\n return this\n }\n\n this.append('set-cookie', serialized)\n return this\n }\n\n /**\n * Set unsigned cookie as the response header. The inline options overrides\n * all options from the config.\n */\n plainCookie(\n key: string,\n value: any,\n options?: Partial<CookieOptions & { encode: boolean }>\n ): this {\n options = Object.assign({}, this.#config.cookie, options)\n\n const serialized = this.#cookieSerializer.encode(key, value, options)\n if (!serialized) {\n return this\n }\n\n this.append('set-cookie', serialized)\n return this\n }\n\n /**\n * Clear existing cookie.\n */\n clearCookie(key: string, options?: Partial<CookieOptions>): this {\n options = Object.assign({}, this.#config.cookie, options)\n options.expires = new Date(1)\n options.maxAge = -1\n\n const serialized = this.#cookieSerializer.encode(key, '', { ...options, encode: false })\n this.append('set-cookie', serialized!)\n return this\n }\n\n /**\n * Finishes the response by writing the lazy body, when `explicitEnd = true`\n * and response is already pending.\n *\n * Calling this method twice or when `explicitEnd = false` is noop.\n */\n finish() {\n if (!this.isPending) {\n return\n }\n\n if (this.content) {\n this.writeBody(...this.content)\n return\n }\n\n if (this.lazyBody.stream) {\n this.streamBody(...this.lazyBody.stream)\n return\n }\n\n if (this.lazyBody.fileToStream) {\n this.streamFileForDownload(...this.lazyBody.fileToStream)\n return\n }\n\n this.#endResponse()\n }\n\n /**\n * Shorthand method to finish request with \"100\" status code\n */\n continue(): void {\n this.status(ResponseStatus.Continue)\n return this.send(null, false)\n }\n\n /**\n * Shorthand method to finish request with \"101\" status code\n */\n switchingProtocols(): void {\n this.status(ResponseStatus.SwitchingProtocols)\n return this.send(null, false)\n }\n\n /**\n * Shorthand method to finish request with \"200\" status code\n */\n ok(body: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.Ok)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"201\" status code\n */\n created(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.Created)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"202\" status code\n */\n accepted(body: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.Accepted)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"203\" status code\n */\n nonAuthoritativeInformation(body: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.NonAuthoritativeInformation)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"204\" status code\n */\n noContent(): void {\n this.status(ResponseStatus.NoContent)\n return this.send(null, false)\n }\n\n /**\n * Shorthand method to finish request with \"205\" status code\n */\n resetContent(): void {\n this.status(ResponseStatus.ResetContent)\n return this.send(null, false)\n }\n\n /**\n * Shorthand method to finish request with \"206\" status code\n */\n partialContent(body: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.PartialContent)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"300\" status code\n */\n multipleChoices(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.MultipleChoices)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"301\" status code\n */\n movedPermanently(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.MovedPermanently)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"302\" status code\n */\n movedTemporarily(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.Found)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"303\" status code\n */\n seeOther(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.SeeOther)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"304\" status code\n */\n notModified(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.NotModified)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"305\" status code\n */\n useProxy(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.UseProxy)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"307\" status code\n */\n temporaryRedirect(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.TemporaryRedirect)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"400\" status code\n */\n badRequest(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.BadRequest)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"401\" status code\n */\n unauthorized(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.Unauthorized)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"402\" status code\n */\n paymentRequired(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.PaymentRequired)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"403\" status code\n */\n forbidden(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.Forbidden)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"404\" status code\n */\n notFound(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.NotFound)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"405\" status code\n */\n methodNotAllowed(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.MethodNotAllowed)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"406\" status code\n */\n notAcceptable(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.NotAcceptable)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"407\" status code\n */\n proxyAuthenticationRequired(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.ProxyAuthenticationRequired)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"408\" status code\n */\n requestTimeout(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.RequestTimeout)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"409\" status code\n */\n conflict(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.Conflict)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"401\" status code\n */\n gone(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.Gone)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"411\" status code\n */\n lengthRequired(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.LengthRequired)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"412\" status code\n */\n preconditionFailed(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.PreconditionFailed)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"413\" status code\n */\n requestEntityTooLarge(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.PayloadTooLarge)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"414\" status code\n */\n requestUriTooLong(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.URITooLong)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"415\" status code\n */\n unsupportedMediaType(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.UnsupportedMediaType)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"416\" status code\n */\n requestedRangeNotSatisfiable(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.RangeNotSatisfiable)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"417\" status code\n */\n expectationFailed(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.ExpectationFailed)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"422\" status code\n */\n unprocessableEntity(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.UnprocessableEntity)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"429\" status code\n */\n tooManyRequests(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.TooManyRequests)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"500\" status code\n */\n internalServerError(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.InternalServerError)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"501\" status code\n */\n notImplemented(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.NotImplemented)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"502\" status code\n */\n badGateway(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.BadGateway)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"503\" status code\n */\n serviceUnavailable(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.ServiceUnavailable)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"504\" status code\n */\n gatewayTimeout(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.GatewayTimeout)\n return this.send(body, generateEtag)\n }\n\n /**\n * Shorthand method to finish request with \"505\" status code\n */\n httpVersionNotSupported(body?: any, generateEtag?: boolean): void {\n this.status(ResponseStatus.HTTPVersionNotSupported)\n return this.send(body, generateEtag)\n }\n}\n","/*\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 cookie from 'cookie'\nimport string from '@poppinss/utils/string'\nimport type { Encryption } from '@adonisjs/encryption'\n\nimport { CookieClient } from './client.js'\nimport type { CookieOptions } from '../types/response.js'\n\n/**\n * Cookies serializer is used to serialize a value to be set on the `Set-Cookie`\n * header. You can `encode`, `sign` on `encrypt` cookies using the serializer\n * and then set them individually using the `set-cookie` header.\n */\nexport class CookieSerializer {\n #client: CookieClient\n\n constructor(encryption: Encryption) {\n this.#client = new CookieClient(encryption)\n }\n\n /**\n * Serializes the key-value pair to a string, that can be set on the\n * `Set-Cookie` header.\n */\n #serializeAsCookie(key: string, value: string, options?: Partial<CookieOptions>) {\n /**\n * Invoked expires method to get the date\n */\n let expires = options?.expires\n if (typeof expires === 'function') {\n expires = expires()\n }\n\n /**\n * Parse string based max age to seconds\n */\n let maxAge = options?.maxAge ? string.seconds.parse(options?.maxAge) : undefined\n\n const parsedOptions = Object.assign({}, options, { maxAge, expires })\n return cookie.serialize(key, value, parsedOptions)\n }\n\n /**\n * Encodes value as a plain cookie. By default, the plain value will be converted\n * to a string using \"JSON.stringify\" method and then encoded as a base64 string.\n *\n * You can disable encoding of the cookie by setting `options.encoded = false`.\n *\n * ```ts\n * serializer.encode('name', 'virk')\n * ```\n */\n encode(\n key: string,\n value: any,\n options?: Partial<CookieOptions & { encode: boolean }>\n ): string | null {\n const packedValue = options?.encode === false ? value : this.#client.encode(key, value)\n if (packedValue === null || packedValue === undefined) {\n return null\n }\n\n return this.#serializeAsCookie(key, packedValue, options)\n }\n\n /**\n * Sign a key-value pair to a signed cookie. The signed value has a\n * verification hash attached to it to detect data tampering.\n */\n sign(key: string, value: any, options?: Partial<CookieOptions>): string | null {\n const packedValue = this.#client.sign(key, value)\n if (packedValue === null) {\n return null\n }\n\n return this.#serializeAsCookie(key, packedValue, options)\n }\n\n /**\n * Encrypts a key-value pair to an encrypted cookie.\n */\n encrypt(key: string, value: any, options?: Partial<CookieOptions>): string | null {\n const packedValue = this.#client.encrypt(key, value)\n if (packedValue === null) {\n return null\n }\n\n return this.#serializeAsCookie(key, packedValue, options)\n }\n}\n","/*\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 { moduleImporter } from '@adonisjs/fold'\nimport { RuntimeException } from '@poppinss/utils'\nimport type { Encryption } from '@adonisjs/encryption'\nimport type { Application } from '@adonisjs/application'\n\nimport type { Qs } from '../qs.js'\nimport { Route } from './route.js'\nimport { RouteGroup } from './group.js'\nimport { BriskRoute } from './brisk.js'\nimport { RoutesStore } from './store.js'\nimport { toRoutesJSON } from '../helpers.js'\nimport { RouteResource } from './resource.js'\nimport { LookupStore } from './lookup_store/main.js'\nimport { RouteMatchers as Matchers } from './matchers.js'\nimport type { Constructor, LazyImport } from '../types/base.js'\nimport { defineNamedMiddleware } from '../define_middleware.js'\nimport type { MiddlewareAsClass, ParsedGlobalMiddleware } from '../types/middleware.js'\n\nimport type {\n RouteFn,\n MatchedRoute,\n RouteMatcher,\n RouteMatchers,\n MakeUrlOptions,\n MakeSignedUrlOptions,\n GetControllerHandlers,\n} from '../types/route.js'\nimport debug from '../debug.js'\nimport { parseRoutePattern } from './parser.js'\n\n/**\n * Router class exposes a unified API to register new routes, group them or\n * create route resources.\n *\n * ```ts\n * const router = new Router()\n *\n * router.get('/', async function () {\n * // handle request\n * })\n * ```\n */\nexport class Router extends LookupStore {\n #commited: boolean = false\n\n /**\n * Application is needed to resolve string based controller expressions\n */\n #app: Application<any>\n\n /**\n * Store with tokenized routes\n */\n #store: RoutesStore = new RoutesStore()\n\n /**\n * Global matchers to test route params against regular expressions.\n */\n #globalMatchers: RouteMatchers = {}\n\n /**\n * Middleware store to be shared with the routes\n */\n #middleware: ParsedGlobalMiddleware[] = []\n\n /**\n * A boolean to tell the router that a group is in\n * open state right now\n */\n #openedGroups: RouteGroup[] = []\n\n /**\n * Collection of routes, including route resource and route\n * group. To get a flat list of routes, call `router.toJSON()`\n */\n routes: (Route | RouteResource | RouteGroup | BriskRoute)[] = []\n\n /**\n * A flag to know if routes for explicit domains have been registered.\n * The boolean is computed after calling the \"commit\" method.\n */\n usingDomains: boolean = false\n\n /**\n * Shortcut methods for commonly used route matchers\n */\n matchers = new Matchers()\n\n /**\n * Check if routes have been committed to the store. Once\n * routes are committed, defining new set of routes will\n * have no impact\n */\n get commited() {\n return this.#commited\n }\n\n constructor(app: Application<any>, encryption: Encryption, qsParser: Qs) {\n super(encryption, qsParser)\n this.#app = app\n }\n\n /**\n * Push a give router entity to the list of routes or the\n * recently opened group.\n */\n #pushToRoutes(entity: Route | RouteResource | RouteGroup | BriskRoute) {\n const openedGroup = this.#openedGroups[this.#openedGroups.length - 1]\n if (openedGroup) {\n openedGroup.routes.push(entity)\n return\n }\n\n this.routes.push(entity)\n }\n\n /**\n * Parses the route pattern\n */\n parsePattern(pattern: string, matchers?: RouteMatchers) {\n return parseRoutePattern(pattern, matchers)\n }\n\n /**\n * Define an array of middleware to use on all the routes.\n * Calling this method multiple times pushes to the\n * existing list of middleware\n */\n use(middleware: LazyImport<MiddlewareAsClass>[]): this {\n middleware.forEach((one) =>\n this.#middleware.push(moduleImporter(one, 'handle').toHandleMethod())\n )\n\n return this\n }\n\n /**\n * Define a collection of named middleware. The defined collection is\n * not registered anywhere, but instead converted in a new collection\n * of functions you can apply on the routes, or router groups.\n */\n named<NamedMiddleware extends Record<string, LazyImport<MiddlewareAsClass>>>(\n collection: NamedMiddleware\n ) {\n return defineNamedMiddleware<NamedMiddleware>(collection)\n }\n\n /**\n * Add route for a given pattern and methods\n */\n route<T extends Constructor<any>>(\n pattern: string,\n methods: string[],\n handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]\n ) {\n const route = new Route(this.#app, this.#middleware, {\n pattern,\n methods,\n handler,\n globalMatchers: this.#globalMatchers,\n })\n\n this.#pushToRoutes(route)\n return route\n }\n\n /**\n * Define a route that handles all common HTTP methods\n */\n any<T extends Constructor<any>>(\n pattern: string,\n handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]\n ) {\n return this.route(\n pattern,\n ['HEAD', 'OPTIONS', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE'],\n handler\n )\n }\n\n /**\n * Define `GET` route\n */\n get<T extends Constructor<any>>(\n pattern: string,\n handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]\n ) {\n return this.route(pattern, ['GET', 'HEAD'], handler)\n }\n\n /**\n * Define `POST` route\n */\n post<T extends Constructor<any>>(\n pattern: string,\n handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]\n ) {\n return this.route(pattern, ['POST'], handler)\n }\n\n /**\n * Define `PUT` route\n */\n put<T extends Constructor<any>>(\n pattern: string,\n handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]\n ) {\n return this.route(pattern, ['PUT'], handler)\n }\n\n /**\n * Define `PATCH` route\n */\n patch<T extends Constructor<any>>(\n pattern: string,\n handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]\n ) {\n return this.route(pattern, ['PATCH'], handler)\n }\n\n /**\n * Define `DELETE` route\n */\n delete<T extends Constructor<any>>(\n pattern: string,\n handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]\n ) {\n return this.route(pattern, ['DELETE'], handler)\n }\n\n /**\n * Creates a group of routes. A route group can apply transforms\n * to routes in bulk\n */\n group(callback: () => void) {\n /*\n * Create a new group with empty set of routes\n */\n const group = new RouteGroup([])\n\n /**\n * Track group\n */\n this.#pushToRoutes(group)\n\n /*\n * Track the group, so that the upcoming calls inside the callback\n * can use this group\n */\n this.#openedGroups.push(group)\n\n /*\n * Execute the callback. Now all registered routes will be\n * collected seperately from the `routes` array\n */\n callback()\n\n /*\n * Now the callback is over, get rid of the opened group\n */\n this.#openedGroups.pop()\n\n return group\n }\n\n /**\n * Registers a route resource with conventional set of routes\n */\n resource(resource: string, controller: string | LazyImport<Constructor<any>> | Constructor<any>) {\n const resourceInstance = new RouteResource(this.#app, this.#middleware, {\n resource,\n controller,\n shallow: false,\n globalMatchers: this.#globalMatchers,\n })\n\n this.#pushToRoutes(resourceInstance)\n return resourceInstance\n }\n\n /**\n * Register a route resource with shallow nested routes.\n */\n shallowResource(\n resource: string,\n controller: string | LazyImport<Constructor<any>> | Constructor<any>\n ) {\n const resourceInstance = new RouteResource(this.#app, this.#middleware, {\n resource,\n controller,\n shallow: true,\n globalMatchers: this.#globalMatchers,\n })\n\n this.#pushToRoutes(resourceInstance)\n return resourceInstance\n }\n\n /**\n * Returns a brisk route instance for a given URL pattern\n */\n on(pattern: string) {\n const briskRoute = new BriskRoute(this.#app, this.#middleware, {\n pattern,\n globalMatchers: this.#globalMatchers,\n })\n\n this.#pushToRoutes(briskRoute)\n return briskRoute\n }\n\n /**\n * Define matcher for a given param. The global params are applied\n * on all the routes (unless overridden at the route level).\n */\n where(param: string, matcher: RouteMatcher | string | RegExp): this {\n if (typeof matcher === 'string') {\n this.#globalMatchers[param] = { match: new RegExp(matcher) }\n } else if (is.regExp(matcher)) {\n this.#globalMatchers[param] = { match: matcher }\n } else {\n this.#globalMatchers[param] = matcher\n }\n\n return this\n }\n\n /**\n * Commit routes to the store. The router is freezed after the\n * commit method is called.\n */\n commit() {\n if (this.#commited) {\n return\n }\n\n debug('Committing routes to the routes store')\n const routeNamesByDomain: Map<string, Set<string>> = new Map()\n\n toRoutesJSON(this.routes).forEach((route) => {\n if (!routeNamesByDomain.has(route.domain)) {\n routeNamesByDomain.set(route.domain, new Set())\n }\n\n const routeNames = routeNamesByDomain.get(route.domain)!\n\n /*\n * Raise error when route name is already in use. Route names have to be unique\n * to ensure that only one route is returned during lookup.\n */\n if (route.name && routeNames.has(route.name)) {\n throw new RuntimeException(\n `Route with duplicate name found. A route with name \"${route.name}\" already exists`\n )\n }\n\n /*\n * If route has a unique, then track the name for checking duplicates\n */\n if (route.name) {\n routeNames.add(route.name)\n }\n\n /**\n * Register the route with the lookup store\n */\n this.register(route)\n this.#store.add(route)\n })\n\n routeNamesByDomain.clear()\n\n this.usingDomains = this.#store.usingDomains\n this.routes = []\n this.#globalMatchers = {}\n this.#middleware = []\n this.#commited = true\n }\n\n /**\n * Find route for a given URL, method and optionally domain\n */\n match(url: string, method: string, hostname?: string | null): null | MatchedRoute {\n const matchingDomain = this.#store.matchDomain(hostname)\n\n return matchingDomain.length\n ? this.#store.match(url, method, {\n tokens: matchingDomain,\n hostname: hostname!,\n })\n : this.#store.match(url, method)\n }\n\n /**\n * Make URL to a pre-registered route\n */\n makeUrl(\n routeIdentifier: string,\n params?: any[] | Record<string, any>,\n options?: MakeUrlOptions\n ): string {\n const normalizedOptions = Object.assign({}, options)\n\n const builder = normalizedOptions.domain\n ? this.builderForDomain(normalizedOptions.domain)\n : this.builder()\n\n builder.params(params)\n builder.qs(normalizedOptions.qs)\n\n normalizedOptions.prefixUrl && builder.prefixUrl(normalizedOptions.prefixUrl)\n normalizedOptions.disableRouteLookup && builder.disableRouteLookup()\n\n return builder.make(routeIdentifier)\n }\n\n /**\n * Makes a signed URL to a pre-registered route.\n */\n makeSignedUrl(\n routeIdentifier: string,\n params?: any[] | Record<string, any>,\n options?: MakeSignedUrlOptions\n ): string {\n const normalizedOptions = Object.assign({}, options)\n\n const builder = normalizedOptions.domain\n ? this.builderForDomain(normalizedOptions.domain)\n : this.builder()\n\n builder.params(params)\n builder.qs(normalizedOptions.qs)\n\n normalizedOptions.prefixUrl && builder.prefixUrl(normalizedOptions.prefixUrl)\n normalizedOptions.disableRouteLookup && builder.disableRouteLookup()\n\n return builder.makeSigned(routeIdentifier, normalizedOptions)\n }\n}\n","/*\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\n// @ts-expect-error\nimport matchit from '@poppinss/matchit'\nimport lodash from '@poppinss/utils/lodash'\nimport { RuntimeException } from '@poppinss/utils'\nimport type {\n RouteJSON,\n MatchedRoute,\n StoreRouteNode,\n StoreDomainNode,\n StoreMethodNode,\n StoreRoutesTree,\n MatchItRouteToken,\n} from '../types/route.js'\nimport { parseRoutePattern } from './parser.js'\nimport debug from '../debug.js'\n\n/**\n * Store class is used to store a list of routes, along side with their tokens\n * to match the URLs.\n *\n * ```ts\n * const store = new Store()\n *\n * store.add({\n * pattern: 'posts/:id',\n * handler: function onRoute () {},\n * middleware: [],\n * matchers: {\n * id: '^[0-9]$+'\n * },\n * meta: {},\n * methods: ['GET']\n * })\n *\n * store.match('posts/1', 'GET')\n * ```\n */\nexport class RoutesStore {\n /**\n * A flag to know if routes for explicit domains\n * have been registered\n */\n usingDomains: boolean = false\n\n /**\n * Tree of registered routes and their matchit tokens\n */\n tree: StoreRoutesTree = { tokens: [], domains: {} }\n\n /**\n * Returns the domain node for a given domain.\n */\n #getDomainNode(domain: string): StoreDomainNode {\n if (!this.tree.domains[domain]) {\n this.tree.tokens.push(parseRoutePattern(domain))\n this.tree.domains[domain] = {}\n }\n\n return this.tree.domains[domain]\n }\n\n /**\n * Returns the method node for a given domain and method.\n */\n #getMethodNode(domain: string, method: string): StoreMethodNode {\n const domainNode = this.#getDomainNode(domain)\n if (!domainNode[method]) {\n domainNode[method] = { tokens: [], routes: {}, routeKeys: {} }\n }\n\n return domainNode[method]\n }\n\n /**\n * Collects route params\n */\n #collectRouteParams(route: StoreRouteNode, tokens: MatchItRouteToken[]) {\n const collectedParams: Set<string> = new Set()\n\n for (let token of tokens) {\n if ([1, 3].includes(token.type)) {\n if (collectedParams.has(token.val)) {\n throw new RuntimeException(`Duplicate param \"${token.val}\" found in \"${route.pattern}\"`)\n } else {\n collectedParams.add(token.val)\n }\n }\n }\n\n const params = [...collectedParams]\n collectedParams.clear()\n\n return params\n }\n\n /**\n * Register route for a given domain and method\n */\n #registerRoute(\n domain: string,\n method: string,\n tokens: MatchItRouteToken[],\n route: StoreRouteNode\n ) {\n const methodRoutes = this.#getMethodNode(domain, method)\n\n /*\n * Check for duplicate route for the same domain and method\n */\n if (methodRoutes.routes[route.pattern]) {\n throw new RuntimeException(\n `Duplicate route found. \"${method}: ${route.pattern}\" route already exists`\n )\n }\n\n if (debug.enabled) {\n debug('registering route to the store %O', route)\n debug('route middleware %O', route.middleware.all().entries())\n }\n\n methodRoutes.tokens.push(tokens)\n methodRoutes.routes[route.pattern] = route\n methodRoutes.routeKeys[route.pattern] =\n domain !== 'root' ? `${domain}-${method}-${route.pattern}` : `${method}-${route.pattern}`\n }\n\n /**\n * Add a route to the store\n *\n * ```ts\n * store.add({\n * pattern: 'post/:id',\n * methods: ['GET'],\n * matchers: {},\n * meta: {},\n * handler: function handler () {\n * }\n * })\n * ```\n */\n add(route: RouteJSON): this {\n /**\n * Set flag when a custom domain is used\n */\n if (route.domain !== 'root') {\n this.usingDomains = true\n }\n\n /**\n * Generate tokens for the route\n */\n const tokens = parseRoutePattern(route.pattern, route.matchers)\n\n /**\n * Create route node object for persistence\n */\n const routeNode: StoreRouteNode = lodash.merge(\n { meta: {} },\n lodash.pick(route, ['pattern', 'handler', 'meta', 'middleware', 'name', 'execute'])\n )\n\n /**\n * Set route params\n */\n routeNode.meta.params = this.#collectRouteParams(routeNode, tokens)\n\n /**\n * Register route for every method\n */\n route.methods.forEach((method) => {\n this.#registerRoute(route.domain, method, tokens, routeNode)\n })\n\n return this\n }\n\n /**\n * Matches the url, method and optionally domain to pull the matching\n * route. `null` is returned when unable to match the URL against\n * registered routes.\n *\n * The domain parameter has to be a registered pattern and not the fully\n * qualified runtime domain. You must call `matchDomain` first to fetch\n * the pattern for qualified domain\n */\n match(\n url: string,\n method: string,\n domain?: { tokens: MatchItRouteToken[]; hostname: string }\n ): null | MatchedRoute {\n const domainName = domain?.tokens[0]?.old || 'root'\n\n const matchedDomain = this.tree.domains[domainName]\n if (!matchedDomain) {\n return null\n }\n\n /*\n * Next get the method node for the given method inside the domain. If\n * method node is missing, means no routes ever got registered for that\n * method\n */\n const matchedMethod = this.tree.domains[domainName][method]\n if (!matchedMethod) {\n return null\n }\n\n /*\n * Next, match route for the given url inside the tokens list for the\n * matchedMethod\n */\n const matchedRoute = matchit.match(url, matchedMethod.tokens)\n if (!matchedRoute.length) {\n return null\n }\n\n const route = matchedMethod.routes[matchedRoute[0].old]\n return {\n route: route,\n routeKey: matchedMethod.routeKeys[route.pattern],\n params: matchit.exec(url, matchedRoute),\n subdomains: domain?.hostname ? matchit.exec(domain.hostname, domain.tokens) : {},\n }\n }\n\n /**\n * Match hostname against registered domains.\n */\n matchDomain(hostname?: string | null): MatchItRouteToken[] {\n if (!hostname || !this.usingDomains) {\n return []\n }\n\n return matchit.match(hostname, this.tree.tokens)\n }\n}\n","/*\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\n// @ts-expect-error\nimport matchit from '@poppinss/matchit'\nimport { MatchItRouteToken, RouteMatchers } from '../types/route.js'\n\n/**\n * Parses the route pattern\n */\nexport function parseRoutePattern(pattern: string, matchers?: RouteMatchers): MatchItRouteToken[] {\n const tokens = matchit.parse(pattern, matchers)\n return tokens\n}\n","/*\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 Macroable from '@poppinss/macroable'\nimport type { Encryption } from '@adonisjs/encryption'\n\nimport type { Qs } from '../../qs.js'\nimport { UrlBuilder } from './url_builder.js'\nimport { RouteFinder } from './route_finder.js'\nimport type { RouteJSON } from '../../types/route.js'\nimport { E_CANNOT_LOOKUP_ROUTE } from '../../exceptions.js'\n\n/**\n * Lookup store exposes the API to lookup routes and\n * make URLs for registered routes.\n */\nexport class LookupStore extends Macroable {\n /**\n * List of route finders grouped by domains\n */\n #routes: { [domain: string]: RouteFinder } = {}\n\n /**\n * Encryption for making URLs\n */\n #encryption: Encryption\n\n /**\n * Query string parser for making URLs\n */\n #qsParser: Qs\n\n constructor(encryption: Encryption, qsParser: Qs) {\n super()\n this.#encryption = encryption\n this.#qsParser = qsParser\n }\n\n /**\n * Register route JSON payload\n */\n register(route: RouteJSON) {\n this.#routes[route.domain] = this.#routes[route.domain] || new RouteFinder()\n this.#routes[route.domain].register(route)\n }\n\n /**\n * Returns an instance of the URL builder for making\n * route URIs\n */\n builder() {\n return this.builderForDomain('root')\n }\n\n /**\n * Returns an instance of the URL builder for a specific\n * domain.\n */\n builderForDomain(domain: string) {\n const finder = this.#routes[domain]\n return new UrlBuilder(this.#encryption, finder || new RouteFinder(), this.#qsParser)\n }\n\n /**\n * Finds a route by its identifier. The identifier can be the\n * route name, controller.method name or the route pattern\n * itself.\n */\n find(routeIdentifier: string, domain?: string): RouteJSON | null {\n const finder = this.#routes[domain || 'root']\n if (!finder) {\n return null\n }\n\n return finder.find(routeIdentifier)\n }\n\n /**\n * Finds a route by its identifier. The identifier can be the\n * route name, controller.method name or the route pattern\n * itself.\n *\n * An error is raised when unable to find the route.\n */\n findOrFail(routeIdentifier: string, domain?: string): RouteJSON {\n const finder = this.#routes[domain || 'root']\n if (!finder) {\n throw new E_CANNOT_LOOKUP_ROUTE([routeIdentifier])\n }\n\n return finder.findOrFail(routeIdentifier)\n }\n\n /**\n * Check if a route exists. The identifier can be the\n * route name, controller.method name or the route pattern\n * itself.\n */\n has(routeIdentifier: string, domain?: string): boolean {\n const finder = this.#routes[domain || 'root']\n if (!finder) {\n return false\n }\n\n return finder.has(routeIdentifier)\n }\n\n toJSON() {\n return Object.keys(this.#routes).reduce<Record<string, RouteJSON[]>>((result, domain) => {\n result[domain] = this.#routes[domain].toJSON()\n return result\n }, {})\n }\n}\n","/*\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 { RuntimeException } from '@poppinss/utils'\nimport type { Encryption } from '@adonisjs/encryption'\n\nimport type { Qs } from '../../qs.js'\nimport { parseRoutePattern } from '../parser.js'\nimport type { RouteFinder } from './route_finder.js'\n\n/**\n * URL builder class is used to create URIs for pre-registered\n * routes.\n *\n * ```ts\n * const builder = new UrlBuilder(encryption, routeFinder)\n *\n * builder\n * .qs({ sort: 'id' })\n * .params([category.id])\n * .make('categories.posts.index')\n * ```\n */\nexport class UrlBuilder {\n /**\n * Query string parser\n */\n #qsParser: Qs\n\n /**\n * The parameters to apply on the route\n */\n #params: any[] | Record<string, any> = {}\n\n /**\n * Query string to append to the route\n */\n #qs: Record<string, any> = {}\n\n /**\n * Should we perform the route lookup or just build the\n * given pattern as it is.\n */\n #shouldPerformLookup = true\n\n /**\n * BaseURL to append to the constructored URL\n */\n #baseUrl?: string\n\n /**\n * Encryption class for making signed URLs\n */\n #encryption: Encryption\n\n /**\n * Route finder for finding route pattern\n */\n #routeFinder: RouteFinder\n\n constructor(encryption: Encryption, routeFinder: RouteFinder, qsParser: Qs) {\n this.#qsParser = qsParser\n this.#encryption = encryption\n this.#routeFinder = routeFinder\n }\n\n /**\n * Raises exception when wildcard values array is missing or\n * has length of zero.\n */\n #ensureHasWildCardValues(pattern: string, values?: string[]) {\n if (!values || !Array.isArray(values) || !values.length) {\n throw new RuntimeException(\n `Cannot make URL for \"${pattern}\" route. Invalid value provided for wildcard param`\n )\n }\n }\n\n /*\n * Raises exception when value is not defined\n */\n #ensureHasParamValue(pattern: string, param: string, value: string) {\n if (value === undefined || value === null) {\n throw new RuntimeException(\n `Cannot make URL for \"${pattern}\" route. Missing value for \"${param}\" param`\n )\n }\n }\n\n /**\n * Processes the pattern against the params\n */\n #processPattern(pattern: string): string {\n const uriSegments: string[] = []\n const paramsArray = Array.isArray(this.#params) ? this.#params : null\n const paramsObject = !Array.isArray(this.#params) ? this.#params : {}\n\n let paramsIndex = 0\n const tokens = parseRoutePattern(pattern)\n\n for (const token of tokens) {\n /**\n * Expected wildcard param to be at the end always and hence\n * we must break out from the loop\n */\n if (token.type === 0) {\n uriSegments.push(token.val === '/' ? '' : `${token.val}${token.end}`)\n } else if (token.type === 2) {\n const values: string[] = paramsArray ? paramsArray.slice(paramsIndex) : paramsObject['*']\n this.#ensureHasWildCardValues(pattern, values)\n uriSegments.push(`${values.join('/')}${token.end}`)\n break\n } else {\n const paramName = token.val\n const value = paramsArray ? paramsArray[paramsIndex] : paramsObject[paramName]\n\n /**\n * Type = 1 means param is required\n */\n if (token.type === 1) {\n this.#ensureHasParamValue(pattern, paramName, value)\n }\n\n paramsIndex++\n if (value !== undefined && value !== null) {\n uriSegments.push(`${value}${token.end}`)\n }\n }\n }\n\n return `/${uriSegments.join('/')}`\n }\n\n /**\n * Suffix the query string to the URL\n */\n #suffixQueryString(url: string, qs?: Record<string, any>): string {\n if (qs) {\n const queryString = this.#qsParser.stringify(qs)\n url = queryString ? `${url}?${queryString}` : url\n }\n\n return url\n }\n\n /**\n * Prefixes base URL to the uri string\n */\n #prefixBaseUrl(uri: string) {\n return this.#baseUrl ? `${this.#baseUrl}${uri}` : uri\n }\n\n /**\n * Prefix a custom base URL to the final URI\n */\n prefixUrl(url: string): this {\n this.#baseUrl = url\n return this\n }\n\n /**\n * Disable route lookup. Calling this method considers\n * the \"identifier\" as the route pattern\n */\n disableRouteLookup(): this {\n this.#shouldPerformLookup = false\n return this\n }\n\n /**\n * Append query string to the final URI\n */\n qs(queryString?: Record<string, any>): this {\n if (!queryString) {\n return this\n }\n\n this.#qs = queryString\n return this\n }\n\n /**\n * Specify params to apply to the route pattern\n */\n params(params?: any[] | Record<string, any>): this {\n if (!params) {\n return this\n }\n\n this.#params = params\n return this\n }\n\n /**\n * Generate URL for the given route identifier. The identifier can be the\n * route name, controller.method name or the route pattern\n * itself.\n */\n make(identifier: string) {\n let url: string\n\n if (this.#shouldPerformLookup) {\n const route = this.#routeFinder.findOrFail(identifier)\n url = this.#processPattern(route.pattern)\n } else {\n url = this.#processPattern(identifier)\n }\n\n return this.#suffixQueryString(this.#prefixBaseUrl(url), this.#qs)\n }\n\n /**\n * Generate a signed URL for the given route identifier. The identifier can be the\n * route name, controller.method name or the route pattern\n * itself.\n */\n makeSigned(identifier: string, options?: { expiresIn?: string | number; purpose?: string }) {\n let url: string\n\n if (this.#shouldPerformLookup) {\n const route = this.#routeFinder.findOrFail(identifier)\n url = this.#processPattern(route.pattern)\n } else {\n url = this.#processPattern(identifier)\n }\n\n /*\n * Making the signature from the qualified url. We do not prefix the domain when\n * making signature, since it just makes the signature big.\n *\n * There might be a case, when someone wants to generate signature for the same route\n * on their 2 different domains, but we ignore that case for now and can consider\n * it later (when someone asks for it)\n */\n const signature = this.#encryption.verifier.sign(\n this.#suffixQueryString(url, this.#qs),\n options?.expiresIn,\n options?.purpose\n )\n\n const qs = Object.assign({}, this.#qs, { signature })\n return this.#suffixQueryString(this.#prefixBaseUrl(url), qs)\n }\n}\n","/*\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 * as errors from '../../exceptions.js'\nimport type { RouteJSON } from '../../types/route.js'\n\n/**\n * Route finder is used to find a route by its name, route pattern\n * or the controller.method name.\n */\nexport class RouteFinder {\n #routes: RouteJSON[] = []\n\n register(route: RouteJSON) {\n this.#routes.push(route)\n }\n\n /**\n * Find a route by indentifier\n */\n find(routeIdentifier: string): RouteJSON | null {\n return (\n this.#routes.find(({ name, pattern, handler }) => {\n if (name === routeIdentifier || pattern === routeIdentifier) {\n return true\n }\n\n if (typeof handler === 'function') {\n return false\n }\n\n return handler.reference === routeIdentifier\n }) || null\n )\n }\n\n /**\n * Find a route by indentifier or fail\n */\n findOrFail(routeIdentifier: string): RouteJSON {\n const route = this.find(routeIdentifier)\n if (!route) {\n throw new errors.E_CANNOT_LOOKUP_ROUTE([routeIdentifier])\n }\n\n return route\n }\n\n /**\n * Find if a route exists\n */\n has(routeIdentifier: string): boolean {\n return !!this.find(routeIdentifier)\n }\n\n /**\n * Returns an array of registered routes\n */\n toJSON() {\n return this.#routes\n }\n}\n","/*\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 Macroable from '@poppinss/macroable'\n\n/**\n * Shortcut methods for commonly used route matchers\n */\nexport class RouteMatchers extends Macroable {\n /**\n * Enforce value to be a number and also casts it to number data\n * type\n */\n number() {\n return { match: /^[0-9]+$/, cast: (value: string) => Number(value) }\n }\n\n /**\n * Enforce value to be formatted as uuid\n */\n uuid() {\n return {\n match: /^[0-9a-zA-F]{8}-[0-9a-zA-F]{4}-[0-9a-zA-F]{4}-[0-9a-zA-F]{4}-[0-9a-zA-F]{12}$/,\n cast: (value: string) => value.toLowerCase(),\n }\n }\n\n /**\n * Enforce value to be formatted as slug\n */\n slug() {\n return { match: /^[^\\s-_](?!.*?[-_]{2,})([a-z0-9-\\\\]{1,})[^\\s]*[^-_\\s]$/ }\n }\n}\n","/*\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 { moduleImporter } from '@adonisjs/fold'\nimport type { LazyImport, UnWrapLazyImport } from './types/base.js'\nimport type {\n GetMiddlewareArgs,\n MiddlewareAsClass,\n ParsedGlobalMiddleware,\n} from './types/middleware.js'\n\n/**\n * Converts a middleware name and its lazy import to a factory function. The function\n * can than later be used to reference the middleware with different arguments\n * every time.\n */\nfunction middlewareReferenceBuilder(\n name: string | number | symbol,\n middleware: LazyImport<MiddlewareAsClass>\n) {\n const handler = moduleImporter(middleware, 'handle').toHandleMethod()\n return function (...args: any[]) {\n return {\n ...handler,\n name,\n args: args[0],\n }\n }\n}\n\n/**\n * Define an collection of named middleware. The collection gets converted\n * into a collection of factory functions. Calling the function returns\n * a reference to the executable middleware.\n */\nexport function defineNamedMiddleware<\n NamedMiddleware extends Record<string | number | symbol, LazyImport<MiddlewareAsClass>>,\n>(collection: NamedMiddleware) {\n return Object.keys(collection).reduce(\n (result, key: keyof NamedMiddleware) => {\n result[key] = middlewareReferenceBuilder(key, collection[key])\n return result\n },\n {} as {\n [K in keyof NamedMiddleware]: <\n Args extends GetMiddlewareArgs<UnWrapLazyImport<NamedMiddleware[K]>>,\n >(\n ...args: Args\n ) => {\n name: K\n args: Args[0]\n handle: ParsedGlobalMiddleware['handle']\n }\n }\n )\n}\n","/*\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 { inspect } from 'node:util'\nimport Macroable from '@poppinss/macroable'\nimport type { Logger } from '@adonisjs/logger'\nimport { RuntimeException } from '@poppinss/utils'\nimport { ContainerResolver } from '@adonisjs/fold'\n\nimport type { Request } from '../request.js'\nimport type { Response } from '../response.js'\nimport { asyncLocalStorage } from './local_storage.js'\nimport type { StoreRouteNode } from '../types/route.js'\n\n/**\n * Http context encapsulates properties for a given HTTP request. The\n * context class can be extended using macros and getters.\n */\nexport class HttpContext extends Macroable {\n /**\n * Find if async localstorage is enabled for HTTP requests\n * or not\n */\n static get usingAsyncLocalStorage() {\n return asyncLocalStorage.isEnabled\n }\n\n /**\n * Get access to the HTTP context. Available only when\n * \"usingAsyncLocalStorage\" is true\n */\n static get(): HttpContext | null {\n if (!this.usingAsyncLocalStorage || !asyncLocalStorage.storage) {\n return null\n }\n\n return asyncLocalStorage.storage.getStore() || null\n }\n\n /**\n * Get the HttpContext instance or raise an exception if not\n * available\n */\n static getOrFail(): HttpContext {\n /**\n * Localstorage is not enabled\n */\n if (!this.usingAsyncLocalStorage || !asyncLocalStorage.storage) {\n throw new RuntimeException(\n 'HTTP context is not available. Enable \"useAsyncLocalStorage\" inside \"config/app.ts\" file'\n )\n }\n\n const store = this.get()\n if (!store) {\n throw new RuntimeException('Http context is not available outside of an HTTP request')\n }\n\n return store\n }\n\n /**\n * Run a method that doesn't have access to HTTP context from\n * the async local storage.\n */\n static runOutsideContext<T>(callback: (...args: any[]) => T, ...args: any[]): T {\n if (!asyncLocalStorage.storage) {\n return callback(...args)\n }\n\n return asyncLocalStorage.storage.exit(callback, ...args)\n }\n\n /**\n * Reference to the current route. Not available inside\n * server middleware\n */\n route?: StoreRouteNode\n\n /**\n * A unique key for the current route\n */\n routeKey?: string\n\n /**\n * Route params\n */\n params: Record<string, any> = {}\n\n /**\n * Route subdomains\n */\n subdomains: Record<string, any> = {}\n\n constructor(\n public request: Request,\n public response: Response,\n public logger: Logger,\n public containerResolver: ContainerResolver<any>\n ) {\n super()\n\n /*\n * Creating the circular reference. We do this, since request and response\n * are meant to be extended and at times people would want to access\n * other ctx properties like `logger`, `profiler` inside those\n * extended methods.\n */\n this.request.ctx = this\n this.response.ctx = this\n }\n\n /**\n * A helper to see top level properties on the context object\n */\n /* c8 ignore next 3 */\n inspect() {\n return inspect(this, false, 1, true)\n }\n}\n","/*\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 { AsyncLocalStorage } from 'node:async_hooks'\nimport type { HttpContext } from './main.js'\n\n/**\n * Async local storage for HTTP context\n */\nexport const asyncLocalStorage: {\n isEnabled: boolean\n storage: null | AsyncLocalStorage<HttpContext>\n create(): AsyncLocalStorage<HttpContext>\n destroy(): void\n} = {\n /**\n * Check if the async local storage for the HTTP\n * context is enabled or not\n */\n isEnabled: false,\n\n /**\n * HTTP context storage instance for the current scope\n */\n storage: null,\n\n /**\n * Create the storage instance. This method must be called only\n * once.\n */\n create() {\n this.isEnabled = true\n this.storage = new AsyncLocalStorage<HttpContext>()\n return this.storage\n },\n\n /**\n * Destroy the create storage instance\n */\n destroy() {\n this.isEnabled = false\n this.storage = null\n },\n}\n","/*\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 onFinished from 'on-finished'\nimport Middleware from '@poppinss/middleware'\nimport type { Logger } from '@adonisjs/logger'\nimport type { Encryption } from '@adonisjs/encryption'\nimport type { Server as HttpsServer } from 'node:https'\nimport type { Application } from '@adonisjs/application'\nimport type { EmitterLike } from '@adonisjs/events/types'\nimport { type ContainerResolver, moduleCaller, moduleImporter } from '@adonisjs/fold'\nimport type { ServerResponse, IncomingMessage, Server as HttpServer } from 'node:http'\n\nimport type { LazyImport } from '../types/base.js'\nimport type { MiddlewareAsClass, ParsedGlobalMiddleware } from '../types/middleware.js'\nimport type {\n ServerConfig,\n HttpServerEvents,\n ServerErrorHandler,\n ErrorHandlerAsAClass,\n TestingMiddlewarePipeline,\n} from '../types/server.js'\n\nimport { Qs } from '../qs.js'\nimport debug from '../debug.js'\nimport { Request } from '../request.js'\nimport { Response } from '../response.js'\nimport { Router } from '../router/main.js'\nimport { HttpContext } from '../http_context/main.js'\nimport { finalHandler } from './factories/final_handler.js'\nimport { writeResponse } from './factories/write_response.js'\nimport { asyncLocalStorage } from '../http_context/local_storage.js'\nimport { middlewareHandler } from './factories/middleware_handler.js'\n\n/**\n * The HTTP server implementation to handle incoming requests and respond using the\n * registered routes.\n */\nexport class Server {\n #booted: boolean = false\n\n /**\n * The default error handler to use\n */\n #defaultErrorHandler: ServerErrorHandler = {\n report() {},\n handle(error, ctx) {\n ctx.response.status(error.status || 500).send(error.message || 'Internal server error')\n },\n }\n\n /**\n * Logger instance, a child logger is added\n * to the context to have request specific\n * logging capabilities.\n */\n #logger: Logger\n\n /**\n * Registered error handler (if any)\n */\n #errorHandler?: LazyImport<ErrorHandlerAsAClass>\n\n /**\n * Resolved error handler is an instance of the lazily imported error\n * handler class.\n */\n #resolvedErrorHandler: ServerErrorHandler = this.#defaultErrorHandler\n\n /**\n * Emitter is required to notify when a request finishes\n */\n #emitter: EmitterLike<HttpServerEvents>\n\n /**\n * The application instance to be shared with the router\n */\n #app: Application<any>\n\n /**\n * The encryption instance to be shared with the router\n */\n #encryption: Encryption\n\n /**\n * Server config\n */\n #config: ServerConfig\n\n /**\n * Query string parser used by the server\n */\n #qsParser: Qs\n\n /**\n * Server middleware stack runs on every incoming HTTP request\n */\n #serverMiddlewareStack?: Middleware<ParsedGlobalMiddleware>\n\n /**\n * Reference to the router used by the server\n */\n #router: Router\n\n /**\n * Reference to the underlying Node HTTP server in use\n */\n #nodeHttpServer?: HttpServer | HttpsServer\n\n /**\n * Middleware store to be shared with the routes\n */\n #middleware: ParsedGlobalMiddleware[] = []\n\n /**\n * The request error response is attached to the middleware\n * pipeline to intercept errors and invoke the user\n * registered error handler.\n *\n * We share this with the route middleware pipeline as well,\n * so that it does not throw any exceptions\n */\n #requestErrorResponder: ServerErrorHandler['handle'] = async (error, ctx) => {\n await this.#resolvedErrorHandler.report(error, ctx)\n return this.#resolvedErrorHandler.handle(error, ctx)\n }\n\n /**\n * Check if the server has already been booted\n */\n get booted() {\n return this.#booted\n }\n\n /**\n * Know if async local storage is enabled or not.\n */\n get usingAsyncLocalStorage() {\n return asyncLocalStorage.isEnabled\n }\n\n constructor(\n app: Application<any>,\n encryption: Encryption,\n emitter: EmitterLike<HttpServerEvents>,\n logger: Logger,\n config: ServerConfig\n ) {\n this.#app = app\n this.#emitter = emitter\n this.#config = config\n this.#logger = logger\n this.#encryption = encryption\n this.#qsParser = new Qs(this.#config.qs)\n this.#router = new Router(this.#app, this.#encryption, this.#qsParser)\n this.#createAsyncLocalStore()\n\n debug('server config: %O', this.#config)\n }\n\n /**\n * Create async local storage store when enabled\n */\n #createAsyncLocalStore() {\n if (this.#config.useAsyncLocalStorage) {\n debug('creating ALS store for HTTP context')\n asyncLocalStorage.create()\n } else {\n asyncLocalStorage.destroy()\n }\n }\n\n /**\n * Creates an instance of the server middleware stack\n */\n #createServerMiddlewareStack() {\n this.#serverMiddlewareStack = new Middleware()\n this.#middleware.forEach((middleware) => this.#serverMiddlewareStack!.add(middleware))\n this.#serverMiddlewareStack.freeze()\n this.#middleware = []\n }\n\n /**\n * Handles the HTTP request\n */\n #handleRequest(ctx: HttpContext, resolver: ContainerResolver<any>) {\n return this.#serverMiddlewareStack!.runner()\n .errorHandler((error) => this.#requestErrorResponder(error, ctx))\n .finalHandler(finalHandler(this.#router!, resolver, ctx, this.#requestErrorResponder))\n .run(middlewareHandler(resolver, ctx))\n .catch((error) => {\n ctx.logger.fatal({ err: error }, 'Exception raised by error handler')\n return this.#defaultErrorHandler.handle(error, ctx)\n })\n .finally(writeResponse(ctx))\n }\n\n /**\n * Creates a pipeline of middleware.\n */\n pipeline(middleware: MiddlewareAsClass[]): TestingMiddlewarePipeline {\n const middlewareStack = new Middleware<ParsedGlobalMiddleware>()\n middleware.forEach((one) => {\n middlewareStack.add(moduleCaller(one, 'handle').toHandleMethod())\n })\n\n middlewareStack.freeze()\n const stackRunner = middlewareStack.runner()\n\n return {\n finalHandler(handler) {\n stackRunner.finalHandler(handler)\n return this\n },\n errorHandler(handler) {\n stackRunner.errorHandler(handler)\n return this\n },\n run(ctx) {\n return stackRunner.run((handler, next) => {\n return handler.handle(ctx.containerResolver, ctx, next)\n })\n },\n }\n }\n\n /**\n * Define an array of middleware to use on all the incoming HTTP request.\n * Calling this method multiple times pushes to the existing list\n * of middleware\n */\n use(middleware: LazyImport<MiddlewareAsClass>[]): this {\n middleware.forEach((one) =>\n this.#middleware.push(moduleImporter(one, 'handle').toHandleMethod())\n )\n\n return this\n }\n\n /**\n * Register a custom error handler for HTTP requests.\n * All errors will be reported to this method\n */\n errorHandler(handler: LazyImport<ErrorHandlerAsAClass>): this {\n this.#errorHandler = handler\n return this\n }\n\n /**\n * Boot the server. Calling this method performs the following actions.\n *\n * - Register routes with the store.\n * - Resolve and construct the error handler.\n */\n async boot() {\n if (this.#booted) {\n return\n }\n\n debug('booting HTTP server')\n\n /**\n * Creates the middleware stack for the server\n */\n this.#createServerMiddlewareStack()\n\n /**\n * Commit routes\n */\n this.#router.commit()\n\n /**\n * Register custom error handler\n */\n if (this.#errorHandler) {\n if (debug.enabled) {\n debug('using custom error handler \"%s\"', this.#errorHandler)\n }\n\n const moduleExports = await this.#errorHandler()\n this.#resolvedErrorHandler = await this.#app.container.make(moduleExports.default)\n }\n\n this.#booted = true\n }\n\n /**\n * Set the HTTP server instance used to listen for requests.\n */\n setNodeServer(server: HttpServer | HttpsServer) {\n server.timeout = this.#config.timeout ?? server.timeout\n server.keepAliveTimeout = this.#config.keepAliveTimeout ?? server.keepAliveTimeout\n server.headersTimeout = this.#config.headersTimeout ?? server.headersTimeout\n server.requestTimeout = this.#config.requestTimeout ?? server.requestTimeout\n this.#nodeHttpServer = server\n }\n\n /**\n * Returns reference to the underlying HTTP server\n * in use\n */\n getNodeServer() {\n return this.#nodeHttpServer\n }\n\n /**\n * Returns reference to the router instance used\n * by the server.\n */\n getRouter(): Router {\n return this.#router\n }\n\n /**\n * Creates an instance of the [[Request]] class\n */\n createRequest(req: IncomingMessage, res: ServerResponse) {\n return new Request(req, res, this.#encryption, this.#config, this.#qsParser)\n }\n\n /**\n * Creates an instance of the [[Response]] class\n */\n createResponse(req: IncomingMessage, res: ServerResponse) {\n return new Response(req, res, this.#encryption, this.#config, this.#router, this.#qsParser)\n }\n\n /**\n * Creates an instance of the [[HttpContext]] class\n */\n createHttpContext(request: Request, response: Response, resolver: ContainerResolver<any>) {\n return new HttpContext(\n request,\n response,\n this.#logger.child({ request_id: request.id() }),\n resolver\n )\n }\n\n /**\n * Handle request\n */\n handle(req: IncomingMessage, res: ServerResponse) {\n /**\n * Setup for the \"http:request_finished\" event\n */\n const hasRequestListener = this.#emitter.hasListeners('http:request_completed')\n const startTime = hasRequestListener ? process.hrtime() : null\n\n /**\n * Creating essential instances\n */\n const resolver = this.#app.container.createResolver()\n const ctx = this.createHttpContext(\n this.createRequest(req, res),\n this.createResponse(req, res),\n resolver\n )\n\n /**\n * Emit event when listening for the request_finished event\n */\n if (startTime) {\n onFinished(res, () => {\n this.#emitter.emit('http:request_completed', {\n ctx: ctx,\n duration: process.hrtime(startTime),\n })\n })\n }\n\n /**\n * Handle request\n */\n if (this.usingAsyncLocalStorage) {\n return asyncLocalStorage.storage!.run(ctx, () => this.#handleRequest(ctx, resolver))\n }\n return this.#handleRequest(ctx, resolver)\n }\n}\n","/*\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 { parse, stringify } from 'qs'\nimport { QSParserConfig } from './types/qs.js'\n\n/**\n * Query string parser used to parse and stringify query\n * strings.\n */\nexport class Qs {\n #config: QSParserConfig\n\n constructor(config: QSParserConfig) {\n this.#config = config\n }\n\n parse(value: string) {\n return parse(value, this.#config.parse)\n }\n\n stringify(value: any) {\n return stringify(value, this.#config.stringify)\n }\n}\n","/*\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 type { ContainerResolver } from '@adonisjs/fold'\n\nimport * as errors from '../../exceptions.js'\nimport type { Router } from '../../router/main.js'\nimport type { HttpContext } from '../../http_context/main.js'\nimport type { ServerErrorHandler } from '../../types/server.js'\n\n/**\n * The final handler is executed after the server middleware stack.\n * It looks for a matching route and executes the route middleware\n * stack.\n */\nexport function finalHandler(\n router: Router,\n resolver: ContainerResolver<any>,\n ctx: HttpContext,\n errorResponder: ServerErrorHandler['handle']\n) {\n return function () {\n const url = ctx.request.url()\n const method = ctx.request.method()\n const hostname = router.usingDomains ? ctx.request.hostname() : undefined\n const route = router.match(url, method, hostname)\n\n if (route) {\n ctx.params = route.params\n ctx.subdomains = route.subdomains\n ctx.route = route.route\n ctx.routeKey = route.routeKey\n return route.route.execute(route.route, resolver, ctx, errorResponder)\n }\n\n return Promise.reject(new errors.E_ROUTE_NOT_FOUND([method, url]))\n }\n}\n","/*\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 type { HttpContext } from '../../http_context/main.js'\n\n/**\n * Writes the response to the socket. The \"finish\" method can\n * raise error when unable to serialize the response.\n */\nexport function writeResponse(ctx: HttpContext) {\n return function () {\n try {\n ctx.response.finish()\n } catch (error) {\n ctx.logger.fatal({ err: error }, 'Response serialization failed')\n ctx.response.internalServerError(error.message)\n ctx.response.finish()\n }\n }\n}\n","/*\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 type { NextFn } from '@poppinss/middleware/types'\nimport type { ContainerResolver } from '@adonisjs/fold'\n\nimport type { HttpContext } from '../../http_context/main.js'\nimport { ParsedGlobalMiddleware } from '../../types/middleware.js'\nimport debug from '../../debug.js'\n\n/**\n * The middleware handler invokes the middleware functions.\n */\nexport function middlewareHandler(resolver: ContainerResolver<any>, ctx: HttpContext) {\n return function (fn: ParsedGlobalMiddleware, next: NextFn) {\n debug('executing middleware %s', fn.name)\n return fn.handle(resolver, ctx, next)\n }\n}\n","/*\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 proxyAddr from 'proxy-addr'\nimport string from '@poppinss/utils/string'\nimport type { ServerConfig } from './types/server.js'\nimport lodash from '@poppinss/utils/lodash'\n\ntype DeepPartial<T> = {\n [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]\n}\n\ntype UserDefinedServerConfig = DeepPartial<\n Omit<ServerConfig, 'trustProxy'> & {\n trustProxy: ((address: string, distance: number) => boolean) | boolean | string\n }\n>\n\n/**\n * Define configuration for the HTTP server\n */\nexport function defineConfig(config: UserDefinedServerConfig): ServerConfig {\n const { trustProxy, ...rest } = config\n\n const defaults = {\n allowMethodSpoofing: false,\n trustProxy: proxyAddr.compile('loopback'),\n subdomainOffset: 2,\n generateRequestId: false,\n useAsyncLocalStorage: false,\n etag: false,\n jsonpCallbackName: 'callback',\n cookie: {\n maxAge: '2h',\n path: '/',\n httpOnly: true,\n secure: true,\n sameSite: 'lax' as const,\n },\n qs: {\n parse: {\n depth: 5,\n parameterLimit: 1000,\n allowSparse: false,\n arrayLimit: 20,\n comma: true,\n },\n stringify: {\n encode: true,\n encodeValuesOnly: false,\n arrayFormat: 'indices' as const,\n skipNulls: false,\n },\n },\n } satisfies ServerConfig\n\n const normalizedConfig: ServerConfig = lodash.merge({}, defaults, rest)\n\n /**\n * Normalizing maxAge property on cookies to be a number in\n * seconds\n */\n if (normalizedConfig.cookie.maxAge) {\n normalizedConfig.cookie.maxAge = string.seconds.parse(normalizedConfig.cookie.maxAge)\n }\n\n /**\n * Normalizing trust proxy setting to allow boolean and\n * string values\n */\n if (typeof trustProxy === 'boolean') {\n const tpValue = trustProxy\n normalizedConfig.trustProxy = (_, __) => tpValue\n } else if (typeof trustProxy === 'string') {\n const tpValue = trustProxy\n normalizedConfig.trustProxy = proxyAddr.compile(tpValue)\n } else if (trustProxy) {\n normalizedConfig.trustProxy = trustProxy\n }\n\n return normalizedConfig\n}\n"],"mappings":";;;;;;;AASA,OAAO,QAAQ;AACf,OAAOA,gBAAe;AACtB,OAAO,gBAAgB;AACvB,SAAS,oBAAAC,yBAAwB;AAEjC,SAAS,cAAc,sBAAsB;;;ACCtC,SAAS,eAAe,KAAkB;AAC/C,SAAO,SAAU,OAAY;AAC3B,QACE,UAAU;AAAA,IACV,CAAC,IAAI,SAAS;AAAA,IACd,UAAU,IAAI,UACd;AACA,UAAI,SAAS,KAAK,KAAK;AAAA,IACzB;AAAA,EACF;AACF;;;ACNO,SAAS,QACd,OACA,UACA,KACA,gBACA;AACA,SAAO,MAAM,WACV,OAAO,EACP,aAAa,CAAC,UAAU,eAAe,OAAO,GAAG,CAAC,EAClD,aAAa,YAAY;AACxB,QAAI,OAAO,MAAM,YAAY,YAAY;AACvC,aAAO,QAAQ,QAAQ,MAAM,QAAQ,GAAG,CAAC,EAAE,KAAK,eAAe,GAAG,CAAC;AAAA,IACrE;AAEA,WAAO,MAAM,QAAQ,OAAO,UAAU,GAAG,EAAE,KAAK,eAAe,GAAG,CAAC;AAAA,EACrE,CAAC,EACA,IAAI,OAAO,YAAY,SAAS;AAC/B,QAAI,OAAO,eAAe,YAAY;AACpC,aAAO,WAAW,KAAK,IAAI;AAAA,IAC7B;AAEA,WAAO,WAAW,OAAO,UAAU,KAAK,MAAM,WAAW,IAAI;AAAA,EAC/D,CAAC;AACL;;;ACjCA,OAAO,WAAW;AAClB,SAAS,iCAAiC;;;ACD1C,OAAO,eAAe;AAiBf,IAAM,aAAN,cAAyB,UAAU;AAAA;AAAA;AAAA;AAAA,EAIxC;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA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SAASD,QAAO,QAAQ,MAAM,iBAAiB,OAAO,MAAM;AAAA,EACtF;AAMA,MAAI,OAAOE,gBAAe,WAAW;AACnC,UAAM,UAAUA;AAChB,qBAAiB,aAAa,CAAC,GAAG,OAAO;AAAA,EAC3C,WAAW,OAAOA,gBAAe,UAAU;AACzC,UAAM,UAAUA;AAChB,qBAAiB,aAAa,UAAU,QAAQ,OAAO;AAAA,EACzD,WAAWA,aAAY;AACrB,qBAAiB,aAAaA;AAAA,EAChC;AAEA,SAAO;AACT;","names":["Macroable","RuntimeException","Macroable","Macroable","Macroable","Macroable","Macroable","RuntimeException","pack","canUnpack","unpack","pack","canUnpack","unpack","pack","canUnpack","unpack","is","Macroable","Macroable","is","parse","parse","error","Buffer","fresh","Macroable","RuntimeException","cookie","string","string","cookie","Macroable","RuntimeException","Buffer","fresh","is","moduleImporter","RuntimeException","matchit","lodash","RuntimeException","RuntimeException","lodash","matchit","Macroable","RuntimeException","RuntimeException","Macroable","Macroable","moduleImporter","moduleImporter","is","RuntimeException","Macroable","RuntimeException","Macroable","RuntimeException","onFinished","Middleware","moduleCaller","moduleImporter","parse","Middleware","moduleCaller","moduleImporter","onFinished","string","lodash","trustProxy"]}