Last active
August 29, 2021 19:32
-
-
Save viktorfa/8186fa9becd42baf5e83868a93de9297 to your computer and use it in GitHub Desktop.
Entry point for Serverless Strapi with serverless-http
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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