Comparing version 0.0.1-31 to 0.0.1-32
@@ -10,2 +10,3 @@ /// <reference types="node" /> | ||
export declare const ValidationTypesAccepted: string[]; | ||
export declare type InterceptorFactory = (opt: KambojaOption) => string | string[] | RequestInterceptor | RequestInterceptor[]; | ||
export declare class Decorator { | ||
@@ -12,0 +13,0 @@ internal(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void; |
@@ -9,4 +9,6 @@ import * as Core from "./core"; | ||
private storage; | ||
private interceptorFactories; | ||
constructor(engine: Core.Engine, override?: Core.KambojaOption); | ||
intercept(factory: (opt: Core.KambojaOption) => string | string[] | Core.RequestInterceptor | Core.RequestInterceptor[]): void; | ||
intercept(factory: Core.InterceptorFactory): this; | ||
private registerInterceptors(); | ||
private isFolderProvided(); | ||
@@ -13,0 +15,0 @@ private generateRoutes(controllerMeta); |
@@ -12,2 +12,3 @@ "use strict"; | ||
this.engine = engine; | ||
this.interceptorFactories = []; | ||
var options = Lodash.assign({ | ||
@@ -37,11 +38,18 @@ skipAnalysis: false, | ||
Kamboja.prototype.intercept = function (factory) { | ||
var interceptors = factory(this.options); | ||
if (!this.options.interceptors) | ||
this.options.interceptors = []; | ||
if (Array.isArray(interceptors)) | ||
(_a = this.options.interceptors).push.apply(_a, interceptors); | ||
else | ||
this.options.interceptors.push(interceptors); | ||
var _a; | ||
this.interceptorFactories.push(factory); | ||
return this; | ||
}; | ||
Kamboja.prototype.registerInterceptors = function () { | ||
var _this = this; | ||
this.interceptorFactories.forEach(function (x) { | ||
var result = x(_this.options); | ||
if (!_this.options.interceptors) | ||
_this.options.interceptors = []; | ||
if (Array.isArray(result)) | ||
(_a = _this.options.interceptors).push.apply(_a, result); | ||
else | ||
_this.options.interceptors.push(result); | ||
var _a; | ||
}); | ||
}; | ||
Kamboja.prototype.isFolderProvided = function () { | ||
@@ -113,3 +121,5 @@ var _this = this; | ||
throw new Error("Fatal Error"); | ||
return this.engine.init(routeInfos, this.options); | ||
var app = this.engine.init(routeInfos, this.options); | ||
this.registerInterceptors(); | ||
return app; | ||
}; | ||
@@ -116,0 +126,0 @@ return Kamboja; |
{ | ||
"name": "kamboja", | ||
"version": "0.0.1-31", | ||
"version": "0.0.1-32", | ||
"description": "MVC Framework powered by TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "lib/source/index.js", |
154224
3535