Skip to content

Instantly share code, notes, and snippets.

@madorb
Last active February 21, 2018 17:36
Show Gist options
  • Save madorb/c71488f6b27ed86a9a43b3cde3761be3 to your computer and use it in GitHub Desktop.
Save madorb/c71488f6b27ed86a9a43b3cde3761be3 to your computer and use it in GitHub Desktop.
// @flow
import { Pageable, IndexablePage, paginate } from '@panderalabs/koa-pageable';
import type { Context } from 'koa';
import Koa from 'koa';
import Router from 'koa-router'
const app = new Koa();
const router = new Router();
app
.use(router.routes())
.use(router.allowedMethods());
router.get('/people', paginate, async (ctx: Context) => {
const pageable: Pageable = ctx.state.pageable;
const result: IndexablePage<number, Person> = service.getData(pageable);
ctx.body = result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment