chore: Upgrade Flow to v0.104.0
This commit is contained in:
@@ -17,6 +17,7 @@ export default function apiWrapper() {
|
||||
) {
|
||||
// $FlowFixMe
|
||||
ctx.body = {
|
||||
// $FlowFixMe
|
||||
...ctx.body,
|
||||
status: ctx.status,
|
||||
ok,
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
// @flow
|
||||
import debug from "debug";
|
||||
import { type Context } from "koa";
|
||||
|
||||
const log = debug("cache");
|
||||
|
||||
export default function cache() {
|
||||
return async function cacheMiddleware(ctx: Context, next: () => Promise<*>) {
|
||||
ctx.cache = {};
|
||||
|
||||
ctx.cache.set = async (id, value) => {
|
||||
ctx.cache[id] = value;
|
||||
};
|
||||
|
||||
ctx.cache.get = async (id, def) => {
|
||||
if (ctx.cache[id]) {
|
||||
log(`hit: ${id}`);
|
||||
} else {
|
||||
log(`miss: ${id}`);
|
||||
ctx.cache.set(id, await def());
|
||||
}
|
||||
return ctx.cache[id];
|
||||
};
|
||||
return next();
|
||||
};
|
||||
}
|
||||
@@ -16,9 +16,8 @@ export default function pagination(options?: Object) {
|
||||
};
|
||||
|
||||
let query = ctx.request.query;
|
||||
|
||||
// $FlowFixMe
|
||||
let body = ctx.request.body;
|
||||
|
||||
// $FlowFixMe
|
||||
let limit = query.limit || body.limit;
|
||||
// $FlowFixMe
|
||||
@@ -48,15 +47,20 @@ export default function pagination(options?: Object) {
|
||||
);
|
||||
}
|
||||
|
||||
/* $FlowFixMeNowPlease This comment suppresses an error found when upgrading
|
||||
* flow-bin@0.104.0. To view the error, delete this comment and run Flow. */
|
||||
ctx.state.pagination = {
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
limit,
|
||||
offset,
|
||||
};
|
||||
|
||||
// $FlowFixMe
|
||||
query.limit = ctx.state.pagination.limit;
|
||||
// $FlowFixMe
|
||||
query.offset = ctx.state.pagination.offset + query.limit;
|
||||
|
||||
/* $FlowFixMeNowPlease This comment suppresses an error found when upgrading
|
||||
* flow-bin@0.104.0. To view the error, delete this comment and run Flow. */
|
||||
ctx.state.pagination.nextPath = `/api${
|
||||
ctx.request.path
|
||||
}?${querystring.stringify(query)}`;
|
||||
|
||||
Reference in New Issue
Block a user