Stormkit LogoStormkit Logo WhiteStormkit

Deploying Nest.js websites

Nest.js allows you to write scalable NodeJS applications. With Stormkit, you can easily host and manage your Nest.js applications.

To host your app simply go to your application's build config. Click on My application > My environment > Edit and specify the following fields in your build configuration:
FieldDescription
Build commandThe build command. For instance, npm run build. Stormkit expects to find a folder named dist after this command is executed. All files in this folder will be packed and deployed to the lambda function.
In order to prepare your application to work in a serverless environment, you will need to alter the default behaviour of Nest.js, which is listening to a port for the incoming requests. All we have to do is to remove the listen function and export the express app instead. Here is how:// main.ts import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; async function bootstrap() { const app = await NestFactory.create(AppModule); // The SK_APP_ID environment variable is declared in Stormkit environments. // The following block listens to the given PORT in local environments. if (process.env.SK_APP_ID) { return app.listen(process.env.PORT); } await app.init(); return app.getHttpAdapter().getInstance(); } export default bootstrap()

Limitations

Since Stormkit runs on a serverless environment, you should try to build your NodeJS backend application as stateless as possible. Long-lived processes like websockets are not supported by Stormkit.

Also, anything that is specified as a production dependency is bundled in the deployment package. The maximum size for the zipped package is 50MB and unzipped is 250MB.