Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GET-4089] Upgrade packages to fix github dependabot vulns #36

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: 2.1
orbs:
node: circleci/[email protected]
jobs:
test:
executor:
name: node/default
steps:
- checkout
- node/install-packages
- run:
name: "Lint"
command: npm run-script lint
- run:
name: "Test"
command: npm test
deploy:
executor:
name: node/default
steps:
- checkout
- node/install-packages
- run:
name: Build
command: npm run-script build
- run:
name: "Setup npm auth"
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- run:
name: Publish
command: npm publish
workflows:
test-and-deploy:
jobs:
- test
- deploy:
context: NPMJS ReadWrite
requires:
- test
filters:
branches:
only: main
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

126 changes: 75 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Event Mocks
# mock-aws-events

## Context
This library is a fork of the (currently unmaintained) [@serverless/event-mocks](https://github.com/serverless/event-mocks) package. It was created to publish bug fixes and PRs that were blocking development. If [@serverless/event-mocks](https://github.com/serverless/event-mocks) is actively developed again, this package can be deprecated.

A small library that includes details mocks of AWS Lambda event sources. Useful for use when unit testing your Lambda functions.
Supported Event Sources are:
- [x] API Gateway
Expand All @@ -17,12 +21,18 @@ Supported Event Sources are:

The library simply uses default event source mock templates and merge it with any overwrite you provide. [Check out the JSON template files](./lib/events/aws) to learn more about the data structure of each event source.

## Installation

```
npm install mock-aws-events --save-dev
```

## Usage

### SNS

```js
import createEvent from "@serverless/event-mocks"
import createEvent from "mock-aws-events"

const mocked = createEvent(
"aws:sns",
Expand All @@ -38,7 +48,7 @@ const mocked = createEvent(
### API Gateway

```js
import createEvent from "@serverless/event-mocks"
import createEvent from "mock-aws-events"

const event = createEvent(
"aws:apiGateway",
Expand All @@ -53,7 +63,7 @@ const event = createEvent(
### S3

```js
import createEvent from "@serverless/event-mocks"
import createEvent from "mock-aws-events"

const event = createEvent(
"aws:s3",
Expand All @@ -75,7 +85,7 @@ const event = createEvent(
### Scheduled

```js
import createEvent from "@serverless/event-mocks"
import createEvent from "mock-aws-events"

const event = createEvent(
"aws:scheduled",
Expand All @@ -87,7 +97,7 @@ const event = createEvent(
### Kinesis

```js
import createEvent from "@serverless/event-mocks"
import createEvent from "mock-aws-events"

const event = createEvent(
"aws:kinesis",
Expand All @@ -99,7 +109,7 @@ const event = createEvent(
### Dynamo

```js
import createEvent from "@serverless/event-mocks"
import createEvent from "mock-aws-events"

const event = createEvent(
"aws:dynamo",
Expand Down Expand Up @@ -138,75 +148,89 @@ const event = createEvent(
### Websocket event

```js
const event = createEvent("aws:websocket", {
body: {
first_name: "Sam",
last_name: "Smith",
},
requestContext: {
connectedAt: 123,
connectionId: "abc123",
},
});
import createEvent from "mock-aws-events"

const event = createEvent("aws:websocket", {
body: {
first_name: "Sam",
last_name: "Smith",
},
requestContext: {
connectedAt: 123,
connectionId: "abc123",
},
});
```
### CloudWatch event

```js
const event = createEvent("aws:cloudWatch", {
"detail-type": "Something has been deleted.",
"region": "us-east-1"
});
import createEvent from "mock-aws-events"

const event = createEvent("aws:cloudWatch", {
"detail-type": "Something has been deleted.",
"region": "us-east-1"
});
```

### CloudWatchLog event

```js
const event = createEvent("aws:cloudWatchLog", {
awslogs: {
data: "Some gzipped, then base64 encoded data",
}
});
import createEvent from "mock-aws-events"

const event = createEvent("aws:cloudWatchLog", {
awslogs: {
data: "Some gzipped, then base64 encoded data",
}
});
```

### Alexa Skill event

```js
const event = createEvent("aws:alexaSkill", {
request: {
type: "CanFulfillIntentRequest",
},
context: {
System: {
device: {
deviceId: "myDevice",
},
import createEvent from "mock-aws-events"

const event = createEvent("aws:alexaSkill", {
request: {
type: "CanFulfillIntentRequest",
},
context: {
System: {
device: {
deviceId: "myDevice",
},
},
}
},
}
```

### Alexa SmartHome event
```js
const event = createEvent("aws:alexaSmartHome", {
payload: {
switchControlAction: "TURN_OFF",
},
}
import createEvent from "mock-aws-events"

const event = createEvent("aws:alexaSmartHome", {
payload: {
switchControlAction: "TURN_OFF",
},
}
```

### IoT event
```js
const event = createEvent("aws:iot", {
this: {
can: {
be: "anything I want",
},
}
import createEvent from "mock-aws-events"

const event = createEvent("aws:iot", {
this: {
can: {
be: "anything I want",
},
}
```

### Cognito Pool Event
```js
const event = createEvent("aws:cognitoUserPool", {
userName: "Aaron Stuyvenberg",
}
```
import createEvent from "mock-aws-events"

const event = createEvent("aws:cognitoUserPool", {
userName: "Aaron Stuyvenberg",
}
```
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const dictionary = {

export default function createEvent<T extends keyof typeof dictionary, B>(
eventType: T,
body: typeof dictionary[T],
body: Partial<typeof dictionary[T]>,
): typeof dictionary[T] {
const event = dictionary[eventType];
let generatedEvent = {};
Expand Down
Loading