Switched to ok
from success
on API responses
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
exports[`test should require authentication 1`] = `
|
||||
Object {
|
||||
"error": "Authentication required",
|
||||
"success": false
|
||||
"ok": false
|
||||
}
|
||||
`;
|
||||
|
||||
@ -13,6 +13,6 @@ Object {
|
||||
"name": "User 1",
|
||||
"username": "user1"
|
||||
},
|
||||
"success": true
|
||||
"ok": true
|
||||
}
|
||||
`;
|
||||
|
@ -1,5 +1,4 @@
|
||||
import bodyParser from 'koa-bodyparser';
|
||||
import httpErrors from 'http-errors';
|
||||
import Koa from 'koa';
|
||||
import Router from 'koa-router';
|
||||
import Sequelize from 'sequelize';
|
||||
@ -41,7 +40,7 @@ api.use(async (ctx, next) => {
|
||||
}
|
||||
|
||||
ctx.body = {
|
||||
success: false,
|
||||
ok: false,
|
||||
error: message,
|
||||
};
|
||||
}
|
||||
|
@ -2,11 +2,11 @@ export default function apiWrapper(_options) {
|
||||
return async function apiWrapperMiddleware(ctx, next) {
|
||||
await next();
|
||||
|
||||
const success = ctx.status < 400;
|
||||
const ok = ctx.status < 400;
|
||||
|
||||
ctx.body = {
|
||||
...ctx.body,
|
||||
success,
|
||||
ok,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import queryString from 'query-string';
|
||||
|
||||
export default function methodOverride(options) {
|
||||
export default function methodOverride(_options) {
|
||||
return async function methodOverrideMiddleware(ctx, next) {
|
||||
if (ctx.method === 'POST') {
|
||||
ctx.body = ctx.request.body;
|
||||
} else if (ctx.method === 'GET') {
|
||||
ctx.method= 'POST';
|
||||
ctx.method= 'POST'; // eslint-disable-line
|
||||
ctx.body = queryString.parse(ctx.querystring);
|
||||
}
|
||||
return next();
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user