Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #8 from spring-media/gulp4
Browse files Browse the repository at this point in the history
using now gulp4
  • Loading branch information
jzlai authored Aug 28, 2018
2 parents 3740832 + 3f00c79 commit e0dea56
Show file tree
Hide file tree
Showing 6 changed files with 2,564 additions and 2,677 deletions.
48 changes: 26 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

[![Build Status](https://travis-ci.org/WeltN24/aws-lambda-router.svg?branch=master)](https://travis-ci.org/WeltN24/aws-lambda-router)
[![Build Status](https://travis-ci.org/spring-media/aws-lambda-router.svg?branch=master)](https://travis-ci.org/spring-media/aws-lambda-router)
[![npm version](https://badge.fury.io/js/aws-lambda-router.svg)](https://badge.fury.io/js/aws-lambda-router)
[![dependencies](https://david-dm.org/WeltN24/aws-lambda-router.svg)](https://www.npmjs.com/package/aws-lambda-router)

Expand Down Expand Up @@ -49,27 +49,6 @@ exports.handler = router.handler(
path: '/:id',
method: 'DELETE',
action: request=>deleteSomething(request.paths.id)
},
{
path: '/custom-response-object',
action: 'GET',
action: request => {
return {
// Allow for custom status codes depending on execution.
statusCode: 400,
// Headers will merge with CORs headers when enabled.
// Will merge with Content-Type: application/json
headers: {
'x-fake-header': 'x-value'
},
// When returning a custom response object, a key of body is required
// The value of body needs to be JSON stringified, this matches
// the expected response for an AWS Lambda.
body: JSON.stringify({
foo: 'bar'
})
}
}
}
],
debug: true,
Expand All @@ -96,6 +75,30 @@ exports.handler = router.handler(
});
```

### Custom response

Per default a status code 200 will be returned. This behavior can be override.

By providing body in the returned object you can modify statuscode and response headers.

```js
return {
// Allow for custom status codes depending on execution.
statusCode: 218,
// Headers will merge with CORs headers when enabled.
// Will merge with Content-Type: application/json
headers: {
'x-new-header': 'another-value'
},
// When returning a custom response object, a key of body is required
// The value of body needs to be JSON stringified, this matches
// the expected response for an AWS Lambda.
body: JSON.stringify({
foo:'bar'
})
};
```

## local developement

The best is to work with ```npm link```
Expand All @@ -105,6 +108,7 @@ See here: http://vansande.org/2015/03/20/npm-link/

## Release History

* 0.3.0 proxyIntegration: allow for custom status codes from route (thanks to [@mintuz](https://github.com/mintuz))
* 0.2.2 proxyIntegration: set correct header values now for CORS
* 0.2.1 proxyIntegration: CORS in Preflight, status code 400 for invalid body, set more CORS headers as default
* 0.2.0 Attention: breaking changes for configuration; add SNS event process
Expand Down
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const gulp = require('gulp');
const del = require('del');
const install = require('gulp-install');
const jasmine = require('gulp-jasmine');
const reporters = require('jasmine-reporters');

gulp.task('test', () =>
gulp.src('test/*.spec.js')
Expand Down
Loading

0 comments on commit e0dea56

Please sign in to comment.