Use new operator to create a Koa v2 app

Without it one would get: `TypeError: Class constructors cannot be invoked without 'new'`.
This commit is contained in:
Julien Fontanet 2016-01-23 14:31:05 +01:00
parent 09f5080aa0
commit b3b00d9ebe

View file

@ -25,6 +25,9 @@ $ npm install koa
Koa v2 is currently in alpha. In this new version, the middleware function signature completely changes in favor of ES2015-2016 syntax: Koa v2 is currently in alpha. In this new version, the middleware function signature completely changes in favor of ES2015-2016 syntax:
```js ```js
// Koa application is now a class and requires the new operator.
const app = new Koa()
// uses async arrow functions // uses async arrow functions
app.use(async (ctx, next) => { app.use(async (ctx, next) => {
try { try {