Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reekoheek/node-bono-auth
https://github.com/reekoheek/node-bono-auth
Last synced: 23 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/reekoheek/node-bono-auth
- Owner: reekoheek
- License: mit
- Created: 2017-02-01T08:45:54.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-16T05:27:09.000Z (about 7 years ago)
- Last Synced: 2024-11-12T23:36:26.926Z (about 1 month ago)
- Language: JavaScript
- Size: 25.4 KB
- Stars: 0
- Watchers: 2
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-xinix - bono-auth - Bono Auth Middleware and Bundle - [reekoheek](https://github.com/reekoheek) (Grouping / Node)
README
# node-bono-auth
```sh
npm i bono-auth
``````js
const Bundle = require('bono');
const auth = require('bono-auth');const secret = 'this is secret';
const app = new Bundle();auth.use(async ctx => {
let { username, password } = await ctx.parse();
if (username === 'admin' && password === 'password') {
return { username };
}
});const api = new Bundle();
api.use(auth.authenticate());
app.bundle('/api', api);
app.bundle('/auth', new auth.Bundle());app.listen(3000, () => console.log('Listening at http://localhost:3000'));
```