[build-utils] Add NodejsLambda class (#7423)

When an instance of this class is returned in a Builder's `output`, it is a signal to the build system that it needs to add additional files to the final Lambda before creating the zip file.
This commit is contained in:
Nathan Rajlich
2022-02-15 14:17:12 -08:00
committed by GitHub
parent 983946650e
commit ce8e6e3806
6 changed files with 87 additions and 35 deletions

View File

@@ -0,0 +1,21 @@
import { NodejsLambda, FileBlob } from '../src';
describe('Test `NodejsLambda`', () => {
it('should create an instance', () => {
const helloSrc = 'module.exports = (req, res) => res.end("hi");';
const lambda = new NodejsLambda({
files: {
'api/hello.js': new FileBlob({ data: helloSrc }),
},
handler: 'api/hello.js',
runtime: 'node14.x',
shouldAddHelpers: true,
shouldAddSourcemapSupport: false,
});
expect(lambda.handler).toEqual('api/hello.js');
expect(lambda.runtime).toEqual('node14.x');
expect(lambda.shouldAddHelpers).toEqual(true);
expect(lambda.shouldAddSourcemapSupport).toEqual(false);
expect(lambda.awsLambdaHandler).toBeUndefined();
});
});