New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lambda-node-runtime

Package Overview
Dependencies
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lambda-node-runtime - npm Package Compare versions

Comparing version

to
0.0.20

2

package.json
{
"name": "lambda-node-runtime",
"version": "0.0.19",
"version": "0.0.20",
"description": "Run any Node version on AWS Lambda",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -16,4 +16,5 @@ # Lambda Node Runtime

### Usage
Write a module that holds AWS Lambda handler:
Write a module that holds AWS Lambda handler (i.e.: `index.js`):
```js
// index.js
module.exports.handler = async (event, context) => {

@@ -25,2 +26,3 @@ // Your code

```js
// index.js
module.exports.handler = (event, context, callback) => {

@@ -30,11 +32,11 @@ // Your code

```
Reference your handler using AWS Lambda Environment Variable
Reference your handler using AWS Lambda Environment Variable (i.e.: `index.js`):
```
LAMBDA_NODE_HANDLER=index.handler
```
Choose `Node.js 6.10` AWS Lambda Runtime, increase Timeout to at least 4 seconds (see [Benchmarks](#benchmarks) section for more details) and set AWS Lambda Handler to expression
Choose `Node.js 6.10` AWS Lambda Runtime, increase Timeout to at least 4 seconds (see [Benchmarks](#benchmarks) section for more details) and set AWS Lambda Handler to expression:
```
node_modules/lambda-node-runtime/index.handler
```
Optionally set desired Node.js version in `package.json` (default is latest LTS version 8.x (Carbon))
Optionally set desired Node.js version in `package.json` (default is latest LTS version 8.x (Carbon)):
```json

@@ -50,2 +52,16 @@ {

### Serverless support
Example `serverless.yml` configuration:
```yml
functions:
yourLambdaFunction:
handler: node_modules/lambda-node-runtime/index.handler
runtime: nodejs6.10
timeout: 4 # Cold start might take up to 4 seconds.
environment:
LAMBDA_NODE_HANDLER: index.handler # when handler method `handler` is in `index.js` module
```
Please note that when running `serverless invoke local` command, development Node.js version is used (not the one downloaded by the module).
## How it works

@@ -52,0 +68,0 @@ When you install `lambda-node-runtime` module it downloads Node to `node_modules/lambda-node-runtime/.node` dir. Therefore, when you create an AWS Lambda Function package it includes desired Node runtime. When AWS Lambda Function package is deployed and invoked, bundled Node child process starts and executes your JS code.

@@ -1,2 +0,2 @@

const { spawn } = require('child_process');
const { spawn, fork } = require('child_process');

@@ -58,7 +58,13 @@ const errors = require('./errors');

nodeChildProcess = handleNodeChildProcess(
spawn(
`${__dirname}/../.node/bin/node`,
[`${__dirname}/lambdaFunctionInvoker`],
{ stdio: [process.stdin, process.stdout, process.stderr, 'ipc'] }
),
process.env.IS_LOCAL
? fork(
`${__dirname}/lambdaFunctionInvoker`,
[],
{ stdio: [process.stdin, process.stdout, process.stderr, 'ipc'] }
)
: spawn(
`${__dirname}/../.node/bin/node`,
[`${__dirname}/lambdaFunctionInvoker`],
{ stdio: [process.stdin, process.stdout, process.stderr, 'ipc'] }
),
event,

@@ -65,0 +71,0 @@ context,