# tokenator

> Lightweight Connect Middleware access control with tokens

Latest version **0.0.4** (published 2012-09-16) · 0 weekly downloads

## Install

```sh
npm install tokenator
pnpm add tokenator
yarn add tokenator
bun add tokenator
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2012-09-16 |
| First published | 2012-03-07 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | George Ornbo |
| Maintainers | shapeshed |
| Keywords | api, token, middleware, connect |

## Links

- npm: https://www.npmjs.com/package/tokenator
- Repository: https://github.com/shapeshed/tokenator
- Issues: https://github.com/shapeshed/tokenator/issues
- npm.io page: https://npm.io/package/tokenator

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

- 0.0.4 (latest) — 2012-09-16
- 0.0.3 — 2012-09-07
- 0.0.2 — 2012-09-06
- 0.0.1 — 2012-03-07

## README

# Tokenator

[![Build Status](https://secure.travis-ci.org/shapeshed/tokenator.png)](http://travis-ci.org/shapeshed/tokenator)

Tokenator is a lightweight piece of [Connect][1] Middleware to provide access control based on a token. It is design to be used with APIs.

## Installation

via [npm][2]

    npm install tokenator

## Usage

Tokenator expects the API token to be sent by the client in a header named 'api-token'. 

On the server tokenator expects an array of valid tokens.

If a client tries to connect without a token or an invalid token a 401 response will be returned. 

For [connect][1]

    var connect = require('connect'),
        http = require('http'),
        tokenator = require('tokenator');

    function accessGranted(req, res){
      res.end('Tokenator says yes!');
    }
    var app = connect()
      .use(tokenator(['5917f138c80b512d14a4ee2fe05a17dc', '7b1a47ab847f7534b507c6ae4a763118']))
      .use(accessGranted)
     
    http.Server(app).listen(3000);

For [express][3]

    var express = require('express'),
        tokenator = require('tokenator');

    var app = module.exports = express.createServer();

    app.configure(function(){
      app.use(tokenator(['5917f138c80b512d14a4ee2fe05a17dc', '7b1a47ab847f7534b507c6ae4a763118']))
    });

    app.get('/', function(req, res){
      res.send('Tokenator says yes!');
    });

    app.listen(3000);

[1]: https://github.com/senchalabs/connect/
[2]: http://npmjs.org/
[3]: http://expressjs.com/

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