๋๊ตฌ๋ Koa 2๋ฅผ ์ฌ์ฉํ๋ ๊ฐ๋จํ ์๊ฐ ์์ต๋๊น?
const n = next({ dev })
const handle = n.getRequestHandler()
n.prepare()
.then(() => {
const app = new Koa()
const router = new Router()
router.get('*', async ctx => {
await handle(ctx.req, ctx.res)
ctx.respond = false
})
app.use(async (ctx, next) => {
// Koa doesn't seems to set the default statusCode.
// So, this middleware does that
ctx.res.statusCode = 200
await next()
})
app.use(router.routes())
app.listen(3000)
})
@timneutkens Node๋ ์ด์ async/await๊ฐ ์๊ณ Koa 2.0.1์ 3์ผ ์ ์ ์ถ์๋์์ต๋๋ค ๐ ์ด ๋ฒ์ ์ ์ฌ์ฉํ๋๋ก ์์ ๋ฅผ ์ ๋ฐ์ดํธํ๋ ๊ฒ์ด ํฉ๋ฆฌ์ ์ผ ๊ฒ ๊ฐ์ต๋๋ค.
์, ์ ํฐ์ผ์ ์์ฑํ๊ฒ ์ต๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ