express-api-routes
Advanced tools
Comparing version 1.0.3 to 1.1.0
28
index.js
@@ -11,2 +11,3 @@ 'use strict'; | ||
const Routes = require('./lib/Routes'); | ||
const nodeWatch = require('node-watch'); | ||
@@ -29,2 +30,11 @@ | ||
// make routes! | ||
this.doWork() | ||
this.watchForFileChange() | ||
return this.config.app; | ||
} | ||
doWork() { | ||
// setup controllers | ||
@@ -48,4 +58,20 @@ new Controllers(this.config); | ||
} | ||
return this.config.app; | ||
watchForFileChange() { | ||
if (process.NODE_ENV === 'production') { return } | ||
const self = this; | ||
nodeWatch([ | ||
this.config.policiesDir, | ||
this.config.controllersDir, | ||
path.join(this.config.rootDir,'config','routes.js') | ||
], | ||
function(filename) { | ||
console.log('+++ ExpressApiRoutes - file has changed:'); | ||
console.log(` ${filename}`); | ||
console.log('+++ Reloading routes...'); | ||
self.doWork(); | ||
}); | ||
} | ||
@@ -52,0 +78,0 @@ |
{ | ||
"name": "express-api-routes", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "", | ||
@@ -13,3 +13,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"express": "^4.14.0" | ||
"express": "^4.14.0", | ||
"node-watch": "^0.4.0" | ||
}, | ||
@@ -16,0 +17,0 @@ "devDependencies": { |
12623
266
2
+ Addednode-watch@^0.4.0
+ Addednode-watch@0.4.1(transitive)