# @bigoncloud/middleware

> Collection of commonly used middlewares

Latest version **1.0.18** (published 2020-09-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bigoncloud/middleware
pnpm add @bigoncloud/middleware
yarn add @bigoncloud/middleware
bun add @bigoncloud/middleware
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.18 |
| Published | 2020-09-02 |
| First published | 2020-07-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | tjnction |

## Links

- npm: https://www.npmjs.com/package/@bigoncloud/middleware
- npm.io page: https://npm.io/package/@bigoncloud/middleware

## Dependencies (9)

- [cors](https://npm.io/package/cors.md) ^2.8.5
- [helmet](https://npm.io/package/helmet.md) ^3.23.3
- [morgan](https://npm.io/package/morgan.md) ^1.10.0
- [express](https://npm.io/package/express.md) ^4.17.1
- [compression](https://npm.io/package/compression.md) ^1.7.4
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^8.5.1
- [cookie-session](https://npm.io/package/cookie-session.md) ^1.4.0
- [express-validator](https://npm.io/package/express-validator.md) ^6.6.0
- [@bigoncloud/errors](https://npm.io/package/@bigoncloud/errors.md) ^1.0.6

## Recent versions

- 1.0.18 (latest) — 2020-09-02
- 1.0.17 — 2020-09-02
- 1.0.14 — 2020-08-30
- 1.0.13 — 2020-08-26
- 1.0.12 — 2020-08-14
- 1.0.11 — 2020-08-12
- 1.0.10 — 2020-08-12
- 1.0.9 — 2020-08-12
- 1.0.8 — 2020-08-11
- 1.0.7 — 2020-08-10
- 1.0.4 — 2020-07-18
- 1.0.1 — 2020-07-18
- 1.0.0 — 2020-07-18

## README

# Commonly Used Middlewares

This collection of middlewares can:
 - setup cors, helmet, compression, morgan and cookie-session
 - validate a user
 - handles all errors
 - handle unknown requests
 - check if user have authorization
 - validate imcoming requests

# Quick start
First, run npm install @bigoncloud/middleware --save for your app. Then in your Express app, if you want to load the common middleware function:


```js
const { commonMiddleware } = require('@bigoncloud/middleware')
```

# Important
It's best to use `commonMiddleware` early in your middleware stack, so that `cors`, `helmet`, `compression`, `morgan` and `cookie-sessions` are set

The environment variable names supported are:
### NODE_ENV
During **development** morgan, the HTTP request logger middleware will active

During **tests** your cookie-session will not be secure, will only be secure during **production** and **development**

### JWT_SECRET
If you use this package, make sure you set your secret key with this environment variable name **JWT_SECRET**. This will through an error if secret is not set with this environment variable name

# Other
This package is designed to work with [@bigoncloud/errors](https://www.npmjs.com/package/@bigoncloud/errors) package

---
_Source: https://npm.io/package/@bigoncloud/middleware · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
