Created
September 6, 2016 09:52
-
-
Save jeffijoe/ad0a4247e4925310f64d893bdca1d483 to your computer and use it in GitHub Desktop.
Snippet for my Medium article
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const router = new KoaRouter() | |
router.get('/todos', async (ctx) => { | |
const todosService = makeTodosService({ | |
todosRepository: new TodosRepository(), | |
// Our Koa request knows about the current user | |
currentUser: ctx.state.user | |
}) | |
ctx.body = await todosService.getTodos(ctx.request.query) | |
ctx.status = 200 | |
}) | |
router.post('/todos', async (ctx) => { | |
const todosService = makeTodosService({ | |
todosRepository: new TodosRepository(), | |
currentUser: ctx.state.user | |
}) | |
// ... | |
}) | |
// and so on... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Or you can just use currying (or bind()):