dougmoscrop / serverless-http

Use your existing middleware framework (e.g. Express, Koa) in AWS Lambda 🎉
Other
1.71k stars 164 forks source link

missing ESM setup/doc/support #231

Open kimyu92 opened 2 years ago

kimyu92 commented 2 years ago

Since amazon supports esm in its runtime, the setup below doesn't seem to work and I couldn't find any documentation around it except writtin in commonjs

Error: app.lambdaHandler is undefined or not exported","stack":["Runtime.HandlerNotFound: app.lambdaHandler is undefined or not exported

Snippet

import serverless from 'serverless-http';
import express from 'express';

const app = express();

app.use(/* register your middleware as normal */);

const serverLessHandler = serverless(app, {
  basePath: '/rest',
});

export async function handler(event, context) {
  const res = await serverLessHandler(event, context);

  return res;
}

Any insight would be greatly appreciated.