@foal/core
Advanced tools
Comparing version 2.6.0 to 2.7.0
@@ -140,5 +140,5 @@ "use strict"; | ||
this.readJSON('config/default.json'), | ||
this.readJS(`config/${process.env.NODE_ENV || 'development'}.js`), | ||
this.readYAML(`config/${process.env.NODE_ENV || 'development'}.yml`), | ||
this.readJSON(`config/${process.env.NODE_ENV || 'development'}.json`), | ||
this.readJS(`config/${env_1.Env.getEnvironmentName()}.js`), | ||
this.readYAML(`config/${env_1.Env.getEnvironmentName()}.yml`), | ||
this.readJSON(`config/${env_1.Env.getEnvironmentName()}.json`), | ||
].reduce((config1, config2) => this.mergeDeep(config1, config2)); | ||
@@ -145,0 +145,0 @@ } |
@@ -9,2 +9,3 @@ export declare class Env { | ||
static clearCache(): void; | ||
static getEnvironmentName(): string; | ||
static get(key: string): string | undefined; | ||
@@ -11,0 +12,0 @@ private static dotEnv; |
@@ -15,2 +15,5 @@ "use strict"; | ||
} | ||
static getEnvironmentName() { | ||
return process.env.FOAL_ENV || process.env.NODE_ENV || 'development'; | ||
} | ||
static get(key) { | ||
@@ -21,4 +24,4 @@ if (this.dotEnv === null) { | ||
this.loadEnv('.env.local'); | ||
this.loadEnv(`.env.${process.env.NODE_ENV || 'development'}`); | ||
this.loadEnv(`.env.${process.env.NODE_ENV || 'development'}.local`); | ||
this.loadEnv(`.env.${this.getEnvironmentName()}`); | ||
this.loadEnv(`.env.${this.getEnvironmentName()}.local`); | ||
} | ||
@@ -25,0 +28,0 @@ if (this.dotEnv[key] !== undefined) { |
@@ -18,2 +18,3 @@ import { Context } from './contexts'; | ||
sameSite?: 'strict' | 'lax' | 'none'; | ||
signed?: boolean; | ||
} | ||
@@ -29,4 +30,4 @@ /** | ||
*/ | ||
export declare abstract class HttpResponse { | ||
body?: any; | ||
export declare abstract class HttpResponse<T = any> { | ||
body?: T | undefined; | ||
/** | ||
@@ -69,3 +70,3 @@ * Property used internally by isHttpResponse. | ||
*/ | ||
constructor(body?: any, options?: { | ||
constructor(body?: T | undefined, options?: { | ||
stream?: boolean; | ||
@@ -158,3 +159,3 @@ }); | ||
*/ | ||
export declare abstract class HttpResponseSuccess extends HttpResponse { | ||
export declare abstract class HttpResponseSuccess<T = any> extends HttpResponse<T> { | ||
/** | ||
@@ -171,3 +172,3 @@ * Property used internally by isHttpResponseSuccess. | ||
*/ | ||
constructor(body?: any, options?: { | ||
constructor(body?: T, options?: { | ||
stream?: boolean; | ||
@@ -197,3 +198,3 @@ }); | ||
*/ | ||
export declare class HttpResponseOK extends HttpResponseSuccess { | ||
export declare class HttpResponseOK<T = any> extends HttpResponseSuccess<T> { | ||
/** | ||
@@ -212,3 +213,3 @@ * Property used internally by isHttpResponseOK. | ||
*/ | ||
constructor(body?: any, options?: { | ||
constructor(body?: T, options?: { | ||
stream?: boolean; | ||
@@ -238,3 +239,3 @@ }); | ||
*/ | ||
export declare class HttpResponseCreated extends HttpResponseSuccess { | ||
export declare class HttpResponseCreated<T = any> extends HttpResponseSuccess<T> { | ||
/** | ||
@@ -253,3 +254,3 @@ * Property used internally by isHttpResponseCreated. | ||
*/ | ||
constructor(body?: any, options?: { | ||
constructor(body?: T, options?: { | ||
stream?: boolean; | ||
@@ -316,3 +317,3 @@ }); | ||
*/ | ||
export declare abstract class HttpResponseRedirection extends HttpResponse { | ||
export declare abstract class HttpResponseRedirection<T = any> extends HttpResponse<T> { | ||
/** | ||
@@ -329,3 +330,3 @@ * Property used internally by isHttpResponseRedirection. | ||
*/ | ||
constructor(body?: any, options?: { | ||
constructor(body?: T, options?: { | ||
stream?: boolean; | ||
@@ -395,3 +396,3 @@ }); | ||
*/ | ||
export declare class HttpResponseRedirect extends HttpResponseRedirection { | ||
export declare class HttpResponseRedirect<T = any> extends HttpResponseRedirection<T> { | ||
path: string; | ||
@@ -412,3 +413,3 @@ /** | ||
*/ | ||
constructor(path: string, body?: any, options?: { | ||
constructor(path: string, body?: T, options?: { | ||
stream?: boolean; | ||
@@ -439,3 +440,3 @@ }); | ||
*/ | ||
export declare abstract class HttpResponseClientError extends HttpResponse { | ||
export declare abstract class HttpResponseClientError<T = any> extends HttpResponse<T> { | ||
/** | ||
@@ -452,3 +453,3 @@ * Property used internally by isHttpResponseClientError. | ||
*/ | ||
constructor(body?: any, options?: { | ||
constructor(body?: T, options?: { | ||
stream?: boolean; | ||
@@ -479,3 +480,3 @@ }); | ||
*/ | ||
export declare class HttpResponseBadRequest extends HttpResponseClientError { | ||
export declare class HttpResponseBadRequest<T = any> extends HttpResponseClientError<T> { | ||
/** | ||
@@ -494,3 +495,3 @@ * Property used internally by isHttpResponseBadRequest. | ||
*/ | ||
constructor(body?: any, options?: { | ||
constructor(body?: T, options?: { | ||
stream?: boolean; | ||
@@ -521,3 +522,3 @@ }); | ||
*/ | ||
export declare class HttpResponseUnauthorized extends HttpResponseClientError { | ||
export declare class HttpResponseUnauthorized<T = any> extends HttpResponseClientError<T> { | ||
/** | ||
@@ -536,3 +537,3 @@ * Property used internally by isHttpResponseUnauthorized. | ||
*/ | ||
constructor(body?: any, options?: { | ||
constructor(body?: T, options?: { | ||
stream?: boolean; | ||
@@ -563,3 +564,3 @@ }); | ||
*/ | ||
export declare class HttpResponseForbidden extends HttpResponseClientError { | ||
export declare class HttpResponseForbidden<T = any> extends HttpResponseClientError<T> { | ||
/** | ||
@@ -578,3 +579,3 @@ * Property used internally by isHttpResponseForbidden. | ||
*/ | ||
constructor(body?: any, options?: { | ||
constructor(body?: T, options?: { | ||
stream?: boolean; | ||
@@ -604,3 +605,3 @@ }); | ||
*/ | ||
export declare class HttpResponseNotFound extends HttpResponseClientError { | ||
export declare class HttpResponseNotFound<T = any> extends HttpResponseClientError<T> { | ||
/** | ||
@@ -619,3 +620,3 @@ * Property used internally by isHttpResponseNotFound. | ||
*/ | ||
constructor(body?: any, options?: { | ||
constructor(body?: T, options?: { | ||
stream?: boolean; | ||
@@ -645,3 +646,3 @@ }); | ||
*/ | ||
export declare class HttpResponseMethodNotAllowed extends HttpResponseClientError { | ||
export declare class HttpResponseMethodNotAllowed<T = any> extends HttpResponseClientError<T> { | ||
/** | ||
@@ -660,3 +661,3 @@ * Property used internally by isHttpResponseMethodNotAllowed. | ||
*/ | ||
constructor(body?: any, options?: { | ||
constructor(body?: T, options?: { | ||
stream?: boolean; | ||
@@ -687,3 +688,3 @@ }); | ||
*/ | ||
export declare class HttpResponseConflict extends HttpResponseClientError { | ||
export declare class HttpResponseConflict<T = any> extends HttpResponseClientError<T> { | ||
/** | ||
@@ -702,3 +703,3 @@ * Property used internally by isHttpResponseConflict. | ||
*/ | ||
constructor(body?: any, options?: { | ||
constructor(body?: T, options?: { | ||
stream?: boolean; | ||
@@ -728,3 +729,3 @@ }); | ||
*/ | ||
export declare class HttpResponseTooManyRequests extends HttpResponseClientError { | ||
export declare class HttpResponseTooManyRequests<T = any> extends HttpResponseClientError<T> { | ||
/** | ||
@@ -743,3 +744,3 @@ * Property used internally by isHttpResponseTooManyRequests. | ||
*/ | ||
constructor(body?: any, options?: { | ||
constructor(body?: T, options?: { | ||
stream?: boolean; | ||
@@ -771,3 +772,3 @@ }); | ||
*/ | ||
export declare abstract class HttpResponseServerError extends HttpResponse { | ||
export declare abstract class HttpResponseServerError<T = any> extends HttpResponse<T> { | ||
/** | ||
@@ -779,3 +780,3 @@ * Property used internally by isHttpResponseServerError. | ||
readonly isHttpResponseServerError = true; | ||
constructor(body?: any, options?: { | ||
constructor(body?: T, options?: { | ||
stream?: boolean; | ||
@@ -806,3 +807,3 @@ }); | ||
*/ | ||
export declare class HttpResponseInternalServerError extends HttpResponseServerError { | ||
export declare class HttpResponseInternalServerError<T = any> extends HttpResponseServerError<T> { | ||
/** | ||
@@ -823,3 +824,3 @@ * Property used internally by isHttpResponseInternalServerError. | ||
*/ | ||
constructor(body?: any, options?: { | ||
constructor(body?: T, options?: { | ||
stream?: boolean; | ||
@@ -852,3 +853,3 @@ error?: Error; | ||
*/ | ||
export declare class HttpResponseNotImplemented extends HttpResponseServerError { | ||
export declare class HttpResponseNotImplemented<T = any> extends HttpResponseServerError<T> { | ||
/** | ||
@@ -867,3 +868,3 @@ * Property used internally by isHttpResponseNotImplemented. | ||
*/ | ||
constructor(body?: any, options?: { | ||
constructor(body?: T, options?: { | ||
stream?: boolean; | ||
@@ -870,0 +871,0 @@ }); |
@@ -9,2 +9,3 @@ import { Class, IAppController, ServiceManager } from '../core'; | ||
preMiddlewares?: (Middleware | ErrorMiddleware)[]; | ||
afterPreMiddlewares?: (Middleware | ErrorMiddleware)[]; | ||
postMiddlewares?: (Middleware | ErrorMiddleware)[]; | ||
@@ -11,0 +12,0 @@ } |
@@ -70,3 +70,7 @@ "use strict"; | ||
// Parse cookies. | ||
app.use(cookieParser()); | ||
app.use(cookieParser(core_1.Config.get('settings.cookieParser.secret', 'string'))); | ||
// Add optional after pre-middlewares. | ||
for (const middleware of options.afterPreMiddlewares || []) { | ||
app.use(middleware); | ||
} | ||
// Create the service and controller manager. | ||
@@ -73,0 +77,0 @@ const services = options.serviceManager || new core_1.ServiceManager(); |
{ | ||
"name": "@foal/core", | ||
"version": "2.6.0", | ||
"version": "2.7.0", | ||
"description": "Elegant and complete Node.Js web framework based on TypeScript", | ||
@@ -82,3 +82,3 @@ "main": "./lib/index.js", | ||
"ajv": "~6.12.0", | ||
"cookie-parser": "~1.4.4", | ||
"cookie-parser": "~1.4.6", | ||
"express": "~4.17.1", | ||
@@ -89,3 +89,3 @@ "morgan": "~1.10.0", | ||
"devDependencies": { | ||
"@foal/internal-test": "^2.6.0", | ||
"@foal/internal-test": "^2.7.0", | ||
"@types/mocha": "7.0.2", | ||
@@ -105,3 +105,3 @@ "@types/node": "10.17.24", | ||
}, | ||
"gitHead": "250d8220d4f6045f1e9eafd1902624ae61b4779d" | ||
"gitHead": "f29806e349427d412606a2086ae474f2b65df3ac" | ||
} |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
370911
8771
11
Updatedcookie-parser@~1.4.6