Comparing version 0.0.8 to 0.0.9
@@ -25,4 +25,5 @@ /** | ||
load(apiPath) { | ||
load(apiPath, controllerPath) { | ||
this.apiPath = apiPath; | ||
this.controllerPath = controllerPath || path.join(path.dirname(require.main.filename), './controllers'); | ||
this.raml = raml1Parser.loadApiSync(apiPath); | ||
@@ -62,3 +63,3 @@ this.apis = this.raml.toJSON(); | ||
}).filter((x) => x != null); | ||
routers.push(new Router(item.method, uri, schema, checkOuts, item.description)); | ||
routers.push(new Router(item.method, uri, schema, checkOuts, item.description, this.controllerPath)); | ||
}); | ||
@@ -65,0 +66,0 @@ return routers; |
@@ -12,3 +12,4 @@ /** | ||
constructor(method, uri, schema, checkOuts, description) { | ||
constructor(method, uri, schema, checkOuts, description, controllerPath) { | ||
this.controllerPath = controllerPath; | ||
this.path = `${method.toUpperCase()} ${uri}`; | ||
@@ -62,3 +63,3 @@ this.schema = schema; | ||
} | ||
this.cache.import(path.join(path.dirname(require.main.filename), 'controllers', this.controller.path)).then((controller) => { | ||
this.cache.import(path.join(this.controllerPath, this.controller.path)).then((controller) => { | ||
if (!(this.controller.method in controller)) { | ||
@@ -65,0 +66,0 @@ status.status = 404; |
{ | ||
"name": "cds-api", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "api with raml power by cds", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -10,2 +10,3 @@ /** | ||
const template = fs.readFileSync(path.join(__dirname, 'template', 'api.ejs')).toString(); | ||
// api.load(path.join(__dirname, './apis/api.raml'),path.join(__dirname,'./controllers')); | ||
api.load(path.join(__dirname, './apis/api.raml')); | ||
@@ -12,0 +13,0 @@ |
29572
393