Helper to build koa-router apis easily
- node 14 or higher
- koa-router
- koa
import ApiBuilder from "koa-api-builder";
const group = new ApiBuilder().path((group) => {
group.post('/login', loginRequest)
.post('/signup', signupRequest)
.path('/user/:userId/accounts', ifAuthenticated, (group) => {
group.get(listAccountsRequest)
.post(ifAllowed, insertAccountRequest)
.path('/:accountId', (group) => {
group.get(findAccountRequest);
group.put(updateAccountRequest);
group.del(ifAllowed, delAccountRequest);
group.get('/transactions', listTransactionsRequest);
});
});
});
// then we build our api definition into a regular koa-router
const router = group.build();
See router section on koa wiki
This api builder is heavily copied from Javalin's group handler
- Initial implementation
- Test and coverage
- Publish npm package
- Add linting tool
- Publish every new tag
- Publish coverage results
-
Add specialrender
pseudo-verb for template engines - Add Server Sent Events configuration support
- Add WebSockets configuration support
See the changelog for more details