# @id6/express

> id6 ExpressJS integration

Latest version **1.1.0** (published 2021-05-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install @id6/express
pnpm add @id6/express
yarn add @id6/express
bun add @id6/express
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2021-05-31 |
| First published | 2021-04-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Geoffroy Empain |
| Maintainers | id6io, gempain |
| Keywords | id6, express, integration |

## Links

- npm: https://www.npmjs.com/package/@id6/express
- Repository: https://github.com/id6/id6-express
- Homepage: https://github.com/id6/id6-express#readme
- Issues: https://github.com/id6/id6-express/issues
- npm.io page: https://npm.io/package/@id6/express

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^0.21.1

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2021-05-31
- 1.0.5 — 2021-04-14

## README

<p align="center">
  <a href="https://id6.io">
    <img alt="id6-logo" src="https://raw.githubusercontent.com/id6/id6-brand/latest/logo/id6-logo-purple.svg" width="100"/>
  </a>
</p>
<h1 align="center">id6-express</h1>
<p align="center">Express middleware for id6</p>

<p align="center">
  <img alt="npm" src="https://img.shields.io/npm/v/@id6/express">
</p>

## Usage

Install dependencies:

```
npm i @id6/express cookie-parser dotenv
```

Setup authentication:

```js
const express = require('express');
const express = require('cors');
const { authenticate, isAuthenticated } = require('id6-express');

const app = express();

app.use(cors({
  // 1. allow browsers to send the auth cookie
  credentials: true,
}));
// 2. make sure express parses cookies
app.use(cookieParser());
// 3. add the auth middleware
app.use(authenticate({
  url: 'https://authorize.company.com',
  secret: 'changeMe',
}));

app.get('/hello', (req, res) => {
  const user = req.user; // set by id6
  res.json(user ? 'Authenticated' : 'Anonymous');
});
app.get('/private', isAuthenticated, (req, res) => {
  const user = req.user; // set by id6
  res.json(user ? 'Authenticated' : 'Anonymous');
});

app.listen(8000, () => console.log(`Listening on port 8000`));
```

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