Feature: First version of the REST API done

This commit is contained in:
2015-08-14 08:04:31 +00:00
commit e6fc0be0ed
28 changed files with 3170 additions and 0 deletions

18
app/helpers/handler.js Normal file
View File

@@ -0,0 +1,18 @@
module.exports = {
errorHandler : function(errors, status, response) {
var message = []
if( errors.errors) {
Object.keys(errors.errors).forEach(function (field) {
var error = errors.errors[field];
message.push({
field: error.path,
rule: error.kind,
message: error.message
});
});
return response.status(status).json(message);
} else {
return response.status(status).end();
}
}
}