@loopback/core
Advanced tools
Comparing version 4.0.0-alpha.7 to 4.0.0-alpha.8
@@ -8,3 +8,3 @@ /// <reference types="node" /> | ||
export declare class Application extends Context { | ||
appConfig: AppConfig; | ||
options: ApplicationOptions; | ||
/** | ||
@@ -29,3 +29,4 @@ * Handle incoming HTTP(S) request by invoking the corresponding | ||
protected _httpHandler: HttpHandler; | ||
constructor(appConfig?: AppConfig); | ||
constructor(options?: ApplicationOptions); | ||
protected _bindSequence(): void; | ||
protected _handleHttpRequest(request: ServerRequest, response: ServerResponse): Promise<void>; | ||
@@ -50,5 +51,5 @@ protected _setupHandlerIfNeeded(): void; | ||
} | ||
export interface AppConfig { | ||
components: Array<Constructor<Component>>; | ||
sequences: Array<Constructor<Sequence>>; | ||
export interface ApplicationOptions { | ||
components?: Array<Constructor<Component>>; | ||
sequence?: Constructor<Sequence>; | ||
} |
@@ -13,7 +13,7 @@ "use strict"; | ||
class Application extends context_1.Context { | ||
constructor(appConfig) { | ||
constructor(options) { | ||
super(); | ||
this.appConfig = appConfig; | ||
if (appConfig && appConfig.components) { | ||
for (const component of appConfig.components) { | ||
this.options = options; | ||
if (options && options.components) { | ||
for (const component of options.components) { | ||
// TODO(superkhau): Need to figure a way around this hack, | ||
@@ -26,16 +26,13 @@ // `componentClassName.constructor.name` + `componentClassName.name` | ||
} | ||
if (appConfig && appConfig.sequences) { | ||
for (const sequence of appConfig.sequences) { | ||
// TODO(superkhau): Need to figure a way around this hack, | ||
// `componentClassName.constructor.name` + `componentClassName.name` | ||
// doesn't work | ||
const sequenceClassName = sequence.toString().split(' ')[1]; | ||
this.bind(`sequence.${sequenceClassName}`).toClass(sequence); | ||
} | ||
} | ||
this._bindSequence(); | ||
this.handleHttp = (req, res) => this._handleHttpRequest(req, res); | ||
this.bind('logError').to(this._logError.bind(this)); | ||
} | ||
_bindSequence() { | ||
// TODO(bajtos, ritch, superkhau) figure out how to integrate this single | ||
// sequence with custom sequences contributed by components | ||
this.bind('sequence').toClass(sequence_1.Sequence); | ||
const sequence = this.options && this.options.sequence ? | ||
this.options.sequence : | ||
sequence_1.Sequence; | ||
this.bind('sequence').toClass(sequence); | ||
} | ||
@@ -42,0 +39,0 @@ _handleHttpRequest(request, response) { |
@@ -8,3 +8,3 @@ /// <reference types="node" /> | ||
export declare class Application extends Context { | ||
appConfig: AppConfig; | ||
options: ApplicationOptions; | ||
/** | ||
@@ -29,3 +29,4 @@ * Handle incoming HTTP(S) request by invoking the corresponding | ||
protected _httpHandler: HttpHandler; | ||
constructor(appConfig?: AppConfig); | ||
constructor(options?: ApplicationOptions); | ||
protected _bindSequence(): void; | ||
protected _handleHttpRequest(request: ServerRequest, response: ServerResponse): Promise<void>; | ||
@@ -50,5 +51,5 @@ protected _setupHandlerIfNeeded(): void; | ||
} | ||
export interface AppConfig { | ||
components: Array<Constructor<Component>>; | ||
sequences: Array<Constructor<Sequence>>; | ||
export interface ApplicationOptions { | ||
components?: Array<Constructor<Component>>; | ||
sequence?: Constructor<Sequence>; | ||
} |
@@ -13,7 +13,7 @@ "use strict"; | ||
class Application extends context_1.Context { | ||
constructor(appConfig) { | ||
constructor(options) { | ||
super(); | ||
this.appConfig = appConfig; | ||
if (appConfig && appConfig.components) { | ||
for (const component of appConfig.components) { | ||
this.options = options; | ||
if (options && options.components) { | ||
for (const component of options.components) { | ||
// TODO(superkhau): Need to figure a way around this hack, | ||
@@ -26,16 +26,13 @@ // `componentClassName.constructor.name` + `componentClassName.name` | ||
} | ||
if (appConfig && appConfig.sequences) { | ||
for (const sequence of appConfig.sequences) { | ||
// TODO(superkhau): Need to figure a way around this hack, | ||
// `componentClassName.constructor.name` + `componentClassName.name` | ||
// doesn't work | ||
const sequenceClassName = sequence.toString().split(' ')[1]; | ||
this.bind(`sequence.${sequenceClassName}`).toClass(sequence); | ||
} | ||
} | ||
this._bindSequence(); | ||
this.handleHttp = (req, res) => this._handleHttpRequest(req, res); | ||
this.bind('logError').to(this._logError.bind(this)); | ||
} | ||
_bindSequence() { | ||
// TODO(bajtos, ritch, superkhau) figure out how to integrate this single | ||
// sequence with custom sequences contributed by components | ||
this.bind('sequence').toClass(sequence_1.Sequence); | ||
const sequence = this.options && this.options.sequence ? | ||
this.options.sequence : | ||
sequence_1.Sequence; | ||
this.bind('sequence').toClass(sequence); | ||
} | ||
@@ -42,0 +39,0 @@ _handleHttpRequest(request, response) { |
{ | ||
"name": "@loopback/core", | ||
"version": "4.0.0-alpha.7", | ||
"version": "4.0.0-alpha.8", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
10
184707
3507