Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aws-lambda-mock-context

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-lambda-mock-context - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

25

index.js

@@ -7,19 +7,28 @@ 'use strict';

var defer = require('pinkie-defer');
var objectAssign = require('object-assign');
var pkg = require('./package.json');
module.exports = function () {
module.exports = function (opts) {
var id = uuid.v1();
var stream = uuid.v4().replace(/-/g, '');
var account = uuid.v1().replace(/-/g, '').substr(0, 12);
opts = objectAssign({
region: 'us-west-1',
account: '123456789012',
functionName: pkg.name,
functionVersion: '$LATEST',
memoryLimitInMB: '128'
}, opts);
var deferred = defer();
return {
functionName: pkg.name,
functionVersion: '$LATEST',
invokedFunctionArn: format('arn:aws:lambda:us-west-1:%s:function:%s', account, pkg.name),
memoryLimitInMB: '128',
functionName: opts.functionName,
functionVersion: opts.functionVersion,
invokedFunctionArn: format('arn:aws:lambda:%s:%s:function:%s:%s', opts.region, opts.account, opts.functionName, opts.alias || opts.functionVersion),
memoryLimitInMB: opts.memoryLimitInMB,
awsRequestId: id,
logGroupName: format('/aws/lambda/%s', pkg.name),
logStreamName: format('%s/[$LATEST]/%s', moment().format('YYYY/MM/DD'), stream),
invokeid: id,
logGroupName: format('/aws/lambda/%s', opts.functionName),
logStreamName: format('%s/[%s]/%s', moment().format('YYYY/MM/DD'), opts.functionVersion, stream),
succeed: function (result) {

@@ -26,0 +35,0 @@ deferred.resolve(result);

{
"name": "aws-lambda-mock-context",
"version": "1.0.0",
"version": "1.1.0",
"description": "AWS Lambda mock context object",

@@ -17,3 +17,7 @@ "main": "index.js",

"context",
"mock"
"ctx",
"function",
"mocking",
"mock",
"promise"
],

@@ -32,2 +36,3 @@ "files": [

"node-uuid": "^1.4.3",
"object-assign": "^4.0.1",
"pinkie-defer": "^1.0.0",

@@ -39,8 +44,3 @@ "pinkie-promise": "^1.0.0"

"xo": "*"
},
"xo": {
"ignores": [
"test.js"
]
}
}

@@ -8,3 +8,3 @@ # aws-lambda-mock-context [![Build Status](https://travis-ci.org/SamVerschueren/aws-lambda-mock-context.svg?branch=master)](https://travis-ci.org/SamVerschueren/aws-lambda-mock-context)

```bash
```
npm install --save aws-lambda-mock-context

@@ -17,5 +17,5 @@ ```

```js
var context = require('aws-lambda-mock-context');
const context = require('aws-lambda-mock-context');
var ctx = context();
const ctx = context();

@@ -25,6 +25,6 @@ index.handler({hello: 'world'}, ctx);

ctx.Promise
.then(function () {
.then(() => {
//=> succeed() called
})
.catch(function (err) {
.catch(err => {
//=> fail() called

@@ -35,2 +35,50 @@ });

## API
### context(options)
#### options
##### region
Type: `string`
Default: `us-west-1`
The AWS region.
##### account
Type: `string`
Default: `123456789012`
The account number.
##### functionName
Type: `string`
Default: `aws-lambda-mock-context`
The name of the function.
##### functionVersion
Type: `string`
Default: `$LATEST`
The version of the function.
##### memoryLimitInMB
Type: `string`
Default: `128`
The memory limit.
##### alias
Type: `string`
The alias of the function.
## Related

@@ -37,0 +85,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc