Package Exports
- @stormkit/serverless
- @stormkit/serverless/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@stormkit/serverless) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Stormkit Serverless
Export node.js applications into serverless compatible functions
Why?
Stormkit servesless provides handy wrappers to make your code work in serverless environments.
This makes your function much more portable. The wrapper will take the incoming event and transform
it into a Node.js http.IncomingMessage object.
For whom is this package targeted for?
This repository is intended for users who care about portability. If you know you'll be using AWS Lambda and you don't need to make your code portable, then this package may be overengineering for your needs. If, however, you'd like to deploy your application to multiple providers, then this package can be helpful.
Example usage
import http from "http";
import serverless from "@stormkit/serverless";
export const handler = serverless(
async (req: http.IncomingMessage, res: http.ServerResponse) => {
res.write("Hello from " + req.url);
res.end();
}
);By default the above example will use a Stormkit handler. To change this behaviour you can tell
the serverless function which handler to use.
export const handler = serverless(
async (req: http.IncomingMessage, res: http.ServerResponse) => {
res.write("Hello from " + req.url);
res.end();
},
"awsAlb"
);In order to avoid setting the handler type all the time, you can also use the process.env.SERVERLESS_HANDLER
environment variable to set a different default type. Allowed types are:
awsAlbstormkit
If you need a different handler, feel free to open a issue 🙏🏻
Currently supported signatures
Each provider has it's own signature to call a serverless function. Here's the list of the currently supported providers:
License
Made with 💛 Published under MIT.