NestJS example
See original GitHub issueWould it be possible to add sample code for NestJS into https://github.com/vendia/serverless-express/tree/mainline/examples? For example, how to do something like this with v4.0.0?
import { Server } from 'http'
import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
import { Context, APIGatewayEvent } from 'aws-lambda'
import * as ServerlessExpress from '@vendia/serverless-express'
import express from 'express'
import { ExpressAdapter } from '@nestjs/platform-express'
let lambdaProxy : Server
async function bootstrap() {
const expressServer = express()
const app = await NestFactory.create(AppModule, new ExpressAdapter(expressServer))
await app.init()
return ServerlessExpress.createServer(expressServer)
}
export const handler = (event : APIGatewayEvent, context : Context) => {
if (!lambdaProxy) {
bootstrap().then((server) => {
lambdaProxy = server
ServerlessExpress.proxy(lambdaProxy, event, context)
})
} else {
ServerlessExpress.proxy(lambdaProxy, event, context)
}
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:19 (7 by maintainers)
Top Results From Across the Web
First steps | NestJS - A progressive Node.js framework
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines ...
Read more >@nestjs/core examples - CodeSandbox
Learn how to use @nestjs/core by viewing and forking example apps that make use of @nestjs/core on CodeSandbox. ; Latest version9.2.1. License ;...
Read more >Getting started with continuous integration for Nest.js APIs
Learn how to build RESTful APIs with Nest.js, a Node.js framework ... Our tutorials are platform-agnostic, but use CircleCI as an example.
Read more >Example | Nestjs-query - Blog
Let's create a simple todo-item graphql example. ... npm i -g @nestjs/clinest new nestjs-query-getting-started. Copy. Install Dependencies#.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Great idea! My file is similar:
lambda.ts
bootstrap.ts
EDIT: I added a helper to an npm package I’m working on. Rough around the edges, but at least I have it written down somewhere 😄
Alright, I think I ended up figuring it out. I’ve updated my repo. If I’m off or missing something let me know!