open-index/open-npm huggingface dataset:
npm package: @schibsted/middy-access-log
Description: Middy middleware for logging processed requests in an access-log like fashion. Optimised for JSON loggers e.g. Bunyan or Pino.
Latest version: 4.0.2

# Middy access log middleware

![github checks](https://badgen.net/github/checks/schibsted/middy-access-log)
![current version @ npm](https://badgen.net/npm/v/@schibsted/middy-access-log)
![weekly downloads @ npm](https://badgen.net/npm/dw/@schibsted/middy-access-log)
![minified size](https://badgen.net//bundlephobia/min/@schibsted/middy-access-log)

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

This middleware logs processed requests in an access log like fashion.
I suggest using it together with [@schibsted/middy-error-handler](https://github.com/schibsted/middy-error-handler)

This access log is optimised for JSON loggers e.g. [bunyan](https://github.com/trentm/node-bunyan) or [pino](https://getpino.io/)

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

## Install

To install this middleware you can use NPM:

```bash
npm install --save @schibsted/middy-access-log
```

## Options

- `logger` (defaults to `console`) - a logging function that is invoked with the current error as an argument. You can pass `false` if you don't want the logging to happen.
- `level` (defaults to `info`) - log level to use for the log entries
- `excludeHeaders` (array of header names, defaults to `[]`) - prevent specified headers from showing up in logs (e.g. user credentials)

See the sample usage below.

## Sample usage

```javascript
const middy = require('@middy/core');
const accessLog = require('@schibsted/middy-access-log');
const bunyan = require('bunyan');
const logger = bunyan.createLogger({name: "myapp"});

const handler = middy(async () => ({
        statusCode: 200,
        body: JSON.stringify({ foo: 'bar' }),
    }));

handler
  .use(accessLog({ logger }));
```

## Contributing

Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/schibsted/middy-access-log/issues) or to [submit Pull Requests](https://github.com/schibsted/middy-access-log/pulls).
npm package: @schibsted/middy-caching-headers
Description: Middy middleware for adding caching headers to success response and errors
Latest version: 4.0.4

# Middy caching headers middleware

![github checks](https://badgen.net/github/checks/schibsted/middy-caching-headers)
![current version @ npm](https://badgen.net/npm/v/@schibsted/middy-caching-headers)
![weekly downloads @ npm](https://badgen.net/npm/dw/@schibsted/middy-caching-headers)
![minified size](https://badgen.net//bundlephobia/min/@schibsted/middy-caching-headers)

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

This middleware sets HTTP caching headers, necessary for making the requests cache'able both in browsers and reverse proxies.

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

## Install

To install this middleware you can use NPM:

```bash
npm install --save @schibsted/middy-caching-headers
```

## Options

- `success` (object) - configuration for the successful requests
- `errors` (object) - configuration for the error requests based on the statusCode

Every section of the config contains 3 properties:

- `directive` (string, optional) - response directive e.g. `must-revalidate`, `public` etc.
- `clientTime` (int) - time to set `max-age` for
- `serverTime` (int) - time to set `s-maxage` for

See the sample usage below.

## Sample usage

```javascript
const middy = require('@middy/core');
const cors = require('@schibsted/middy-caching-headers');

const handler = middy(async () => ({
        statusCode: 200,
        body: JSON.stringify({ foo: 'bar' }),
    }));

handler
  .use(cors({
        success: {
            directive: null,
            serverTime: 3600,
            clientTime: 600,
        },
        errors: {
            default: {
                directive: null,
                serverTime: 5,
                clientTime: 5,
            },
            502: false,
            404: {
                directive: null,
                serverTime: 600,
                clientTime: 600,
            },
        },
    }));

// when Lambda runs the handler...
handler({}, {}, (_, response) => {
  expect(response).toEqual({
    statusCode: 200,
    headers:  {
        'cache-control': 'max-age=600,s-maxage=3600',
        'surrogate-control': 'max-age=3600',
    },
    body: JSON.stringify({ foo: 'bar' }),
  })
})
```

## Contributing

Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/schibsted/middy-caching-headers/issues) or to [submit Pull Requests](https://github.com/schibsted/middy-caching-headers/pulls).
npm package: @schibsted/middy-cors
Description: Middy middleware for adding CORS headers to success response and errors
Latest version: 3.0.1

# Schibsted Middy CORS middleware

![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

## Install

To install this middleware you can use NPM:

```bash
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
- `allowMethods` (array) - list of allowed HTTP methods
- `allowHeaders` (array) - list of allowed HTTP headers

## Sample usage

```javascript
const middy = require('@middy/core');
const cors = require('@schibsted/middy-cors');

const handler = middy(async () => ({
        statusCode: 200,
        body: JSON.stringify({ foo: 'bar' }),
    }));

handler
  .use(cors({ allowedOrigins: ['https://www.vg.no', 'https://www.tek.no']}));

// when Lambda runs the handler...
handler({}, {}, (_, response) => {
  expect(response).toEqual({
    statusCode: 200,
    headers: {
        'access-control-allow-origin': 'https://www.vg.no',
    },
    body: JSON.stringify({ foo: 'bar' }),
  })
})
```

## 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).