You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following the error and code trying to use Koa.
For information it works when using Express
Error:
ERROR Uncaught Exception {"errorType":"TypeError","errorMessage":"koa_exports is not a constructor","stack":["TypeError: koa_exports is not a constructor"," at Object.<anonymous> (/var/task/server.js:17858:11)"," at Module._compile (node:internal/modules/cjs/loader:1358:14)"," at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)"," at Module.load (node:internal/modules/cjs/loader:1208:32)"," at Module._load (node:internal/modules/cjs/loader:1024:12)"," at Module.require (node:internal/modules/cjs/loader:1233:19)"," at require (node:internal/modules/helpers:179:18)"," at _tryRequireFile (file:///var/runtime/index.mjs:1002:37)"," at _tryRequire (file:///var/runtime/index.mjs:1052:25)"," at _loadUserApp (file:///var/runtime/index.mjs:1081:22)"]}
Code
import * as Koa from "koa"
import * as Router from "koa-router";
import serverless from "serverless-http"
const app = new Koa();
app.on('error', (err, ctx) => {
console.error('server error', err, ctx)
});
const router = new Router();
router
.get('/api/info', (ctx) => {
ctx.body = { application: 'sample-app', version: '1' };
})
app.use(router.routes())
.use(router.allowedMethods());
module.exports.handler = serverless(app);
The text was updated successfully, but these errors were encountered:
Following the error and code trying to use Koa.
For information it works when using Express
Error:
ERROR Uncaught Exception {"errorType":"TypeError","errorMessage":"koa_exports is not a constructor","stack":["TypeError: koa_exports is not a constructor"," at Object.<anonymous> (/var/task/server.js:17858:11)"," at Module._compile (node:internal/modules/cjs/loader:1358:14)"," at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)"," at Module.load (node:internal/modules/cjs/loader:1208:32)"," at Module._load (node:internal/modules/cjs/loader:1024:12)"," at Module.require (node:internal/modules/cjs/loader:1233:19)"," at require (node:internal/modules/helpers:179:18)"," at _tryRequireFile (file:///var/runtime/index.mjs:1002:37)"," at _tryRequire (file:///var/runtime/index.mjs:1052:25)"," at _loadUserApp (file:///var/runtime/index.mjs:1081:22)"]}
Code
The text was updated successfully, but these errors were encountered: