@adonisjs/core
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -5,1 +5,2 @@ export { Ignitor } from './src/Ignitor'; | ||
export { HelpersContract } from './src/Contracts/Helpers'; | ||
export { LoggerContract, LoggerConfig } from './src/Contracts/Logger'; |
@@ -0,10 +1,16 @@ | ||
import { IocContract } from '@adonisjs/fold'; | ||
export default class AppProvider { | ||
app: any; | ||
constructor(app: any); | ||
app: IocContract; | ||
constructor(app: IocContract); | ||
private _registerEnv; | ||
private _registerConfig; | ||
private _registerHttpMiddleware; | ||
private _registerRequest; | ||
private _registerResponse; | ||
private _registerRoute; | ||
private _registerLogger; | ||
private _registerServer; | ||
private _registerBodyParserMiddleware; | ||
register(): void; | ||
boot(): void; | ||
} |
@@ -7,4 +7,7 @@ "use strict"; | ||
const response_1 = require("@adonisjs/response"); | ||
const bodyparser_1 = require("@adonisjs/bodyparser"); | ||
const Config_1 = require("../src/Config"); | ||
const Env_1 = require("../src/Env"); | ||
const Logger_1 = require("../src/Logger"); | ||
const logger_1 = require("../config/logger"); | ||
class AppProvider { | ||
@@ -34,2 +37,12 @@ constructor(app) { | ||
} | ||
_registerRequest() { | ||
this.app.singleton('Adonis/Src/Request', () => { | ||
return request_1.Request; | ||
}); | ||
} | ||
_registerResponse() { | ||
this.app.singleton('Adonis/Src/Response', () => { | ||
return response_1.Response; | ||
}); | ||
} | ||
_registerRoute() { | ||
@@ -41,11 +54,26 @@ this.app.singleton('Adonis/Src/Route', (app) => { | ||
} | ||
_registerLogger() { | ||
this.app.singleton('Adonis/Src/Logger', (app) => { | ||
const loggerConfig = app.use('Adonis/Src/Config').get('app.logger', {}); | ||
return new Logger_1.Logger(loggerConfig); | ||
}); | ||
this.app.alias('Adonis/Src/Logger', 'Logger'); | ||
} | ||
_registerServer() { | ||
this.app.singleton('Adonis/Src/Server', (app) => { | ||
const Route = app.use('Adonis/Src/Route'); | ||
const HttpRequest = app.use('Adonis/Src/Request'); | ||
const HttpResponse = app.use('Adonis/Src/Response'); | ||
const HttpMiddleware = app.use('Adonis/Src/HttpMiddleware'); | ||
const httpConfig = app.use('Adonis/Src/Config').get('app.http', {}); | ||
return new server_1.Server(request_1.Request, response_1.Response, Route, HttpMiddleware, httpConfig); | ||
return new server_1.Server(HttpRequest, HttpResponse, Route, HttpMiddleware, httpConfig); | ||
}); | ||
this.app.alias('Adonis/Src/Server', 'Server'); | ||
} | ||
_registerBodyParserMiddleware() { | ||
this.app.bind('Adonis/Middleware/BodyParser', (app) => { | ||
const config = app.use('Adonis/Src/Config').get('bodyparser', {}); | ||
return new bodyparser_1.BodyParserMiddleware(config); | ||
}); | ||
} | ||
register() { | ||
@@ -55,6 +83,17 @@ this._registerEnv(); | ||
this._registerRoute(); | ||
this._registerRequest(); | ||
this._registerResponse(); | ||
this._registerLogger(); | ||
this._registerServer(); | ||
this._registerHttpMiddleware(); | ||
this._registerBodyParserMiddleware(); | ||
} | ||
boot() { | ||
this.app.with(['Adonis/Src/Config'], (Config) => { | ||
Config.defaults('app.http', Object.assign({}, request_1.requestConfig, response_1.responseConfig)); | ||
Config.defaults('app.logger', logger_1.loggerConfig); | ||
Config.defaults('bodyparser', bodyparser_1.bodyParserConfig); | ||
}); | ||
} | ||
} | ||
exports.default = AppProvider; |
@@ -10,3 +10,4 @@ import { ConfigContract } from '../Contracts/Config'; | ||
merge(key: string, defaultValues: object, customizer?: Function): any; | ||
defaults(key: string, value: any): void; | ||
set(key: string, value: any): void; | ||
} |
@@ -32,2 +32,11 @@ "use strict"; | ||
} | ||
defaults(key, value) { | ||
const existingValue = this.get(key); | ||
if (!existingValue) { | ||
this.set(key, value); | ||
} | ||
else { | ||
lodash_1.mergeWith(this.get(key), value); | ||
} | ||
} | ||
set(key, value) { | ||
@@ -34,0 +43,0 @@ lodash_1.set(this._configCache, key, value); |
@@ -5,3 +5,4 @@ export interface ConfigContract { | ||
set(key: string, value: any): void; | ||
defaults(key: string, value: any): void; | ||
sync(): void; | ||
} |
@@ -35,3 +35,3 @@ import { Ioc } from '@adonisjs/fold'; | ||
private _bootstrap; | ||
private _createHttp; | ||
private _createHttpServer; | ||
private _listen; | ||
@@ -38,0 +38,0 @@ onProfile(callback: ProfilerSubscriber): void; |
@@ -121,3 +121,3 @@ "use strict"; | ||
} | ||
_createHttp(serverCallback) { | ||
_createHttpServer(serverCallback) { | ||
const server = this.ioc.use('Adonis/Src/Server'); | ||
@@ -132,7 +132,11 @@ const router = this.ioc.use('Adonis/Src/Route'); | ||
const handler = server.handle.bind(server); | ||
this.server = serverCallback ? serverCallback(handler) : http_1.createServer(server.handle.bind(server)); | ||
this.server = serverCallback ? serverCallback(handler) : http_1.createServer(handler); | ||
} | ||
_listen(port, host) { | ||
_listen() { | ||
return new Promise((resolve, reject) => { | ||
const startServerAction = this._bootstrapper.profile('server:listen'); | ||
const Env = this.ioc.use('Adonis/Src/Env'); | ||
const Logger = this.ioc.use('Adonis/Src/Logger'); | ||
const host = Env.get('HOST', '0.0.0.0'); | ||
const port = Env.get('PORT', '3333'); | ||
this.server.listen(port, host, (error) => { | ||
@@ -144,2 +148,3 @@ startServerAction.end(); | ||
else { | ||
Logger.info('started server on %s:%s', host, port); | ||
resolve(); | ||
@@ -157,6 +162,6 @@ } | ||
await this._bootstrap(); | ||
this._createHttp(serverCallback); | ||
const Env = this.ioc.use('Adonis/Src/Env'); | ||
await this._listen(Env.get('PORT'), Env.get('HOST')); | ||
this._createHttpServer(serverCallback); | ||
await this._listen(); | ||
this._bootstrapper = null; | ||
this.preloads = []; | ||
} | ||
@@ -163,0 +168,0 @@ catch (error) { |
@@ -6,2 +6,15 @@ # Change Log | ||
# [1.4.0](https://github.com/adonisjs/adonis-framework/tree/master/packages/core/compare/@adonisjs/core@1.3.1...@adonisjs/core@1.4.0) (2019-02-22) | ||
### Features | ||
* **config:** allow merging defaults with user config ([6173839](https://github.com/adonisjs/adonis-framework/tree/master/packages/core/commit/6173839)) | ||
* **logger:** add logger ([054b64c](https://github.com/adonisjs/adonis-framework/tree/master/packages/core/commit/054b64c)) | ||
* **logger:** bind logger to the container ([bc79103](https://github.com/adonisjs/adonis-framework/tree/master/packages/core/commit/bc79103)) | ||
## [1.3.1](https://github.com/adonisjs/adonis-framework/tree/master/packages/core/compare/@adonisjs/core@1.3.0...@adonisjs/core@1.3.1) (2019-02-20) | ||
@@ -8,0 +21,0 @@ |
{ | ||
"name": "@adonisjs/core", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "AdonisJs core package", | ||
@@ -49,11 +49,13 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"@adonisjs/fold": "^5.0.3", | ||
"@adonisjs/profiler": "^1.1.2", | ||
"@adonisjs/request": "^1.1.8", | ||
"@adonisjs/response": "^1.1.9", | ||
"@adonisjs/router": "^1.5.2", | ||
"@adonisjs/server": "^1.2.3", | ||
"@adonisjs/utils": "^1.3.2", | ||
"@adonisjs/bodyparser": "^2.1.1", | ||
"@adonisjs/fold": "^5.0.4", | ||
"@adonisjs/profiler": "^1.1.3", | ||
"@adonisjs/request": "^1.1.9", | ||
"@adonisjs/response": "^1.1.10", | ||
"@adonisjs/router": "^1.5.3", | ||
"@adonisjs/server": "^1.2.4", | ||
"@adonisjs/utils": "^1.3.3", | ||
"dotenv": "^6.2.0", | ||
"lodash": "^4.17.11", | ||
"pino": "^5.11.1", | ||
"require-all": "^3.0.0" | ||
@@ -64,5 +66,6 @@ }, | ||
"fs-extra": "^7.0.1", | ||
"split2": "^3.1.0", | ||
"supertest": "^3.4.2" | ||
}, | ||
"gitHead": "58d893639760310fd95f676c8489ea1cf959deb3" | ||
"gitHead": "6015ab0919495593206e7317d78a3e7ff0b97afc" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32256
27
725
12
4
+ Added@adonisjs/bodyparser@^2.1.1
+ Addedpino@^5.11.1
+ Added@adonisjs/bodyparser@2.3.0(transitive)
+ Added@adonisjs/generic-exceptions@2.0.1(transitive)
+ Added@hapi/bourne@3.0.0(transitive)
+ Addedat-least-node@1.0.0(transitive)
+ Addedatomic-sleep@1.0.0(transitive)
+ Addedbytes@3.1.2(transitive)
+ Addedco-body@6.2.0(transitive)
+ Addedcross-env@5.2.1(transitive)
+ Addedcross-spawn@6.0.5(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addeddepd@1.1.22.0.0(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedfast-redact@2.1.0(transitive)
+ Addedflatstr@1.0.12(transitive)
+ Addedfs-extra@9.1.0(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhttp-errors@1.8.12.0.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinflation@2.1.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedjsonfile@6.1.0(transitive)
+ Addedmedia-typer@1.1.0(transitive)
+ Addedmultiparty@4.2.3(transitive)
+ Addednice-try@1.0.5(transitive)
+ Addednode-exceptions@3.0.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-key@2.0.1(transitive)
+ Addedpino@5.17.0(transitive)
+ Addedpino-std-serializers@2.5.0(transitive)
+ Addedquick-format-unescaped@3.0.3(transitive)
+ Addedrandom-bytes@1.0.0(transitive)
+ Addedraw-body@2.5.2(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedsetprototypeof@1.2.0(transitive)
+ Addedshebang-command@1.2.0(transitive)
+ Addedshebang-regex@1.0.0(transitive)
+ Addedsonic-boom@0.7.7(transitive)
+ Addedstatuses@1.5.02.0.1(transitive)
+ Addedtoidentifier@1.0.1(transitive)
+ Addeduid-safe@2.1.5(transitive)
+ Addeduniversalify@2.0.1(transitive)
+ Addedunpipe@1.0.0(transitive)
+ Addedupcast@2.1.2(transitive)
+ Addedwhich@1.3.1(transitive)
+ Addedwrappy@1.0.2(transitive)
Updated@adonisjs/fold@^5.0.4
Updated@adonisjs/profiler@^1.1.3
Updated@adonisjs/request@^1.1.9
Updated@adonisjs/response@^1.1.10
Updated@adonisjs/router@^1.5.3
Updated@adonisjs/server@^1.2.4
Updated@adonisjs/utils@^1.3.3