Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export function instead of its returned value #63

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/middleware.js
@@ -1,7 +1,7 @@
"use strict";
module.exports = function(options){

var errors = require("nodeerrors");
var errors = require("nodeerrors")();
return errorHandler;

function errorHandler(err, req, res, next){
Expand Down
7 changes: 5 additions & 2 deletions lib/nodeerrors.js
@@ -1,4 +1,6 @@
"use strict";
var parentModule = require('parent-module');
var path = require('path');
var getErrorConfig = require("./util/getErrorConfig");
var makeErrorFunction = require("./util/makeErrorFunction");
var moduleConfig = require("moduleconfig");
Expand Down Expand Up @@ -29,8 +31,9 @@ function getNodeErrors() {
};
}

var startDir = path.dirname(parentModule());

return moduleConfig([".errors.js", "config/.errors.js"], function(errorConfigFilePath){
return moduleConfig(startDir, [".errors.js", "config/.errors.js"], function(errorConfigFilePath) {
//Not in cache, create nodeErrors object
var nodeError = {
errorCodes:{},
Expand All @@ -52,4 +55,4 @@ function getNodeErrors() {

}

module.exports = getNodeErrors();
module.exports = getNodeErrors;