CodeGenieApp / serverless-express

Run Express and other Node.js frameworks on AWS Serverless technologies such as Lambda, API Gateway, Lambda@Edge, and more.
https://codegenie.codes
Apache License 2.0
5.13k stars 668 forks source link

Type error with Koa #487

Open jimmone opened 2 years ago

jimmone commented 2 years ago

I get the following TypeScript error when building using Koa version 2.13.4 and @vendia/serverless-express version 4.5.2:

server/index.ts(10,51): error TS2322: Type 'import("/path/to/project/node_modules/@types/koa/index.d.ts")<DefaultState, DefaultContext>' is not assignable to type 'RequestListener'.
--
80 | Type 'import("/path/to/project/node_modules/@types/koa/index.d.ts")<DefaultState, DefaultContext>' provides no match for the signature '(req: IncomingMessage, res: ServerResponse): void'.
shellscape commented 2 years ago

Confirmed. Seeing this as well. @brettstack can we get eyeballs on this one - looks like it's been around the better part of a year.

shellscape commented 2 years ago

Or perhaps the alter-ego @brett-vendia is the right one to tag

saveman71 commented 1 year ago

What worked for me is calling app.callback() https://koajs.com/#app-callback- which returns a function suitable for using with mounting express-like servers.

serverlessExpress({ app: app.callback() });

The examples could probably benefit from an update.