Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lqqyt2423/basic-auth

The basic auth middleware for express
https://github.com/lqqyt2423/basic-auth

Last synced: 20 days ago
JSON representation

The basic auth middleware for express

Awesome Lists containing this project

README

        

# The basic auth middleware for express

## Install

```bash
npm install @liqiqiang/basic-auth --save
```

## Usage

### before all route

```javascript
const express = require('express');
const basicAuth = require('@liqiqiang/basic-auth');

const app = express();

// all route
app.use(basicAuth('user', 'password'));

app.listen(8000);
```

### before specific route

```javascript
const express = require('express');
const basicAuth = require('@liqiqiang/basic-auth');

const app = express();

// specific route
app.use('/api', basicAuth('user', 'password'));

app.listen(8000);
```