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

docs: add github badges #68

Merged
merged 1 commit into from
Dec 21, 2021
Merged
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
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# Schibsted Middy CORS middleware

#### CORS middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda
![github checks](https://badgen.net/github/checks/schibsted/middy-cors)
![current version @ npm](https://badgen.net/npm/v/@schibsted/middy-cors)
![weekly downloads @ npm](https://badgen.net/npm/dw/@schibsted/middy-cors)
![minified size](https://badgen.net//bundlephobia/min/@schibsted/middy-cors)

#### CORS middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda

This middleware sets HTTP CORS headers, necessary for making cross-origin requests, to the response object.

Sets headers in `after` and `onError` phases.

This is an alternative to [standard Middy cors handler](https://github.com/middyjs/middy/tree/master/packages/http-cors) with the following differences:
- it allows you to add more CORS headers

- it allows you to add more CORS headers

## Install

Expand All @@ -19,17 +23,15 @@ To install this middleware you can use NPM:
npm install --save @schibsted/middy-cors
```


## Options

- `allowedOrigins` (array) - list of allowed origins or `['*']` for allowing all origins
- `exposeHeaders` (array) - list of headers to expose
- `maxAge` (string) - value passed to `access-control-max-age` header
- `credentials` (bool) - value passed to `access-control-allow-credentials` header
- `credentials` (bool) - value passed to `access-control-allow-credentials` header
- `allowMethods` (array) - list of allowed HTTP methods
- `allowHeaders` (array) - list of allowed HTTP headers


## Sample usage

```javascript
Expand All @@ -56,7 +58,6 @@ handler({}, {}, (_, response) => {
})
```


## Contributing

Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/schibsted/middy-cors/issues) or to [submit Pull Requests](https://github.com/schibsted/middy-cors/pulls).