Skip to content

Instantly share code, notes, and snippets.

@josefaidt
Created August 2, 2022 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save josefaidt/e44fe05fe34543b9eb19f05cc22a5d1c to your computer and use it in GitHub Desktop.
Save josefaidt/e44fe05fe34543b9eb19f05cc22a5d1c to your computer and use it in GitHub Desktop.
const fn = new lambda.NodejsFunction(this, 'MyFunction', {
entry: fileURLToPath(new URL('./handler.ts', import.meta.url)),
functionName: `my-function`,
bundling: {
minify: true, // minify code, defaults to false
sourceMap: true, // include source map, defaults to false
sourceMapMode: lambda.SourceMapMode.INLINE, // defaults to SourceMapMode.DEFAULT
target: 'esnext',
define: {
'import.meta.vitest': 'undefined',
'process.env.NODE_ENV': JSON.stringify('production'),
},
tsconfig: fileURLToPath(new URL('./tsconfig.json', import.meta.url)),
format: lambda.OutputFormat.ESM,
},
runtime: Runtime.NODEJS_16_X,
})
import type { APIGatewayProxyHandlerV2 } from 'aws-lambda'
export const handler: APIGatewayProxyHandlerV2 = async (event) => {
console.log('EVENT:', JSON.stringify(event))
return {
statusCode: 200,
body: JSON.stringify({
message: 'Hello World',
}),
}
}
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Default",
"compilerOptions": {
"composite": false,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"isolatedModules": true,
"module": "esnext",
"moduleResolution": "node",
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
"skipLibCheck": true,
"strict": true,
"target": "esnext",
"sourceMap": false,
"inlineSourceMap": true
},
"exclude": ["node_modules"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment