@adonisjs/http-server
Advanced tools
Comparing version 1.8.2 to 2.0.0
@@ -1,4 +0,1 @@ | ||
/** | ||
* @module @adonisjs/http-server | ||
*/ | ||
/// <reference types="node" /> | ||
@@ -12,3 +9,3 @@ declare module '@ioc:Adonis/Core/HttpContext' { | ||
import { ResponseContract } from '@ioc:Adonis/Core/Response'; | ||
import { ServerConfigContract } from '@ioc:Adonis/Core/Server'; | ||
import { ServerConfig } from '@ioc:Adonis/Core/Server'; | ||
import { ProfilerRowContract } from '@ioc:Adonis/Core/Profiler'; | ||
@@ -39,3 +36,3 @@ import { EncryptionContract } from '@ioc:Adonis/Core/Encryption'; | ||
export interface HttpContextConstructorContract extends MacroableConstructorContract<HttpContextContract> { | ||
create(routePattern: string, routeParams: any, logger: LoggerContract, profiler: ProfilerRowContract, encryption: EncryptionContract, req?: IncomingMessage, res?: ServerResponse, serverConfig?: ServerConfigContract): HttpContextContract; | ||
create(routePattern: string, routeParams: any, logger: LoggerContract, profiler: ProfilerRowContract, encryption: EncryptionContract, req?: IncomingMessage, res?: ServerResponse, serverConfig?: ServerConfig): HttpContextContract; | ||
new (request: RequestContract, response: ResponseContract, logger: LoggerContract, profiler: ProfilerRowContract): HttpContextContract; | ||
@@ -42,0 +39,0 @@ } |
@@ -1,3 +0,8 @@ | ||
/** | ||
* @module @adonisjs/http-server | ||
*/ | ||
/* | ||
* @adonisjs/http-server | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ |
@@ -1,12 +0,9 @@ | ||
/** | ||
* @module @adonisjs/http-server | ||
*/ | ||
/// <reference types="node" /> | ||
declare module '@ioc:Adonis/Core/Server' { | ||
import { Server as HttpsServer } from 'https'; | ||
import { RequestConfigContract } from '@ioc:Adonis/Core/Request'; | ||
import { ResponseConfigContract } from '@ioc:Adonis/Core/Response'; | ||
import { RouterContract } from '@ioc:Adonis/Core/Route'; | ||
import { RequestConfig } from '@ioc:Adonis/Core/Request'; | ||
import { ResponseConfig } from '@ioc:Adonis/Core/Response'; | ||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'; | ||
import { MiddlewareStoreContract } from '@ioc:Adonis/Core/Middleware'; | ||
import { RouterContract } from '@ioc:Adonis/Core/Route'; | ||
import { IncomingMessage, ServerResponse, Server as HttpServer } from 'http'; | ||
@@ -17,13 +14,13 @@ /** | ||
*/ | ||
export type HookNode = (ctx: HttpContextContract) => Promise<void>; | ||
export type HookHandler = (ctx: HttpContextContract) => Promise<void>; | ||
/** | ||
* Error handler node | ||
*/ | ||
export type ErrorHandlerNode = string | ((error: any, ctx: HttpContextContract) => Promise<any>); | ||
export type ErrorHandler = string | ((error: any, ctx: HttpContextContract) => Promise<any>); | ||
/** | ||
* Shape of resolved error handler node | ||
*/ | ||
export type ResolvedErrorHandlerNode = { | ||
export type ResolvedErrorHandler = { | ||
type: 'function'; | ||
value: Exclude<ErrorHandlerNode, string>; | ||
value: Exclude<ErrorHandler, string>; | ||
} | { | ||
@@ -38,4 +35,4 @@ type: 'class'; | ||
export interface HooksContract { | ||
before(cb: HookNode): this; | ||
after(cb: HookNode): this; | ||
before(cb: HookHandler): this; | ||
after(cb: HookHandler): this; | ||
} | ||
@@ -50,3 +47,3 @@ /** | ||
middleware: MiddlewareStoreContract; | ||
errorHandler(handler: ErrorHandlerNode): this; | ||
errorHandler(handler: ErrorHandler): this; | ||
handle(req: IncomingMessage, res: ServerResponse): Promise<void>; | ||
@@ -58,5 +55,5 @@ optimize(): void; | ||
*/ | ||
export type ServerConfigContract = RequestConfigContract & ResponseConfigContract; | ||
export type ServerConfig = RequestConfig & ResponseConfig; | ||
const Server: ServerContract; | ||
export default Server; | ||
} |
@@ -1,3 +0,8 @@ | ||
/** | ||
* @module @adonisjs/http-server | ||
*/ | ||
/* | ||
* @adonisjs/http-server | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ |
@@ -1,4 +0,1 @@ | ||
/** | ||
* @module @adonisjs/http-server | ||
*/ | ||
/// <reference path="context.d.ts" /> | ||
@@ -5,0 +2,0 @@ /// <reference path="http-server.d.ts" /> |
@@ -1,4 +0,1 @@ | ||
/** | ||
* @module @adonisjs/http-server | ||
*/ | ||
/* | ||
@@ -5,0 +2,0 @@ * @adonisjs/http-server |
@@ -1,4 +0,1 @@ | ||
/** | ||
* @module @adonisjs/http-server | ||
*/ | ||
declare module '@ioc:Adonis/Core/Middleware' { | ||
@@ -11,3 +8,3 @@ import { IocContract } from '@adonisjs/fold'; | ||
*/ | ||
export type MiddlewareNode = string | ((ctx: HttpContextContract, next: () => Promise<void>, args?: string[]) => Promise<void>); | ||
export type MiddlewareHandler = string | ((ctx: HttpContextContract, next: () => Promise<void>, args?: string[]) => Promise<void>); | ||
/** | ||
@@ -17,5 +14,5 @@ * Shape of resolved middleware. This information is | ||
*/ | ||
export type ResolvedMiddlewareNode = { | ||
export type ResolvedMiddlewareHandler = { | ||
type: 'function'; | ||
value: Exclude<MiddlewareNode, string>; | ||
value: Exclude<MiddlewareHandler, string>; | ||
args: string[]; | ||
@@ -33,9 +30,9 @@ } | { | ||
export interface MiddlewareStoreContract { | ||
register(middleware: MiddlewareNode[]): this; | ||
register(middleware: MiddlewareHandler[]): this; | ||
registerNamed(middleware: { | ||
[alias: string]: MiddlewareNode; | ||
[alias: string]: MiddlewareHandler; | ||
}): this; | ||
get(): ResolvedMiddlewareNode[]; | ||
getNamed(name: string): null | ResolvedMiddlewareNode; | ||
invokeMiddleware(middleware: ResolvedMiddlewareNode, params: [HttpContextContract, () => Promise<void>]): Promise<void>; | ||
get(): ResolvedMiddlewareHandler[]; | ||
getNamed(name: string): null | ResolvedMiddlewareHandler; | ||
invokeMiddleware(middleware: ResolvedMiddlewareHandler, params: [HttpContextContract, () => Promise<void>]): Promise<void>; | ||
} | ||
@@ -42,0 +39,0 @@ /** |
@@ -1,3 +0,8 @@ | ||
/** | ||
* @module @adonisjs/http-server | ||
*/ | ||
/* | ||
* @adonisjs/http-server | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ |
@@ -1,4 +0,1 @@ | ||
/** | ||
* @module @poppinss/request | ||
*/ | ||
/// <reference types="node" /> | ||
@@ -70,11 +67,9 @@ declare module '@ioc:Adonis/Core/Request' { | ||
stale(): boolean; | ||
cookies(): { | ||
cookiesList(): { | ||
[key: string]: any; | ||
}; | ||
plainCookies(): { | ||
[key: string]: any; | ||
}; | ||
cookie(key: string, defaultValue?: any): any; | ||
encryptedCookie(key: string, defaultValue?: any): any; | ||
plainCookie(key: string, defaultValue?: any): any; | ||
hasValidSignature(): boolean; | ||
hasValidSignature(purpose?: string): boolean; | ||
toJSON(): any; | ||
@@ -85,4 +80,3 @@ } | ||
*/ | ||
export type RequestConfigContract = { | ||
secret?: string; | ||
export type RequestConfig = { | ||
forceContentNegotiationToJSON?: boolean; | ||
@@ -101,3 +95,3 @@ subdomainOffset: number; | ||
export interface RequestConstructorContract extends MacroableConstructorContract<RequestContract> { | ||
new (request: IncomingMessage, response: ServerResponse, encryption: EncryptionContract, config: RequestConfigContract): RequestContract; | ||
new (request: IncomingMessage, response: ServerResponse, encryption: EncryptionContract, config: RequestConfig): RequestContract; | ||
} | ||
@@ -104,0 +98,0 @@ const Request: RequestConstructorContract; |
@@ -1,3 +0,8 @@ | ||
/** | ||
* @module @poppinss/request | ||
*/ | ||
/* | ||
* @adonisjs/http-server | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ |
@@ -1,11 +0,20 @@ | ||
/** | ||
* @module @poppinss/response | ||
*/ | ||
/// <reference types="node" /> | ||
declare module '@ioc:Adonis/Core/Response' { | ||
import { CookieOptions } from '@poppinss/cookie'; | ||
import { ServerResponse, IncomingMessage } from 'http'; | ||
import { MacroableConstructorContract } from 'macroable'; | ||
import { EncryptionContract } from '@ioc:Adonis/Core/Encryption'; | ||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'; | ||
/** | ||
* Cookie options can that can be set on the response | ||
*/ | ||
export type CookieOptions = { | ||
domain: string; | ||
expires: Date | (() => Date); | ||
httpOnly: boolean; | ||
maxAge: number | string; | ||
path: string; | ||
sameSite: boolean | 'lax' | 'none' | 'strict'; | ||
secure: boolean; | ||
}; | ||
/** | ||
* Types from which response header can be casted to a | ||
@@ -67,2 +76,3 @@ * string | ||
plainCookie(key: string, value: any, options?: Partial<CookieOptions>): this; | ||
encryptedCookie(key: string, value: any, options?: Partial<CookieOptions>): this; | ||
clearCookie(key: string): this; | ||
@@ -122,4 +132,3 @@ abort(body: any, status?: number): never; | ||
*/ | ||
export type ResponseConfigContract = { | ||
secret?: string; | ||
export type ResponseConfig = { | ||
etag: boolean; | ||
@@ -135,3 +144,3 @@ jsonpCallbackName: string; | ||
export interface ResponseConstructorContract extends MacroableConstructorContract<ResponseContract> { | ||
new (request: IncomingMessage, response: ServerResponse, config: ResponseConfigContract): ResponseContract; | ||
new (request: IncomingMessage, response: ServerResponse, encryption: EncryptionContract, config: ResponseConfig): ResponseContract; | ||
} | ||
@@ -138,0 +147,0 @@ const Response: ResponseConstructorContract; |
@@ -1,3 +0,8 @@ | ||
/** | ||
* @module @poppinss/response | ||
/* | ||
* @adonisjs/http-server | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ |
@@ -1,19 +0,15 @@ | ||
/** | ||
* @module @adonisjs/http-server | ||
*/ | ||
declare module '@ioc:Adonis/Core/Route' { | ||
import { MacroableConstructorContract } from 'macroable'; | ||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'; | ||
import { MiddlewareNode, ResolvedMiddlewareNode } from '@ioc:Adonis/Core/Middleware'; | ||
import { MiddlewareHandler, ResolvedMiddlewareHandler } from '@ioc:Adonis/Core/Middleware'; | ||
/** | ||
* The shape of the route handler | ||
*/ | ||
export type RouteHandlerNode = ((ctx: HttpContextContract) => Promise<any>) | string; | ||
export type RouteHandler = ((ctx: HttpContextContract) => Promise<any>) | string; | ||
/** | ||
* Node after resolving controller.method binding | ||
* from the route | ||
* Node after resolving controller.method binding from the route | ||
*/ | ||
export type ResolveRouteHandlerNode = { | ||
export type ResolvedRouteHandler = { | ||
type: 'function'; | ||
handler: Exclude<RouteHandlerNode, string>; | ||
handler: Exclude<RouteHandler, string>; | ||
} | { | ||
@@ -25,13 +21,2 @@ type: 'autoload' | 'binding'; | ||
/** | ||
* Route look node is used to find the routes using | ||
* handler, pattern or name. | ||
*/ | ||
export type RouteLookupNode = { | ||
handler: RouteHandlerNode; | ||
methods: string[]; | ||
pattern: string; | ||
domain: string; | ||
name?: string; | ||
}; | ||
/** | ||
* Shape of match from the route store | ||
@@ -60,3 +45,3 @@ */ | ||
*/ | ||
handler: RouteHandlerNode; | ||
handler: RouteHandler; | ||
/** | ||
@@ -67,3 +52,3 @@ * The router itself doesn't use the middleware for anything, it | ||
*/ | ||
middleware: MiddlewareNode[]; | ||
middleware: MiddlewareHandler[]; | ||
/** | ||
@@ -73,4 +58,4 @@ * Any custom runtime properties to be added to the route | ||
meta: { | ||
resolvedHandler?: ResolveRouteHandlerNode; | ||
resolvedMiddleware?: ResolvedMiddlewareNode[]; | ||
resolvedHandler?: ResolvedRouteHandler; | ||
resolvedMiddleware?: ResolvedMiddlewareHandler[]; | ||
namespace?: string; | ||
@@ -113,3 +98,3 @@ } & { | ||
*/ | ||
export type RouteDefinition = RouteNode & { | ||
export type RouteJSON = RouteNode & { | ||
methods: string[]; | ||
@@ -120,2 +105,13 @@ domain?: string; | ||
/** | ||
* Route look node is used to find the routes using | ||
* handler, pattern or name. | ||
*/ | ||
export type RouteLookupNode = { | ||
handler: RouteHandler; | ||
methods: string[]; | ||
pattern: string; | ||
domain: string; | ||
name?: string; | ||
}; | ||
/** | ||
* Shape of the matched route for a pattern, method and domain. We set | ||
@@ -138,6 +134,6 @@ * them as spread options to the context. | ||
domain(domain: string): this; | ||
middleware(middleware: MiddlewareNode | MiddlewareNode[], prepend?: boolean): this; | ||
middleware(middleware: MiddlewareHandler | MiddlewareHandler[], prepend?: boolean): this; | ||
as(name: string, prepend?: boolean): this; | ||
namespace(namespace: string): this; | ||
toJSON(): RouteDefinition; | ||
toJSON(): RouteJSON; | ||
} | ||
@@ -153,3 +149,3 @@ /** | ||
middleware(middleware: { | ||
[name: string]: MiddlewareNode | MiddlewareNode[]; | ||
[name: string]: MiddlewareHandler | MiddlewareHandler[]; | ||
}): this; | ||
@@ -169,3 +165,3 @@ where(key: string, matcher: string | RegExp): this; | ||
as(name: string): this; | ||
middleware(middleware: MiddlewareNode | MiddlewareNode[]): this; | ||
middleware(middleware: MiddlewareHandler | MiddlewareHandler[]): this; | ||
namespace(namespace: string): this; | ||
@@ -198,9 +194,9 @@ } | ||
routes: (RouteContract | RouteResourceContract | RouteGroupContract | BriskRouteContract)[]; | ||
route(pattern: string, methods: string[], handler: RouteHandlerNode): RouteContract; | ||
any(pattern: string, handler: RouteHandlerNode): RouteContract; | ||
get(pattern: string, handler: RouteHandlerNode): RouteContract; | ||
post(pattern: string, handler: RouteHandlerNode): RouteContract; | ||
put(pattern: string, handler: RouteHandlerNode): RouteContract; | ||
patch(pattern: string, handler: RouteHandlerNode): RouteContract; | ||
delete(pattern: string, handler: RouteHandlerNode): RouteContract; | ||
route(pattern: string, methods: string[], handler: RouteHandler): RouteContract; | ||
any(pattern: string, handler: RouteHandler): RouteContract; | ||
get(pattern: string, handler: RouteHandler): RouteContract; | ||
post(pattern: string, handler: RouteHandler): RouteContract; | ||
put(pattern: string, handler: RouteHandler): RouteContract; | ||
patch(pattern: string, handler: RouteHandler): RouteContract; | ||
delete(pattern: string, handler: RouteHandler): RouteContract; | ||
group(callback: () => void): RouteGroupContract; | ||
@@ -215,7 +211,8 @@ resource(resource: string, controller: string): RouteResourceContract; | ||
lookup(routeIdentifier: string, domain?: string): null | RouteLookupNode; | ||
forTesting(pattern?: string, methods?: string[], handler?: any): RouteContract; | ||
makeUrl(routeIdentifier: string, options?: MakeUrlOptions, domain?: string): string | null; | ||
makeSignedUrl(routeIdentifier: string, options?: MakeUrlOptions & { | ||
expiresIn?: string | number; | ||
purpose?: string; | ||
}, domain?: string): string | null; | ||
forTesting(pattern?: string, methods?: string[], handler?: any): RouteContract; | ||
} | ||
@@ -222,0 +219,0 @@ const Route: RouterContract; |
@@ -1,3 +0,8 @@ | ||
/** | ||
* @module @adonisjs/http-server | ||
*/ | ||
/* | ||
* @adonisjs/http-server | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ |
@@ -7,3 +7,3 @@ /** | ||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'; | ||
import { ErrorHandlerNode } from '@ioc:Adonis/Core/Server'; | ||
import { ErrorHandler } from '@ioc:Adonis/Core/Server'; | ||
/** | ||
@@ -29,3 +29,3 @@ * Exception manager exposes the API to register custom error handler | ||
*/ | ||
registerHandler(handler: ErrorHandlerNode): void; | ||
registerHandler(handler: ErrorHandler): void; | ||
/** | ||
@@ -32,0 +32,0 @@ * Handle error |
@@ -9,3 +9,3 @@ /** | ||
import { RouteResource } from './Router/Resource'; | ||
import { RouteDefinition } from '@ioc:Adonis/Core/Route'; | ||
import { RouteJSON } from '@ioc:Adonis/Core/Route'; | ||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'; | ||
@@ -21,3 +21,3 @@ /** | ||
*/ | ||
export declare function toRoutesJSON(routes: (RouteGroup | RouteResource | Route | BriskRoute)[]): RouteDefinition[]; | ||
export declare function toRoutesJSON(routes: (RouteGroup | RouteResource | Route | BriskRoute)[]): RouteJSON[]; | ||
/** | ||
@@ -24,0 +24,0 @@ * Makes url for a route pattern and params and querystring. |
@@ -8,2 +8,3 @@ /** | ||
import { RouteNode } from '@ioc:Adonis/Core/Route'; | ||
import { ServerConfig } from '@ioc:Adonis/Core/Server'; | ||
import { IncomingMessage, ServerResponse } from 'http'; | ||
@@ -13,3 +14,2 @@ import { LoggerContract } from '@ioc:Adonis/Core/Logger'; | ||
import { ResponseContract } from '@ioc:Adonis/Core/Response'; | ||
import { ServerConfigContract } from '@ioc:Adonis/Core/Server'; | ||
import { ProfilerRowContract } from '@ioc:Adonis/Core/Profiler'; | ||
@@ -43,3 +43,3 @@ import { EncryptionContract } from '@ioc:Adonis/Core/Encryption'; | ||
*/ | ||
static create(routePattern: string, routeParams: any, logger: LoggerContract, profiler: ProfilerRowContract, encryption: EncryptionContract, req?: IncomingMessage, res?: ServerResponse, serverConfig?: ServerConfigContract): HttpContext; | ||
static create(routePattern: string, routeParams: any, logger: LoggerContract, profiler: ProfilerRowContract, encryption: EncryptionContract, req?: IncomingMessage, res?: ServerResponse, serverConfig?: ServerConfig): HttpContext; | ||
} |
@@ -23,5 +23,5 @@ "use strict"; | ||
const http_1 = require("http"); | ||
const helpers_1 = require("../helpers"); | ||
const Request_1 = require("../Request"); | ||
const Response_1 = require("../Response"); | ||
const helpers_1 = require("../helpers"); | ||
/** | ||
@@ -83,3 +83,2 @@ * Http context is passed to all route handlers, middleware, | ||
const request = new Request_1.Request(req, res, encryption, { | ||
secret: serverConfig.secret, | ||
allowMethodSpoofing: serverConfig.allowMethodSpoofing, | ||
@@ -93,4 +92,3 @@ subdomainOffset: serverConfig.subdomainOffset, | ||
*/ | ||
const response = new Response_1.Response(req, res, { | ||
secret: serverConfig.secret, | ||
const response = new Response_1.Response(req, res, encryption, { | ||
etag: serverConfig.etag, | ||
@@ -97,0 +95,0 @@ cookie: serverConfig.cookie, |
@@ -7,3 +7,3 @@ /** | ||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'; | ||
import { MiddlewareNode, MiddlewareStoreContract, ResolvedMiddlewareNode } from '@ioc:Adonis/Core/Middleware'; | ||
import { MiddlewareHandler, MiddlewareStoreContract, ResolvedMiddlewareHandler } from '@ioc:Adonis/Core/Middleware'; | ||
/** | ||
@@ -58,3 +58,3 @@ * Middleware store register and keep all the application middleware at one | ||
*/ | ||
register(middleware: MiddlewareNode[]): this; | ||
register(middleware: MiddlewareHandler[]): this; | ||
/** | ||
@@ -64,3 +64,3 @@ * Register named middleware that can be referenced later on routes | ||
registerNamed(middleware: { | ||
[alias: string]: MiddlewareNode; | ||
[alias: string]: MiddlewareHandler; | ||
}): this; | ||
@@ -71,3 +71,3 @@ /** | ||
*/ | ||
get(): ResolvedMiddlewareNode[]; | ||
get(): ResolvedMiddlewareHandler[]; | ||
/** | ||
@@ -77,7 +77,7 @@ * Returns a single middleware by it's name registered | ||
*/ | ||
getNamed(name: string): null | ResolvedMiddlewareNode; | ||
getNamed(name: string): null | ResolvedMiddlewareHandler; | ||
/** | ||
* Invokes a resolved middleware. | ||
*/ | ||
invokeMiddleware(middleware: ResolvedMiddlewareNode, params: [HttpContextContract, () => Promise<void>]): Promise<any>; | ||
invokeMiddleware(middleware: ResolvedMiddlewareHandler, params: [HttpContextContract, () => Promise<void>]): Promise<any>; | ||
} |
@@ -1,8 +0,4 @@ | ||
/** | ||
* @module @poppinss/request | ||
*/ | ||
/// <reference path="../../adonis-typings/index.d.ts" /> | ||
/// <reference types="node" /> | ||
import { Macroable } from 'macroable'; | ||
import { DeepReadonly } from 'ts-essentials'; | ||
import { UrlWithStringQuery } from 'url'; | ||
@@ -12,3 +8,3 @@ import { ServerResponse, IncomingMessage, IncomingHttpHeaders } from 'http'; | ||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'; | ||
import { RequestContract, RequestConfigContract } from '@ioc:Adonis/Core/Request'; | ||
import { RequestContract, RequestConfig } from '@ioc:Adonis/Core/Request'; | ||
/** | ||
@@ -57,3 +53,3 @@ * HTTP Request class exposes the interface to consistently read values | ||
*/ | ||
private parsedCookies; | ||
private cookieParser; | ||
/** | ||
@@ -75,3 +71,3 @@ * Required by Macroable | ||
ctx?: HttpContextContract; | ||
constructor(request: IncomingMessage, response: ServerResponse, encryption: EncryptionContract, config: DeepReadonly<RequestConfigContract>); | ||
constructor(request: IncomingMessage, response: ServerResponse, encryption: EncryptionContract, config: RequestConfig); | ||
/** | ||
@@ -82,6 +78,5 @@ * Parses the query string | ||
/** | ||
* Parse cookies, if not already parsed cookies. Cookies are only | ||
* parsed, when any of the cookie methods are used. | ||
* Initiates the cookie parser lazily | ||
*/ | ||
private parseCookies; | ||
private initiateCookieParser; | ||
/** | ||
@@ -537,3 +532,3 @@ * Lazily initiates the `accepts` module to make sure to parse | ||
*/ | ||
cookies(): { | ||
cookiesList(): { | ||
[key: string]: any; | ||
@@ -547,9 +542,6 @@ }; | ||
/** | ||
* Returns all parsed and unsigned cookies. Unsigned cookies gives | ||
* no guarantee for cookie tampering. You only need `plainCookies` | ||
* when cookie is set by the client and not the server | ||
* Returns value for a given key from signed cookies. Optional | ||
* defaultValue is returned when actual value is undefined. | ||
*/ | ||
plainCookies(): { | ||
[key: string]: any; | ||
}; | ||
encryptedCookie(key: string, defaultValue?: string): any; | ||
/** | ||
@@ -564,3 +556,3 @@ * Returns value for a given key from unsigned cookies. Optional | ||
*/ | ||
hasValidSignature(): boolean; | ||
hasValidSignature(purpose?: string): boolean; | ||
/** | ||
@@ -576,3 +568,6 @@ * toJSON copy of the request | ||
protocol: string; | ||
cookies: { | ||
[key: string]: any; | ||
}; | ||
}; | ||
} |
"use strict"; | ||
/** | ||
* @module @poppinss/request | ||
*/ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* | ||
* @poppinss/request | ||
* @adonisjs/http-server | ||
* | ||
@@ -17,8 +10,7 @@ * (c) Harminder Virk <virk@adonisjs.com> | ||
*/ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/// <reference path="../../adonis-typings/index.ts" /> | ||
/** | ||
* Once lodash fixes this issue https://github.com/lodash/lodash/issues/4459. We | ||
* can go back and use individual modules vs the full blown dependency | ||
*/ | ||
const lodash_1 = require("lodash"); | ||
const qs_1 = __importDefault(require("qs")); | ||
@@ -32,5 +24,6 @@ const cuid_1 = __importDefault(require("cuid")); | ||
const macroable_1 = require("macroable"); | ||
const utils_1 = require("@poppinss/utils"); | ||
const url_1 = require("url"); | ||
const cookie_1 = require("@poppinss/cookie"); | ||
const helpers_1 = require("../helpers"); | ||
const Parser_1 = require("../Cookie/Parser"); | ||
/** | ||
@@ -79,6 +72,2 @@ * HTTP Request class exposes the interface to consistently read values | ||
/** | ||
* Copy of lazily parsed signed and plain cookies. | ||
*/ | ||
this.parsedCookies = null; | ||
/** | ||
* Parses copy of the URL with query string as a string and not | ||
@@ -101,8 +90,7 @@ * object. This is done to build URL's with query string without | ||
/** | ||
* Parse cookies, if not already parsed cookies. Cookies are only | ||
* parsed, when any of the cookie methods are used. | ||
* Initiates the cookie parser lazily | ||
*/ | ||
parseCookies() { | ||
if (!this.parsedCookies) { | ||
this.parsedCookies = cookie_1.parse(this.header('cookie'), this.config.secret); | ||
initiateCookieParser() { | ||
if (!this.cookieParser) { | ||
this.cookieParser = new Parser_1.CookieParser(this.header('cookie'), this.encryption); | ||
} | ||
@@ -220,3 +208,3 @@ } | ||
input(key, defaultValue) { | ||
return lodash_1.get(this.requestData, key, defaultValue); | ||
return utils_1.lodash.get(this.requestData, key, defaultValue); | ||
} | ||
@@ -232,3 +220,3 @@ /** | ||
except(keys) { | ||
return lodash_1.omit(this.requestData, keys); | ||
return utils_1.lodash.omit(this.requestData, keys); | ||
} | ||
@@ -244,3 +232,3 @@ /** | ||
only(keys) { | ||
return lodash_1.pick(this.requestData, keys); | ||
return utils_1.lodash.pick(this.requestData, keys); | ||
} | ||
@@ -720,5 +708,5 @@ /** | ||
*/ | ||
cookies() { | ||
this.parseCookies(); | ||
return this.parsedCookies.signedCookies; | ||
cookiesList() { | ||
this.initiateCookieParser(); | ||
return this.cookieParser.list(); | ||
} | ||
@@ -730,13 +718,12 @@ /** | ||
cookie(key, defaultValue) { | ||
this.parseCookies(); | ||
return lodash_1.get(this.parsedCookies.signedCookies, key, defaultValue); | ||
this.initiateCookieParser(); | ||
return this.cookieParser.unsign(key) || defaultValue; | ||
} | ||
/** | ||
* Returns all parsed and unsigned cookies. Unsigned cookies gives | ||
* no guarantee for cookie tampering. You only need `plainCookies` | ||
* when cookie is set by the client and not the server | ||
* Returns value for a given key from signed cookies. Optional | ||
* defaultValue is returned when actual value is undefined. | ||
*/ | ||
plainCookies() { | ||
this.parseCookies(); | ||
return this.parsedCookies.plainCookies; | ||
encryptedCookie(key, defaultValue) { | ||
this.initiateCookieParser(); | ||
return this.cookieParser.decrypt(key) || defaultValue; | ||
} | ||
@@ -748,4 +735,4 @@ /** | ||
plainCookie(key, defaultValue) { | ||
this.parseCookies(); | ||
return lodash_1.get(this.parsedCookies.plainCookies, key, defaultValue); | ||
this.initiateCookieParser(); | ||
return this.cookieParser.decode(key) || defaultValue; | ||
} | ||
@@ -756,3 +743,3 @@ /** | ||
*/ | ||
hasValidSignature() { | ||
hasValidSignature(purpose) { | ||
const { signature, ...rest } = this.get(); | ||
@@ -765,12 +752,6 @@ if (!signature) { | ||
*/ | ||
const signedUrl = this.encryption.create({ hmac: false }).decrypt(signature); | ||
const signedUrl = this.encryption.verifier.unsign(signature, purpose); | ||
if (!signedUrl) { | ||
return false; | ||
} | ||
/** | ||
* Return false when is expired | ||
*/ | ||
if (rest.expires_at && Number(rest.expires_at) < Date.now()) { | ||
return false; | ||
} | ||
const queryString = qs_1.default.stringify(rest); | ||
@@ -790,2 +771,3 @@ return queryString ? `${this.url()}?${queryString}` === signedUrl : this.url() === signedUrl; | ||
protocol: this.protocol(), | ||
cookies: this.cookiesList(), | ||
}; | ||
@@ -792,0 +774,0 @@ } |
@@ -7,6 +7,5 @@ /** | ||
import { Macroable } from 'macroable'; | ||
import { DeepReadonly } from 'ts-essentials'; | ||
import { ServerResponse, IncomingMessage } from 'http'; | ||
import { CookieOptions } from '@poppinss/cookie'; | ||
import { ResponseContract, CastableHeader, LazyBody, ResponseContentType, ResponseStream, ResponseConfigContract } from '@ioc:Adonis/Core/Response'; | ||
import { LazyBody, CookieOptions, CastableHeader, ResponseConfig, ResponseStream, ResponseContract, ResponseContentType } from '@ioc:Adonis/Core/Response'; | ||
import { EncryptionContract } from '@ioc:Adonis/Core/Encryption'; | ||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'; | ||
@@ -39,2 +38,3 @@ /** | ||
response: ServerResponse; | ||
private encryption; | ||
private config; | ||
@@ -45,2 +45,3 @@ protected static macros: {}; | ||
private explicitStatus; | ||
private cookieSerializer; | ||
/** | ||
@@ -59,3 +60,3 @@ * Lazy body is used to set the response body. However, do not | ||
ctx?: HttpContextContract; | ||
constructor(request: IncomingMessage, response: ServerResponse, config: DeepReadonly<ResponseConfigContract>); | ||
constructor(request: IncomingMessage, response: ServerResponse, encryption: EncryptionContract, config: ResponseConfig); | ||
/** | ||
@@ -345,2 +346,7 @@ * Returns a boolean telling if lazy body is already set or not | ||
/** | ||
* Set unsigned cookie as the response header. The inline options overrides | ||
* all options from the config (means they are not merged) | ||
*/ | ||
encryptedCookie(key: string, value: any, options?: Partial<CookieOptions>): this; | ||
/** | ||
* Clear existing cookie. | ||
@@ -347,0 +353,0 @@ */ |
@@ -31,3 +31,3 @@ "use strict"; | ||
const content_disposition_1 = __importDefault(require("content-disposition")); | ||
const cookie_1 = require("@poppinss/cookie"); | ||
const Serializer_1 = require("../Cookie/Serializer"); | ||
/** | ||
@@ -96,9 +96,11 @@ * Wraps `fs.stat` to promise interface. | ||
class Response extends macroable_1.Macroable { | ||
constructor(request, response, config) { | ||
constructor(request, response, encryption, config) { | ||
super(); | ||
this.request = request; | ||
this.response = response; | ||
this.encryption = encryption; | ||
this.config = config; | ||
this.headers = {}; | ||
this.explicitStatus = false; | ||
this.cookieSerializer = new Serializer_1.CookieSerializer(this.encryption); | ||
/** | ||
@@ -747,3 +749,3 @@ * Lazy body is used to set the response body. However, do not | ||
options = Object.assign({}, this.config.cookie, options); | ||
const serialized = cookie_1.serialize(key, value, this.config.secret, options); | ||
const serialized = this.cookieSerializer.sign(key, value, options); | ||
if (!serialized) { | ||
@@ -761,3 +763,3 @@ return this; | ||
options = Object.assign({}, this.config.cookie, options); | ||
const serialized = cookie_1.serialize(key, value, undefined, options); | ||
const serialized = this.cookieSerializer.encode(key, value, options); | ||
if (!serialized) { | ||
@@ -770,2 +772,15 @@ return this; | ||
/** | ||
* Set unsigned cookie as the response header. The inline options overrides | ||
* all options from the config (means they are not merged) | ||
*/ | ||
encryptedCookie(key, value, options) { | ||
options = Object.assign({}, this.config.cookie, options); | ||
const serialized = this.cookieSerializer.encrypt(key, value, options); | ||
if (!serialized) { | ||
return this; | ||
} | ||
this.append('set-cookie', serialized); | ||
return this; | ||
} | ||
/** | ||
* Clear existing cookie. | ||
@@ -777,3 +792,3 @@ */ | ||
options.maxAge = -1; | ||
const serialized = cookie_1.serialize(key, '', undefined, options); | ||
const serialized = this.cookieSerializer.encode(key, '', options); | ||
if (!serialized) { | ||
@@ -780,0 +795,0 @@ return this; |
@@ -7,3 +7,3 @@ /** | ||
import { Route } from './Route'; | ||
import { BriskRouteContract, RouteMatchers, RouteHandlerNode } from '@ioc:Adonis/Core/Route'; | ||
import { BriskRouteContract, RouteMatchers, RouteHandler } from '@ioc:Adonis/Core/Route'; | ||
/** | ||
@@ -39,3 +39,3 @@ * Brisk route enables you to expose expressive API for | ||
*/ | ||
setHandler(handler: RouteHandlerNode, invokedBy: string, methods?: string[]): Route; | ||
setHandler(handler: RouteHandler, invokedBy: string, methods?: string[]): Route; | ||
} |
@@ -7,3 +7,3 @@ /** | ||
import { RouteGroupContract } from '@ioc:Adonis/Core/Route'; | ||
import { MiddlewareNode } from '@ioc:Adonis/Core/Middleware'; | ||
import { MiddlewareHandler } from '@ioc:Adonis/Core/Middleware'; | ||
import { Route } from './Route'; | ||
@@ -75,3 +75,3 @@ import { BriskRoute } from './BriskRoute'; | ||
*/ | ||
middleware(middleware: MiddlewareNode | MiddlewareNode[]): this; | ||
middleware(middleware: MiddlewareHandler | MiddlewareHandler[]): this; | ||
/** | ||
@@ -78,0 +78,0 @@ * Define namespace for all the routes inside the group. |
@@ -7,3 +7,3 @@ /** | ||
import { EncryptionContract } from '@ioc:Adonis/Core/Encryption'; | ||
import { RouteNode, RouterContract, MatchedRoute, RouteLookupNode, RouteHandlerNode, MakeUrlOptions } from '@ioc:Adonis/Core/Route'; | ||
import { RouteNode, MatchedRoute, RouterContract, MakeUrlOptions, RouteLookupNode, RouteHandler } from '@ioc:Adonis/Core/Route'; | ||
import { Route } from './Route'; | ||
@@ -73,27 +73,27 @@ import { RouteGroup } from './Group'; | ||
*/ | ||
route(pattern: string, methods: string[], handler: RouteHandlerNode): Route; | ||
route(pattern: string, methods: string[], handler: RouteHandler): Route; | ||
/** | ||
* Define a route that handles all common HTTP methods | ||
*/ | ||
any(pattern: string, handler: RouteHandlerNode): Route; | ||
any(pattern: string, handler: RouteHandler): Route; | ||
/** | ||
* Define `GET` route | ||
*/ | ||
get(pattern: string, handler: RouteHandlerNode): Route; | ||
get(pattern: string, handler: RouteHandler): Route; | ||
/** | ||
* Define `POST` route | ||
*/ | ||
post(pattern: string, handler: RouteHandlerNode): Route; | ||
post(pattern: string, handler: RouteHandler): Route; | ||
/** | ||
* Define `PUT` route | ||
*/ | ||
put(pattern: string, handler: RouteHandlerNode): Route; | ||
put(pattern: string, handler: RouteHandler): Route; | ||
/** | ||
* Define `PATCH` route | ||
*/ | ||
patch(pattern: string, handler: RouteHandlerNode): Route; | ||
patch(pattern: string, handler: RouteHandler): Route; | ||
/** | ||
* Define `DELETE` route | ||
*/ | ||
delete(pattern: string, handler: RouteHandlerNode): Route; | ||
delete(pattern: string, handler: RouteHandler): Route; | ||
/** | ||
@@ -123,3 +123,3 @@ * Creates a group of routes. A route group can apply transforms | ||
*/ | ||
toJSON(): import("@ioc:Adonis/Core/Route").RouteDefinition[]; | ||
toJSON(): import("@ioc:Adonis/Core/Route").RouteJSON[]; | ||
/** | ||
@@ -150,2 +150,3 @@ * Commit routes to the store. After this, no more | ||
expiresIn?: string | number; | ||
purpose?: string; | ||
}, domain?: string): string | null; | ||
@@ -161,3 +162,3 @@ /** | ||
*/ | ||
forTesting(pattern?: string, methods?: string[], handler?: RouteHandlerNode): Route; | ||
forTesting(pattern?: string, methods?: string[], handler?: RouteHandler): Route; | ||
} |
@@ -5,5 +5,2 @@ "use strict"; | ||
*/ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -19,3 +16,2 @@ /* | ||
/// <reference path="../../adonis-typings/index.ts" /> | ||
const ms_1 = __importDefault(require("ms")); | ||
const qs_1 = require("qs"); | ||
@@ -356,14 +352,5 @@ const utils_1 = require("@poppinss/utils"); | ||
options = Object.assign({ qs: {}, params: {}, domainParams: {}, prefixDomain: true }, options); | ||
const expiresIn = options['expiresIn']; | ||
/** | ||
* Setting the expiry of the url, when `expiresIn` duration is defined. We consider `0` | ||
* as no expiry | ||
*/ | ||
if (expiresIn) { | ||
const milliseconds = typeof (expiresIn) === 'string' ? ms_1.default(expiresIn) : expiresIn; | ||
options.qs.expires_at = Date.now() + milliseconds; | ||
} | ||
/** | ||
* Making the signature from the qualified url. We do not prefix the domain when | ||
* make url for the signature, since it just makes the signature big. | ||
* making signature, since it just makes the signature big. | ||
* | ||
@@ -375,4 +362,8 @@ * There might be a case, when someone wants to generate signature for the same route | ||
const signature = this.encryption | ||
.create({ hmac: false }) | ||
.encrypt(this.makeUrl(route.pattern, { qs: options.qs, params: options.params, prefixDomain: false })); | ||
.verifier | ||
.sign(this.makeUrl(route.pattern, { | ||
qs: options.qs, | ||
params: options.params, | ||
prefixDomain: false, | ||
}), options.expiresIn, options.purpose); | ||
/** | ||
@@ -379,0 +370,0 @@ * Adding signature to the query string and re-making the url again |
@@ -6,3 +6,3 @@ /** | ||
import { Macroable } from 'macroable'; | ||
import { MiddlewareNode } from '@ioc:Adonis/Core/Middleware'; | ||
import { MiddlewareHandler } from '@ioc:Adonis/Core/Middleware'; | ||
import { RouteMatchers, RouteResourceContract } from '@ioc:Adonis/Core/Route'; | ||
@@ -65,3 +65,3 @@ import { Route } from './Route'; | ||
middleware(middleware: { | ||
[name: string]: MiddlewareNode | MiddlewareNode[]; | ||
[name: string]: MiddlewareHandler | MiddlewareHandler[]; | ||
}): this; | ||
@@ -68,0 +68,0 @@ /** |
@@ -15,5 +15,5 @@ "use strict"; | ||
/// <reference path="../../adonis-typings/index.ts" /> | ||
const snake_case_1 = require("snake-case"); | ||
const pluralize_1 = require("pluralize"); | ||
const macroable_1 = require("macroable"); | ||
const utils_1 = require("@poppinss/utils"); | ||
const Route_1 = require("./Route"); | ||
@@ -46,3 +46,3 @@ /** | ||
.split('.') | ||
.map((token) => snake_case_1.snakeCase(token)).join('.'); | ||
.map((token) => utils_1.lodash.snakeCase(token)).join('.'); | ||
this.buildRoutes(); | ||
@@ -66,3 +66,3 @@ } | ||
const fullUrl = `${resourceTokens | ||
.map((token) => `${token}/:${snake_case_1.snakeCase(pluralize_1.singular(token))}_id`) | ||
.map((token) => `${token}/:${utils_1.lodash.snakeCase(pluralize_1.singular(token))}_id`) | ||
.join('/')}/${mainResource}`; | ||
@@ -147,3 +147,3 @@ this.makeRoute(fullUrl, ['GET'], 'index'); | ||
as(name) { | ||
name = snake_case_1.snakeCase(name); | ||
name = utils_1.lodash.snakeCase(name); | ||
this.routes.forEach((route) => { | ||
@@ -150,0 +150,0 @@ route.as(route.name.replace(this.resourceName, name), false); |
@@ -6,4 +6,4 @@ /** | ||
import { Macroable } from 'macroable'; | ||
import { RouteDefinition, RouteMatchers, RouteContract, RouteHandlerNode } from '@ioc:Adonis/Core/Route'; | ||
import { MiddlewareNode } from '@ioc:Adonis/Core/Middleware'; | ||
import { RouteJSON, RouteMatchers, RouteContract, RouteHandler } from '@ioc:Adonis/Core/Route'; | ||
import { MiddlewareHandler } from '@ioc:Adonis/Core/Middleware'; | ||
/** | ||
@@ -67,3 +67,3 @@ * Route class is used to construct consistent [[RouteDefinition]] using | ||
name: string; | ||
constructor(pattern: string, methods: string[], handler: RouteHandlerNode, globalMatchers: RouteMatchers); | ||
constructor(pattern: string, methods: string[], handler: RouteHandler, globalMatchers: RouteMatchers); | ||
/** | ||
@@ -110,3 +110,3 @@ * Returns an object of param matchers by merging global and local | ||
*/ | ||
middleware(middleware: MiddlewareNode | MiddlewareNode[], prepend?: boolean): this; | ||
middleware(middleware: MiddlewareHandler | MiddlewareHandler[], prepend?: boolean): this; | ||
/** | ||
@@ -128,3 +128,3 @@ * Give memorizable name to the route. This is helpful, when you | ||
*/ | ||
toJSON(): RouteDefinition; | ||
toJSON(): RouteJSON; | ||
} |
@@ -5,3 +5,3 @@ /** | ||
/// <reference path="../../adonis-typings/index.d.ts" /> | ||
import { RoutesTree, MatchedRoute, RouteDefinition, RouteStoreMatch } from '@ioc:Adonis/Core/Route'; | ||
import { RoutesTree, MatchedRoute, RouteJSON, RouteStoreMatch } from '@ioc:Adonis/Core/Route'; | ||
/** | ||
@@ -43,2 +43,6 @@ * Store class is used to store a list of routes, along side with their tokens | ||
private matchDomainNoop; | ||
/** | ||
* The implementation used for matching domain. Will pivot to `matchDomainReal` | ||
* when one or more domains will be defined | ||
*/ | ||
matchDomain: any; | ||
@@ -72,3 +76,3 @@ /** | ||
*/ | ||
add(route: RouteDefinition): this; | ||
add(route: RouteJSON): this; | ||
/** | ||
@@ -75,0 +79,0 @@ * Matches the url, method and optionally domain to pull the matching |
@@ -19,3 +19,2 @@ "use strict"; | ||
const matchit_1 = __importDefault(require("matchit")); | ||
const lodash_1 = require("lodash"); | ||
const clone_deep_1 = __importDefault(require("clone-deep")); | ||
@@ -64,2 +63,6 @@ const utils_1 = require("@poppinss/utils"); | ||
}.bind(this); | ||
/** | ||
* The implementation used for matching domain. Will pivot to `matchDomainReal` | ||
* when one or more domains will be defined | ||
*/ | ||
this.matchDomain = this.matchDomainNoop; | ||
@@ -120,3 +123,3 @@ } | ||
*/ | ||
const routeJSON = clone_deep_1.default(lodash_1.pick(route, [ | ||
const routeJSON = clone_deep_1.default(utils_1.lodash.pick(route, [ | ||
'pattern', | ||
@@ -123,0 +126,0 @@ 'handler', |
@@ -5,3 +5,3 @@ /** | ||
/// <reference path="../../../adonis-typings/index.d.ts" /> | ||
import { HookNode, HooksContract } from '@ioc:Adonis/Core/Server'; | ||
import { HookHandler, HooksContract } from '@ioc:Adonis/Core/Server'; | ||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'; | ||
@@ -19,7 +19,7 @@ /** | ||
*/ | ||
before(cb: HookNode): this; | ||
before(cb: HookHandler): this; | ||
/** | ||
* Register after hook | ||
*/ | ||
after(cb: HookNode): this; | ||
after(cb: HookHandler): this; | ||
/** | ||
@@ -26,0 +26,0 @@ * Executing before hooks in series. If this method returns `true`, |
@@ -12,3 +12,3 @@ /** | ||
import { ProfilerContract } from '@ioc:Adonis/Core/Profiler'; | ||
import { ServerContract, ServerConfigContract, ErrorHandlerNode } from '@ioc:Adonis/Core/Server'; | ||
import { ServerContract, ServerConfig, ErrorHandler } from '@ioc:Adonis/Core/Server'; | ||
import { Hooks } from './Hooks'; | ||
@@ -56,3 +56,3 @@ import { Router } from '../Router'; | ||
private requestHandler; | ||
constructor(container: IocContract, logger: LoggerContract, profiler: ProfilerContract, encryption: EncryptionContract, httpConfig: ServerConfigContract); | ||
constructor(container: IocContract, logger: LoggerContract, profiler: ProfilerContract, encryption: EncryptionContract, httpConfig: ServerConfig); | ||
/** | ||
@@ -65,3 +65,3 @@ * Handles HTTP request | ||
*/ | ||
private getProfileRow; | ||
private getProfilerRow; | ||
/** | ||
@@ -75,3 +75,3 @@ * Returns the context for the request | ||
*/ | ||
errorHandler(handler: ErrorHandlerNode): this; | ||
errorHandler(handler: ErrorHandler): this; | ||
/** | ||
@@ -78,0 +78,0 @@ * Optimizes internal handlers, based upon the existence of |
@@ -85,3 +85,3 @@ "use strict"; | ||
*/ | ||
getProfileRow(request) { | ||
getProfilerRow(request) { | ||
return this.profiler.create('http:request', { | ||
@@ -132,4 +132,4 @@ request_id: request.id(), | ||
const request = new Request_1.Request(req, res, this.encryption, this.httpConfig); | ||
const response = new Response_1.Response(req, res, this.httpConfig); | ||
const requestAction = this.getProfileRow(request); | ||
const response = new Response_1.Response(req, res, this.encryption, this.httpConfig); | ||
const requestAction = this.getProfilerRow(request); | ||
const ctx = this.getContext(request, response, requestAction); | ||
@@ -136,0 +136,0 @@ /** |
@@ -1,4 +0,1 @@ | ||
/** | ||
* @module @adonisjs/http-server | ||
*/ | ||
export { Router } from './src/Router'; | ||
@@ -5,0 +2,0 @@ export { Server } from './src/Server'; |
"use strict"; | ||
/** | ||
* @module @adonisjs/http-server | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* | ||
@@ -14,2 +10,3 @@ * @adonisjs/http-server | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Router_1 = require("./src/Router"); | ||
@@ -16,0 +13,0 @@ exports.Router = Router_1.Router; |
{ | ||
"name": "@adonisjs/http-server", | ||
"version": "1.8.2", | ||
"description": "Extracted copy of AdonisJs HTTP server along with it's router", | ||
"version": "2.0.0", | ||
"description": "AdonisJS HTTP server with support packed with Routing and Cookies", | ||
"main": "build/providers/HttpServerProvider.js", | ||
@@ -34,9 +34,11 @@ "files": [ | ||
"devDependencies": { | ||
"@adonisjs/encryption": "^1.0.4", | ||
"@adonisjs/encryption": "^2.0.1", | ||
"@adonisjs/fold": "^6.3.3", | ||
"@adonisjs/logger": "^1.1.9", | ||
"@adonisjs/mrm-preset": "^2.2.4", | ||
"@adonisjs/profiler": "^2.0.0", | ||
"@poppinss/dev-utils": "^1.0.4", | ||
"@types/node": "^13.7.7", | ||
"@adonisjs/logger": "^2.0.0", | ||
"@adonisjs/mrm-preset": "^2.3.0", | ||
"@adonisjs/profiler": "^3.0.0", | ||
"@poppinss/dev-utils": "^1.0.5", | ||
"@types/cookie": "^0.3.3", | ||
"@types/ms": "^0.7.31", | ||
"@types/node": "^13.11.1", | ||
"@types/pluralize": "0.0.29", | ||
@@ -46,3 +48,3 @@ "@types/proxy-addr": "^2.0.0", | ||
"autocannon": "^4.6.0", | ||
"commitizen": "^4.0.3", | ||
"commitizen": "^4.0.4", | ||
"cz-conventional-changelog": "^3.1.0", | ||
@@ -52,8 +54,8 @@ "del-cli": "^3.0.0", | ||
"eslint": "^6.8.0", | ||
"eslint-plugin-adonis": "^1.0.8", | ||
"fastify": "^2.12.1", | ||
"eslint-plugin-adonis": "^1.0.9", | ||
"fastify": "^2.13.0", | ||
"http-status-codes": "^1.4.0", | ||
"husky": "^4.2.3", | ||
"husky": "^4.2.5", | ||
"japa": "^3.0.0", | ||
"mrm": "^2.1.0", | ||
"mrm": "^2.2.1", | ||
"np": "^5.2.1", | ||
@@ -63,4 +65,4 @@ "pem": "^1.14.4", | ||
"supertest": "^4.0.2", | ||
"ts-node": "^8.6.2", | ||
"typedoc": "^0.16.11", | ||
"ts-node": "^8.8.2", | ||
"typedoc": "^0.17.4", | ||
"typedoc-plugin-external-module-name": "^3.0.0", | ||
@@ -71,5 +73,5 @@ "typedoc-plugin-markdown": "^2.2.17", | ||
"peerDependencies": { | ||
"@adonisjs/encryption": "^1.x.x", | ||
"@adonisjs/logger": "^1.x.x", | ||
"@adonisjs/profiler": "^2.x.x" | ||
"@adonisjs/encryption": "2.x.x", | ||
"@adonisjs/logger": "2.x.x", | ||
"@adonisjs/profiler": "3.x.x" | ||
}, | ||
@@ -100,7 +102,6 @@ "nyc": { | ||
"dependencies": { | ||
"@poppinss/cookie": "^1.0.8", | ||
"@poppinss/utils": "^2.1.2", | ||
"@poppinss/utils": "^2.2.3", | ||
"accepts": "^1.3.7", | ||
"clone-deep": "^4.0.1", | ||
"co-compose": "^5.1.3", | ||
"co-compose": "^5.1.4", | ||
"content-disposition": "^0.5.3", | ||
@@ -113,4 +114,3 @@ "cuid": "^2.1.8", | ||
"haye": "^2.0.2", | ||
"lodash": "^4.17.15", | ||
"macroable": "^4.0.2", | ||
"macroable": "^4.0.3", | ||
"matchit": "git+https://github.com/thetutlage/matchit.git", | ||
@@ -121,6 +121,4 @@ "ms": "^2.1.2", | ||
"proxy-addr": "^2.0.6", | ||
"qs": "^6.9.1", | ||
"quick-lru": "^5.0.0", | ||
"snake-case": "^3.0.3", | ||
"ts-essentials": "^6.0.2", | ||
"qs": "^6.9.3", | ||
"quick-lru": "^5.1.0", | ||
"type-is": "^1.6.18", | ||
@@ -127,0 +125,0 @@ "vary": "^1.1.2" |
@@ -71,3 +71,5 @@ <div align="center"><img src="https://res.cloudinary.com/adonisjs/image/upload/q_100/v1564392111/adonis-banner_o9lunk.png" width="600px"></div> | ||
const profiler = new Profiler({ enabled: true }) | ||
const encryption = new Encryption('averylongrandom32charslongsecret') | ||
const encryption = new Encryption({ | ||
secret: 'averylongrandom32charslongsecret', | ||
}) | ||
@@ -80,3 +82,2 @@ const server = new Server(new Ioc(), logger, profiler, encryption, { | ||
generateRequestId: false, | ||
secret: Math.random().toFixed(36).substring(2, 38), | ||
trustProxy: proxyaddr.compile('loopback'), | ||
@@ -83,0 +84,0 @@ allowMethodSpoofing: false, |
243394
24
63
7023
107
33
+ Added@adonisjs/encryption@2.0.6(transitive)
+ Added@adonisjs/logger@2.1.0(transitive)
+ Added@adonisjs/profiler@3.0.4(transitive)
+ Added@types/pino@6.3.12(transitive)
+ Added@types/pino-pretty@5.0.0(transitive)
+ Added@types/pino-std-serializers@4.0.0(transitive)
+ Addedcolorette@2.0.20(transitive)
+ Addeddateformat@4.6.3(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedfast-copy@3.0.2(transitive)
+ Addedhelp-me@5.0.0(transitive)
+ Addedjest-worker@26.6.2(transitive)
+ Addedjoycon@3.1.1(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedon-exit-leak-free@2.1.2(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpino-abstract-transport@2.0.0(transitive)
+ Addedpino-pretty@13.0.0(transitive)
+ Addedpino-std-serializers@7.0.0(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedsecure-json-parse@2.7.0(transitive)
+ Addedsonic-boom@2.8.04.2.0(transitive)
+ Addedsplit2@4.2.0(transitive)
+ Addedstrip-json-comments@3.1.1(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removed@poppinss/cookie@^1.0.8
- Removedlodash@^4.17.15
- Removedsnake-case@^3.0.3
- Removedts-essentials@^6.0.2
- Removed@adonisjs/encryption@1.0.4(transitive)
- Removed@adonisjs/logger@1.2.0(transitive)
- Removed@adonisjs/profiler@2.0.0(transitive)
- Removed@hapi/bourne@2.1.0(transitive)
- Removed@poppinss/cookie@1.0.8(transitive)
- Removed@types/events@3.0.3(transitive)
- Removed@types/pino@5.20.0(transitive)
- Removedcookie@0.4.2(transitive)
- Removedcookie-signature@1.2.2(transitive)
- Removeddot-case@3.0.4(transitive)
- Removedjest-worker@25.5.0(transitive)
- Removedlodash@4.17.21(transitive)
- Removedlower-case@2.0.2(transitive)
- Removedno-case@3.0.4(transitive)
- Removedscmp@2.0.0(transitive)
- Removedsimple-encryptor@3.0.0(transitive)
- Removedsnake-case@3.0.4(transitive)
- Removedts-essentials@6.0.7(transitive)
- Removedtslib@2.8.1(transitive)
- Removedtypescript@5.7.3(transitive)
Updated@poppinss/utils@^2.2.3
Updatedco-compose@^5.1.4
Updatedmacroable@^4.0.3
Updatedqs@^6.9.3
Updatedquick-lru@^5.1.0