How to handle a 404 in Koa 2?
<p>I have a <code>404.jade</code> file that I want to render whenever there is an invalid GET request.</p>

<p>Here is my current code:</p>

<p><strong>app.js</strong></p>

<pre><code>import Koa from 'koa'
import views from 'koa-views'
import serve from 'koa-static'
import rootRoutes from './routes/index'
import userRoutes from './routes/user'

const app = new Koa()

app.use(views(`${__dirname}/views`, { extension: 'jade' }))
app.use(serve(`${__dirname}/public`))
app.use(rootRoutes.routes())
app.use(userRoutes.routes())

app.listen(3000, () =&gt; {
  console.log('Server running at http://localhost:3000')
})

export default app
</code></pre>

<p><strong>routes/index.js</strong></p>

<pre><code>import Router from 'koa-router'
const router = new Router()

router.get('/', async ctx =&gt; {
  await ctx.render('index')
})

router.get('/about', async ctx =&gt; {
  await ctx.render('about')
})

export default router
</code></pre>

<p><strong>routes/user.js</strong></p>

<pre><code>import Router from 'koa-router'
const router = new Router({ prefix: '/user' })

router.get('/:name', async ctx =&gt; {
  const user = ctx.params.name
  await ctx.render('user', { user })
})

export default router
</code></pre>

<p>How can I handle any type of invalid GET request and somehow use <code>await ctx.render('404')</code> whenever it happens?</p>