* First pass: Unfurling of Slack links * Add authentication in db * Call associate on Event correctly * Add SLACK_APP_ID, remove SLACK_REDIRECT_URI, tidy env sample * PR feedback * Comment clarify
23 lines
400 B
JavaScript
23 lines
400 B
JavaScript
// @flow
|
|
import { type Context } from 'koa';
|
|
|
|
export default function apiWrapper() {
|
|
return async function apiWrapperMiddleware(
|
|
ctx: Context,
|
|
next: () => Promise<void>
|
|
) {
|
|
await next();
|
|
|
|
const ok = ctx.status < 400;
|
|
|
|
if (typeof ctx.body !== 'string') {
|
|
// $FlowFixMe
|
|
ctx.body = {
|
|
...ctx.body,
|
|
status: ctx.status,
|
|
ok,
|
|
};
|
|
}
|
|
};
|
|
}
|