Added better API errors and stuff
This commit is contained in:
12
server/api/middlewares/apiWrapper.js
Normal file
12
server/api/middlewares/apiWrapper.js
Normal file
@ -0,0 +1,12 @@
|
||||
export default function apiWrapper(_options) {
|
||||
return async function apiWrapperMiddleware(ctx, next) {
|
||||
await next();
|
||||
|
||||
const success = ctx.status < 400;
|
||||
|
||||
ctx.body = {
|
||||
...ctx.body,
|
||||
success,
|
||||
};
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user