Comparing version 0.1.1-0 to 0.1.1
{ | ||
"name": "kamboja", | ||
"version": "0.1.1-0", | ||
"version": "0.1.1", | ||
"description": "MVC Framework powered by TypeScript", | ||
@@ -32,3 +32,3 @@ "main": "src/index.js", | ||
"chalk": "^1.1.3", | ||
"kamboja-core": "^0.1.1-0", | ||
"kamboja-core": "^0.1.1", | ||
"kecubung": "^0.1.1-0", | ||
@@ -54,3 +54,3 @@ "lodash": "^4.17.4", | ||
"gulp-typescript": "^3.1.6", | ||
"kamboja-testing": "^0.1.1-0", | ||
"kamboja-testing": "^0.1.1", | ||
"mocha": "^3.4.1", | ||
@@ -57,0 +57,0 @@ "run-sequence": "^1.2.2", |
@@ -13,3 +13,3 @@ import * as Core from "kamboja-core" | ||
try { | ||
return this.facade.dependencyResolver.resolve(this.routeInfo.classId) | ||
return this.facade.dependencyResolver.resolve<Core.BaseController>(this.routeInfo.classId) | ||
} | ||
@@ -33,3 +33,3 @@ catch (e) { | ||
try { | ||
let validator = this.facade.dependencyResolver.resolve(x) | ||
let validator = this.facade.dependencyResolver.resolve<Core.ValidatorCommand>(x) | ||
commands.push(validator) | ||
@@ -36,0 +36,0 @@ } |
@@ -30,3 +30,3 @@ import * as Core from "kamboja-core" | ||
try { | ||
let instance = this.facade.dependencyResolver.resolve(middleware) | ||
let instance = this.facade.dependencyResolver.resolve<Core.Middleware>(middleware) | ||
result.push(instance) | ||
@@ -52,3 +52,3 @@ } | ||
try { | ||
let instance = this.facade.dependencyResolver.resolve(middleware) | ||
let instance = this.facade.dependencyResolver.resolve<Core.Middleware>(middleware) | ||
result.push(instance) | ||
@@ -74,3 +74,3 @@ } | ||
try { | ||
let instance = this.facade.dependencyResolver.resolve(middleware) | ||
let instance = this.facade.dependencyResolver.resolve<Core.Middleware>(middleware) | ||
result.push(instance) | ||
@@ -77,0 +77,0 @@ } |
@@ -36,2 +36,5 @@ "use strict"; | ||
showLog: "Info", | ||
validators: [], | ||
middlewares: [], | ||
facilities: [], | ||
identifierResolver: idResolver, | ||
@@ -50,2 +53,8 @@ pathResolver: pathResolver, | ||
}; | ||
Kamboja.prototype.set = function (key, value) { | ||
this.options[key] = value; | ||
}; | ||
Kamboja.prototype.get = function (key) { | ||
return this.options[key]; | ||
}; | ||
/** | ||
@@ -57,4 +66,2 @@ * Add middleware | ||
Kamboja.prototype.use = function (middleware) { | ||
if (!this.options.middlewares) | ||
this.options.middlewares = []; | ||
if (Array.isArray(middleware)) | ||
@@ -66,2 +73,19 @@ this.options.middlewares = this.options.middlewares.concat(middleware); | ||
}; | ||
Kamboja.prototype.apply = function (facility) { | ||
if (typeof facility == "string") { | ||
try { | ||
var fac = this.options.dependencyResolver.resolve(facility); | ||
this.options.facilities.push(fac); | ||
fac.apply(this); | ||
} | ||
catch (e) { | ||
throw new Error("Unable to instantiate " + facility + " as Facility"); | ||
} | ||
} | ||
else { | ||
this.options.facilities.push(facility); | ||
facility.apply(this); | ||
} | ||
return this; | ||
}; | ||
Kamboja.prototype.isFolderProvided = function () { | ||
@@ -68,0 +92,0 @@ var _this = this; |
@@ -12,2 +12,3 @@ import * as Core from "kamboja-core" | ||
import * as Kecubung from "kecubung" | ||
import { Validator } from "./index" | ||
@@ -18,3 +19,3 @@ | ||
*/ | ||
export class Kamboja { | ||
export class Kamboja implements Core.Application { | ||
private static defaultModelPath: string = "model" | ||
@@ -50,3 +51,6 @@ private static facade: Core.Facade; | ||
showLog: "Info", | ||
identifierResolver:idResolver, | ||
validators: [], | ||
middlewares: [], | ||
facilities: [], | ||
identifierResolver: idResolver, | ||
pathResolver: pathResolver, | ||
@@ -62,2 +66,10 @@ dependencyResolver: resolver, | ||
set(key: keyof Core.KambojaOption, value: any) { | ||
this.options[key] = value; | ||
} | ||
get(key: keyof Core.KambojaOption) { | ||
return <any>this.options[key]; | ||
} | ||
/** | ||
@@ -69,4 +81,3 @@ * Add middleware | ||
use(middleware: Core.MiddlewaresType) { | ||
if (!this.options.middlewares) this.options.middlewares = [] | ||
if (Array.isArray(middleware)) | ||
if (Array.isArray(middleware)) | ||
this.options.middlewares = this.options.middlewares.concat(middleware) | ||
@@ -77,2 +88,20 @@ else this.options.middlewares.push(middleware) | ||
apply(facility: string | Core.Facility) { | ||
if (typeof facility == "string") { | ||
try { | ||
let fac = this.options.dependencyResolver.resolve<Core.Facility>(facility) | ||
this.options.facilities.push(fac) | ||
fac.apply(this) | ||
} | ||
catch (e) { | ||
throw new Error(`Unable to instantiate ${facility} as Facility`) | ||
} | ||
} | ||
else { | ||
this.options.facilities.push(facility) | ||
facility.apply(this) | ||
} | ||
return this | ||
} | ||
private isFolderProvided() { | ||
@@ -79,0 +108,0 @@ let result = true; |
334273
7657
Updatedkamboja-core@^0.1.1