-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable nest start script to be run as well as serverless offline
- Loading branch information
1 parent
28a0ffa
commit bf2b559
Showing
8 changed files
with
53 additions
and
25 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { NestFactory } from "@nestjs/core"; | ||
import { AppModule } from "./app.module"; | ||
import mainConfig from "./main.config"; | ||
import setupSwagger from "./setupSwagger"; | ||
|
||
export default async function getApp() { | ||
const app = await NestFactory.create(AppModule); | ||
mainConfig(app); | ||
setupSwagger(app); | ||
|
||
return app; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import serverlessExpress from "@vendia/serverless-express"; | ||
import { Callback, Context, Handler } from "aws-lambda"; | ||
import getApp from "./getApp"; | ||
|
||
let server: Handler; | ||
async function bootstrapServerLess(): Promise<Handler> { | ||
const app = await getApp(); | ||
await app.init(); | ||
|
||
const expressApp = app.getHttpAdapter().getInstance(); | ||
return serverlessExpress({ app: expressApp }); | ||
} | ||
|
||
export const handler: Handler = async (event: any, context: Context, callback: Callback) => { | ||
server = server ?? (await bootstrapServerLess()); | ||
return server(event, context, callback); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,10 @@ | ||
import { NestFactory } from "@nestjs/core"; | ||
import serverlessExpress from "@vendia/serverless-express"; | ||
import { Callback, Context, Handler } from "aws-lambda"; | ||
import { AppModule } from "./app.module"; | ||
import mainConfig from "./main.config"; | ||
import setupSwagger from "./setupSwagger"; | ||
import { API_PORT } from "./consts"; | ||
import getApp from "./getApp"; | ||
|
||
let server: Handler; | ||
|
||
async function bootstrap(): Promise<Handler> { | ||
const app = await NestFactory.create(AppModule); | ||
|
||
mainConfig(app); | ||
setupSwagger(app); | ||
await app.init(); | ||
|
||
const expressApp = app.getHttpAdapter().getInstance(); | ||
return serverlessExpress({ app: expressApp }); | ||
async function bootstrap() { | ||
const app = await getApp(); | ||
console.log(`Server is listening on port ${API_PORT}\n`); | ||
await app.listen(API_PORT); | ||
} | ||
|
||
export const handler: Handler = async (event: any, context: Context, callback: Callback) => { | ||
server = server ?? (await bootstrap()); | ||
return server(event, context, callback); | ||
}; | ||
bootstrap(); |
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
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