This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
outline/server/api/middlewares/apiWrapper.js
Tom Moor 92a18159b5 feat: Export collection as direct download instead of emailing (#1001)
* feat: Export collection as zip instead of emailing

* Flow typing download.js
2019-07-29 22:35:34 -07:00

27 lines
486 B
JavaScript

// @flow
import stream from 'stream';
import { type Context } from 'koa';
export default function apiWrapper() {
return async function apiWrapperMiddleware(
ctx: Context,
next: () => Promise<*>
) {
await next();
const ok = ctx.status < 400;
if (
typeof ctx.body !== 'string' &&
!(ctx.body instanceof stream.Readable)
) {
// $FlowFixMe
ctx.body = {
...ctx.body,
status: ctx.status,
ok,
};
}
};
}