New API responses with good errors

This commit is contained in:
Jori Lallo
2016-09-17 14:53:30 -07:00
parent e631025887
commit fcc83dd2d6
11 changed files with 86 additions and 50 deletions

View File

@ -2,6 +2,7 @@ import bodyParser from 'koa-bodyparser';
import Koa from 'koa';
import Router from 'koa-router';
import Sequelize from 'sequelize';
import _ from 'lodash';
import auth from './auth';
import user from './user';
@ -41,7 +42,9 @@ api.use(async (ctx, next) => {
ctx.body = {
ok: false,
error: message,
error: _.snakeCase(err.id || err.message),
status: err.status,
message,
};
}
});