const middleware = require('../utils/middleware')
const compose = require('composition')
const Router = require('koa-router')

// @TODO: Replace koa-router with an async function friendly router
export default function PostsController () {
  // Middleware
  const loadPost = middleware.load('Post', {
    key: 'name'
  })

  // Routes
  const routes = new Router({
    prefix: '/api'
  })
  .get(
    '/posts',
    compose([
      PostsController.index
    ])
  )
  .get(
    '/posts/:post',
    compose([
      loadPost,
      PostsController.show
    ])
  )

  return routes.middleware()
}

/**
 * GET /api/posts
 */
PostsController.index = async function index () {
  const {Post} = this.models
  this.body = await Post.findAll({
    order: [
      ['createdAt', 'DESC']
    ]
  })
}

/**
 * GET /api/posts/:post
 */
PostsController.show = async function show () {
  this.body = this.state.post
}

@@ -53,146 +53,39 @@
 nst 
-compose = require('composition')%0Aconst Router = require('koa-router')%0A%0A// @TODO: Replace koa-router with an async function friendly router
+Router = require('koa-router')%0A
 %0Aexp
@@ -297,30 +297,16 @@
 posts',%0A
-    compose(%5B%0A
       Po
@@ -325,23 +325,16 @@
 r.index%0A
-    %5D)%0A
   )%0A  .g
@@ -361,22 +361,8 @@
 t',%0A
-    compose(%5B%0A
     
@@ -404,15 +404,8 @@
 how%0A
-    %5D)%0A
   )%0A
@@ -486,22 +486,16 @@
 .index =
- async
  functio
@@ -495,16 +495,18 @@
 function
+ *
  index (
@@ -556,13 +556,13 @@
 y = 
-await
+yield
  Pos
@@ -686,14 +686,8 @@
 ow =
- async
  fun
@@ -691,16 +691,18 @@
 function
+ *
  show ()

Use generators instead of async functions in posts controller