@adonisjs/http-server
Advanced tools
Comparing version 4.0.0 to 4.0.1
@@ -9,2 +9,4 @@ /** | ||
*/ | ||
/// <reference types="@adonisjs/logger/build/adonis-typings/logger" /> | ||
/// <reference types="@adonisjs/profiler/build/adonis-typings/profiler" /> | ||
/// <reference types="node" /> | ||
@@ -11,0 +13,0 @@ declare module '@ioc:Adonis/Core/HttpContext' { |
@@ -26,3 +26,3 @@ /** | ||
} | { | ||
type: 'autoload' | 'binding'; | ||
type: 'alias' | 'binding'; | ||
namespace: string; | ||
@@ -29,0 +29,0 @@ method: string; |
@@ -13,5 +13,5 @@ /** | ||
import { MacroableConstructorContract } from 'macroable'; | ||
import { MakeUrlOptions } from '@ioc:Adonis/Core/Route'; | ||
import { EncryptionContract } from '@ioc:Adonis/Core/Encryption'; | ||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'; | ||
import { MakeUrlOptions, RouterContract } from '@ioc:Adonis/Core/Route'; | ||
/** | ||
@@ -415,3 +415,3 @@ * Cookie options can that can be set on the response | ||
export interface ResponseConstructorContract extends MacroableConstructorContract<ResponseContract> { | ||
new (request: IncomingMessage, response: ServerResponse, encryption: EncryptionContract, config: ResponseConfig): ResponseContract; | ||
new (request: IncomingMessage, response: ServerResponse, encryption: EncryptionContract, config: ResponseConfig, router: RouterContract): ResponseContract; | ||
} | ||
@@ -418,0 +418,0 @@ const Response: ResponseConstructorContract; |
@@ -24,3 +24,3 @@ /** | ||
} | { | ||
type: 'autoload' | 'binding'; | ||
type: 'alias' | 'binding'; | ||
namespace: string; | ||
@@ -409,3 +409,3 @@ method: string; | ||
*/ | ||
toJSON(): RouteNode[]; | ||
toJSON(): RouteLookupNode[]; | ||
/** | ||
@@ -412,0 +412,0 @@ * Commit routes to the store. After this, no more |
@@ -9,6 +9,6 @@ /** | ||
*/ | ||
import { IocContract } from '@adonisjs/fold'; | ||
import { ApplicationContract } from '@ioc:Adonis/Core/Application'; | ||
export default class HttpServerProvider { | ||
protected container: IocContract; | ||
constructor(container: IocContract); | ||
protected application: ApplicationContract; | ||
constructor(application: ApplicationContract); | ||
/** | ||
@@ -15,0 +15,0 @@ * Register request and response bindings to the container |
@@ -12,4 +12,4 @@ "use strict"; | ||
class HttpServerProvider { | ||
constructor(container) { | ||
this.container = container; | ||
constructor(application) { | ||
this.application = application; | ||
} | ||
@@ -20,6 +20,6 @@ /** | ||
registerRequestResponse() { | ||
this.container.singleton('Adonis/Core/Request', () => { | ||
this.application.container.singleton('Adonis/Core/Request', () => { | ||
return require('../src/Request').Request; | ||
}); | ||
this.container.singleton('Adonis/Core/Response', () => { | ||
this.application.container.singleton('Adonis/Core/Response', () => { | ||
return require('../src/Response').Response; | ||
@@ -32,3 +32,3 @@ }); | ||
registerMiddlewareStore() { | ||
this.container.bind('Adonis/Core/MiddlewareStore', () => { | ||
this.application.container.bind('Adonis/Core/MiddlewareStore', () => { | ||
return require('../src/MiddlewareStore').MiddlewareStore; | ||
@@ -41,5 +41,5 @@ }); | ||
registerHTTPContext() { | ||
this.container.bind('Adonis/Core/HttpContext', () => { | ||
this.application.container.bind('Adonis/Core/HttpContext', () => { | ||
const { HttpContext } = require('../src/HttpContext'); | ||
HttpContext.app = this.container.use('Adonis/Core/Application'); | ||
HttpContext.app = this.application.container.use('Adonis/Core/Application'); | ||
return HttpContext; | ||
@@ -52,9 +52,7 @@ }); | ||
registerHttpServer() { | ||
this.container.singleton('Adonis/Core/Server', () => { | ||
this.application.container.singleton('Adonis/Core/Server', () => { | ||
const { Server } = require('../src/Server'); | ||
const Logger = this.container.use('Adonis/Core/Logger'); | ||
const Profiler = this.container.use('Adonis/Core/Profiler'); | ||
const Config = this.container.use('Adonis/Core/Config'); | ||
const Encryption = this.container.use('Adonis/Core/Encryption'); | ||
return new Server(this.container, Logger, Profiler, Encryption, Config.get('app.http', {})); | ||
const Config = this.application.container.use('Adonis/Core/Config'); | ||
const Encryption = this.application.container.use('Adonis/Core/Encryption'); | ||
return new Server(this.application, Encryption, Config.get('app.http', {})); | ||
}); | ||
@@ -67,4 +65,4 @@ } | ||
registerRouter() { | ||
this.container.singleton('Adonis/Core/Route', () => { | ||
return this.container.use('Adonis/Core/Server').router; | ||
this.application.container.singleton('Adonis/Core/Route', () => { | ||
return this.application.container.use('Adonis/Core/Server').router; | ||
}); | ||
@@ -71,0 +69,0 @@ } |
@@ -10,2 +10,4 @@ /** | ||
/// <reference path="../../adonis-typings/index.d.ts" /> | ||
/// <reference types="@adonisjs/logger/build/adonis-typings/logger" /> | ||
/// <reference types="@adonisjs/profiler/build/adonis-typings/profiler" /> | ||
/// <reference types="node" /> | ||
@@ -12,0 +14,0 @@ import { Macroable } from 'macroable'; |
@@ -60,5 +60,3 @@ "use strict"; | ||
static create(routePattern, routeParams, req, res) { | ||
const Logger = HttpContext.app.container.use('Adonis/Core/Logger'); | ||
const Router = HttpContext.app.container.use('Adonis/Core/Route'); | ||
const Profiler = HttpContext.app.container.use('Adonis/Core/Profiler'); | ||
const Encryption = HttpContext.app.container.use('Adonis/Core/Encryption'); | ||
@@ -93,3 +91,3 @@ const serverConfig = HttpContext.app.container.use('Adonis/Core/Config').get('app.http', {}); | ||
*/ | ||
const ctx = new HttpContext(request, response, Logger, Profiler); | ||
const ctx = new HttpContext(request, response, this.app.logger.child({}), this.app.profiler.create('http:context')); | ||
/* | ||
@@ -112,2 +110,6 @@ * Attaching route to the ctx | ||
ctx.params = routeParams; | ||
/** | ||
* Set params on the request | ||
*/ | ||
ctx.request.updateParams(routeParams); | ||
return ctx; | ||
@@ -114,0 +116,0 @@ } |
@@ -10,3 +10,2 @@ /** | ||
/// <reference path="../../adonis-typings/index.d.ts" /> | ||
/// <reference path="../../adonis-typings/route.d.ts" /> | ||
import { EncryptionContract } from '@ioc:Adonis/Core/Encryption'; | ||
@@ -127,3 +126,3 @@ import { RouteNode, RouteHandler, MatchedRoute, RouterContract, MakeUrlOptions, RouteLookupNode, MakeSignedUrlOptions } from '@ioc:Adonis/Core/Route'; | ||
*/ | ||
toJSON(): import("@ioc:Adonis/Core/Route").RouteJSON[]; | ||
toJSON(): RouteLookupNode[]; | ||
/** | ||
@@ -130,0 +129,0 @@ * Commit routes to the store. After this, no more |
@@ -223,3 +223,3 @@ "use strict"; | ||
toJSON() { | ||
return helpers_1.toRoutesJSON(this.routes); | ||
return this.lookupStore; | ||
} | ||
@@ -232,3 +232,3 @@ /** | ||
const names = []; | ||
this.toJSON().forEach((route) => { | ||
helpers_1.toRoutesJSON(this.routes).forEach((route) => { | ||
/* | ||
@@ -235,0 +235,0 @@ * Raise error when route name is already in use. Route names have to be unique |
@@ -10,3 +10,3 @@ /** | ||
/// <reference path="../../adonis-typings/index.d.ts" /> | ||
import { RoutesTree, MatchedRoute, RouteJSON, RouteStoreMatch } from '@ioc:Adonis/Core/Route'; | ||
import { RouteJSON, RoutesTree, MatchedRoute, RouteStoreMatch } from '@ioc:Adonis/Core/Route'; | ||
/** | ||
@@ -13,0 +13,0 @@ * Store class is used to store a list of routes, along side with their tokens |
@@ -11,8 +11,6 @@ /** | ||
/// <reference types="node" /> | ||
import { IocContract } from '@adonisjs/fold'; | ||
import { Server as HttpsServer } from 'https'; | ||
import { LoggerContract } from '@ioc:Adonis/Core/Logger'; | ||
import { EncryptionContract } from '@ioc:Adonis/Core/Encryption'; | ||
import { ApplicationContract } from '@ioc:Adonis/Core/Application'; | ||
import { IncomingMessage, ServerResponse, Server as HttpServer } from 'http'; | ||
import { ProfilerContract } from '@ioc:Adonis/Core/Profiler'; | ||
import { ServerContract, ServerConfig, ErrorHandler } from '@ioc:Adonis/Core/Server'; | ||
@@ -26,5 +24,3 @@ import { Hooks } from './Hooks'; | ||
export declare class Server implements ServerContract { | ||
private container; | ||
private logger; | ||
private profiler; | ||
private application; | ||
private encryption; | ||
@@ -62,3 +58,3 @@ private httpConfig; | ||
private requestHandler; | ||
constructor(container: IocContract, logger: LoggerContract, profiler: ProfilerContract, encryption: EncryptionContract, httpConfig: ServerConfig); | ||
constructor(application: ApplicationContract, encryption: EncryptionContract, httpConfig: ServerConfig); | ||
/** | ||
@@ -65,0 +61,0 @@ * Handles HTTP request |
@@ -30,6 +30,4 @@ "use strict"; | ||
class Server { | ||
constructor(container, logger, profiler, encryption, httpConfig) { | ||
this.container = container; | ||
this.logger = logger; | ||
this.profiler = profiler; | ||
constructor(application, encryption, httpConfig) { | ||
this.application = application; | ||
this.encryption = encryption; | ||
@@ -40,3 +38,3 @@ this.httpConfig = httpConfig; | ||
*/ | ||
this.middleware = new MiddlewareStore_1.MiddlewareStore(this.container); | ||
this.middleware = new MiddlewareStore_1.MiddlewareStore(this.application.container); | ||
/** | ||
@@ -53,7 +51,7 @@ * The route to register routes | ||
*/ | ||
this.precompiler = new PreCompiler_1.PreCompiler(this.container, this.middleware); | ||
this.precompiler = new PreCompiler_1.PreCompiler(this.application.container, this.middleware); | ||
/** | ||
* Exception manager to handle exceptions | ||
*/ | ||
this.exception = new ExceptionManager_1.ExceptionManager(this.container); | ||
this.exception = new ExceptionManager_1.ExceptionManager(this.application.container); | ||
/** | ||
@@ -88,3 +86,3 @@ * Request handler to handle request after route is found | ||
getProfilerRow(request) { | ||
return this.profiler.create('http:request', { | ||
return this.application.profiler.create('http:request', { | ||
request_id: request.id(), | ||
@@ -99,3 +97,3 @@ url: request.url(), | ||
getContext(request, response, profilerRow) { | ||
return new HttpContext_1.HttpContext(request, response, this.logger.child({ | ||
return new HttpContext_1.HttpContext(request, response, this.application.logger.child({ | ||
request_id: request.id(), | ||
@@ -102,0 +100,0 @@ serializers: {}, |
@@ -46,3 +46,3 @@ "use strict"; | ||
else { | ||
returnValue = await this.resolver.call(routeHandler, ctx.route.meta.namespace, [ctx]); | ||
returnValue = await this.resolver.call(routeHandler, undefined, [ctx]); | ||
} | ||
@@ -49,0 +49,0 @@ if (helpers_1.useReturnValue(returnValue, ctx)) { |
{ | ||
"name": "@adonisjs/http-server", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "AdonisJS HTTP server with support packed with Routing and Cookies", | ||
@@ -21,3 +21,3 @@ "main": "build/providers/HttpServerProvider.js", | ||
"build": "npm run compile", | ||
"benchmark": "node build/benchmarks/index.js", | ||
"benchmark": "ENV_SILENT=true node build/benchmarks/index.js", | ||
"build:tmp": "npm run compile", | ||
@@ -39,9 +39,5 @@ "commit": "git-cz", | ||
"devDependencies": { | ||
"@adonisjs/application": "^3.0.0", | ||
"@adonisjs/config": "^2.0.0", | ||
"@adonisjs/encryption": "^2.0.6", | ||
"@adonisjs/fold": "^6.3.5", | ||
"@adonisjs/logger": "^3.0.0", | ||
"@adonisjs/application": "^3.0.5", | ||
"@adonisjs/encryption": "^3.0.0", | ||
"@adonisjs/mrm-preset": "^2.4.0", | ||
"@adonisjs/profiler": "^5.0.1", | ||
"@adonisjs/require-ts": "^1.0.0", | ||
@@ -77,9 +73,6 @@ "@poppinss/dev-utils": "^1.0.10", | ||
"supertest": "^4.0.2", | ||
"ts-node": "^9.0.0", | ||
"typescript": "^4.0.3" | ||
}, | ||
"peerDependencies": { | ||
"@adonisjs/encryption": "^2.0.0", | ||
"@adonisjs/logger": "^3.0.0", | ||
"@adonisjs/profiler": "^5.0.0" | ||
"@adonisjs/application": "^3.0.0" | ||
}, | ||
@@ -86,0 +79,0 @@ "nyc": { |
301769
23
34
72
8785