Skip to content

Instantly share code, notes, and snippets.

@viktorfa
Last active August 29, 2021 19:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viktorfa/8186fa9becd42baf5e83868a93de9297 to your computer and use it in GitHub Desktop.
Save viktorfa/8186fa9becd42baf5e83868a93de9297 to your computer and use it in GitHub Desktop.
Entry point for Serverless Strapi with serverless-http
const startStrapi = require("strapi/lib/Strapi");
const serverless = require("serverless-http");
module.exports.handler = async (event, context) => {
if (!global.strapi) {
console.log("Cold starting Strapi");
await startStrapi({ dir: __dirname }).start();
}
const handler = serverless(global.strapi.app);
return handler(event, context);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment