Skip to content

Commit

Permalink
Merge pull request #2 from rogelio-o/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
rogelio-o committed Dec 30, 2017
2 parents e8d5adc + 437bb0d commit 633124e
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sudo: false
language: node_js
# Specify the node versions to run on
node_js:
- "6.11.2"
- "6.11.5"
# Report code coverage to coveralls after successful test runs
after_success:
- npm run coveralls
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AWS Lambda implementation

[![Coverage Status](https://coveralls.io/repos/github/rogelio-o/lambda-framework-aws/badge.svg?branch=master)](https://coveralls.io/github/rogelio-o/lambda-framework-aws?branch=master) [![Build Status](https://travis-ci.org/rogelio-o/lambda-framework-aws.svg?branch=master)](https://travis-ci.org/rogelio-o/lambda-framework-aws)
[![Coverage Status](https://coveralls.io/repos/github/rogelio-o/lambda-framework-aws/badge.svg?branch=master)](https://coveralls.io/github/rogelio-o/lambda-framework-aws?branch=master) [![Build Status](https://travis-ci.org/rogelio-o/lambda-framework-aws.svg?branch=master)](https://travis-ci.org/rogelio-o/lambda-framework-aws) [![npm version](https://badge.fury.io/js/lambda-framework-aws.svg)](https://badge.fury.io/js/lambda-framework-aws)

AWS Lambda implementation of Lambda Framework.

Expand All @@ -9,20 +9,21 @@ AWS Lambda implementation of Lambda Framework.
### Creating the AWS Lambda handler

```typescript
import { App, IApp } from "lambda-framework";
import { App, IApp, ITemplateRenderer } from "lambda-framework";
importAWSHandler } from "lambda-framework-aws";

const app: IApp = new App();
...
export.handler = AWSHandler(app);
const handler: AWSHandler = new AWSHandler(app);
export const handle = handler.handle.bind(handler);
```

### Using S3 to retrieve the templates

```typescript
import { App, IApp } from "lambda-framework";
importAWSHandler, S3TemplateLoader } from "lambda-framework-aws";
import DustTemplateRenderer from "lambda-framework-dustjs";
import { DustTemplateRenderer } from "lambda-framework-dustjs";

const app: IApp = new App();
...
Expand All @@ -41,9 +42,11 @@ the [Core Project](https://github.com/rogelio-o/lambda-framework).

- [Core](https://github.com/rogelio-o/lambda-framework)
- [AWS Lambda implementation](https://github.com/rogelio-o/lambda-framework-aws)
- [DustJS template engine implementation for Lambda Framework](https://github.com/rogelio-o/lambda-framework-dustjs)
- [Google Cloud Functions implementation](https://github.com/rogelio-o/lambda-framework-gcloud)
- [DustJS template engine implementation](https://github.com/rogelio-o/lambda-framework-dustjs)
- [Website](https://github.com/rogelio-o/lambda-framework-website)
- [Website Resources](https://github.com/rogelio-o/lambda-framework-website-resources)
- [Examples](https://github.com/rogelio-o/lambda-framework-examples)

## Contributions

Expand Down
20 changes: 11 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lambda-framework-aws",
"version": "1.0.6",
"version": "1.0.7",
"description": "AWS Lambda implementation of Lambda Framework",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down Expand Up @@ -30,7 +30,6 @@
"devDependencies": {
"@types/chai": "^4.0.4",
"@types/mocha": "^2.2.43",
"@types/node": "^8.0.28",
"@types/sinon": "^2.3.7",
"chai": "^4.1.2",
"coveralls": "^3.0.0",
Expand All @@ -40,12 +39,15 @@
"sinon": "^4.0.2",
"tslint": "^5.7.0",
"tslint-microsoft-contrib": "^5.0.1",
"typescript": "^2.5.2"
"typescript": "^2.5.2",
"npm-auto-version": "^1.0.0"
},
"dependencies": {
"@types/aws-lambda": "0.0.21",
"@types/aws-lambda": "0.0.24",
"@types/node": "^8.0.28",
"aws-sdk": "^2.161.0",
"lambda-framework": "^1.0.20"
"lambda-framework": "^1.1.1",
"node-cache": "^4.1.1"
},
"nyc": {
"exclude": [
Expand Down
3 changes: 1 addition & 2 deletions src/lib/AWSHandler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Callback, Context } from "aws-lambda";
import { IApp, IRawCallback, IRawEvent } from "lambda-framework";
import AWSTransformer from "./AWSTransformer";

Expand All @@ -15,7 +14,7 @@ export default class AWSHandler {
this._transformer = new AWSTransformer();
}

public handle(event: any, context: Context, callback: Callback): void {
public handle(event: any, context: any, callback: any): void {
const rawEvent: IRawEvent = this._transformer.transformRawEvent(event);
const rawCallback: IRawCallback = this._transformer.transformRawCallback(callback);

Expand Down
4 changes: 4 additions & 0 deletions src/lib/AWSRawCallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ export default class AWSRawCallback implements IRawCallback {
this.callback(null, {statusCode, headers, body});
}

public finalize(err?: Error): void {
this.callback(err);
}

}
12 changes: 12 additions & 0 deletions test/AWSRawCallback.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,16 @@ describe("AWSRawCallback", () => {

});

describe("#finalize", () => {

it("calls the original `callback` function with the given error.", () => {
const err: Error = new Error("Test.");

rawCallback.finalize(err);

Chai.expect(callback.args[0][0]).to.be.equal(err);
});

});

});

0 comments on commit 633124e

Please sign in to comment.