Comparing version 0.0.2 to 0.0.3
@@ -0,1 +1,12 @@ | ||
<a name="0.0.3"></a> | ||
## [0.0.3](https://github.com/dylanfoster/parch/compare/0.0.2...v0.0.3) (2016-06-16) | ||
### Features | ||
* **application:** pass through server options to restify ([daf427c](https://github.com/dylanfoster/parch/commit/daf427c)) | ||
* **loader:** ensure modules are always singularized ([ba1cb51](https://github.com/dylanfoster/parch/commit/ba1cb51)) | ||
<a name="0.0.2"></a> | ||
@@ -2,0 +13,0 @@ ## [0.0.2](https://github.com/dylanfoster/parch/compare/0.0.1...v0.0.2) (2016-06-15) |
@@ -25,14 +25,33 @@ "use strict"; | ||
/** | ||
* TODO: | ||
* - add DEFAULT_CONTROLLER_LOOKUP_PATH | ||
* - should be <caller location>/contrllers | ||
*/ | ||
var Application = function () { | ||
function Application(options) { | ||
function Application() { | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
_classCallCheck(this, Application); | ||
var app = options.app || _restify2.default.createServer(); | ||
var serverOptions = options.server || {}; | ||
// TODO: merge with defaults | ||
var middlewares = serverOptions.middlewares || []; | ||
var app = options.app || _restify2.default.createServer(serverOptions); | ||
var controllerLoader = new _loader2.default({ | ||
type: "controller", | ||
path: options.controllers.dir // || DEFAULT_CONTROLLER_LOOKUP_PATH | ||
}); | ||
var routerSettings = { | ||
app: app, | ||
loader: { | ||
controllers: new _loader2.default({ type: "controller", path: options.controllers.dir }) | ||
controllers: controllerLoader | ||
} | ||
}; | ||
middlewares.forEach(function (middlware) { | ||
app.use(middlware); | ||
}); | ||
this.app = app; | ||
@@ -39,0 +58,0 @@ this.map = _router2.default.map.bind(null, routerSettings); |
@@ -13,2 +13,6 @@ "use strict"; | ||
var _inflect = require("inflect"); | ||
var _inflect2 = _interopRequireDefault(_inflect); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -36,5 +40,4 @@ | ||
value: function _loadModules() { | ||
var typeRegexString = "(.+)" + this.type + "\\" + ".js$"; | ||
var typeRegexString = "(.+)" + this.type + "\\.js$"; | ||
var typeRegex = new RegExp(typeRegexString, "i"); | ||
var modules = (0, _includeAll2.default)({ | ||
@@ -46,5 +49,4 @@ dirname: this.loadPath, | ||
Object.keys(modules).forEach(function (module) { | ||
var key = module.toLowerCase().replace("_", "").replace("-", ""); | ||
var key = _inflect2.default.singularize(module.toLowerCase().replace("_", "").replace("-", "")); | ||
// HACK: cuz node es modules suck | ||
if (modules[module].hasOwnProperty("default")) { | ||
@@ -51,0 +53,0 @@ modules[key] = modules[module].default; |
@@ -35,2 +35,3 @@ "use strict"; | ||
value: function resource(name) { | ||
name = _inflect2.default.singularize(name); | ||
var Controller = this.loader.controllers.get(name); | ||
@@ -37,0 +38,0 @@ var controller = new Controller(); |
{ | ||
"name": "parch", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Restify + Sequelize", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
24193
217