Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/reekoheek/node-bono-auth


https://github.com/reekoheek/node-bono-auth

Last synced: 23 days ago
JSON representation

Awesome Lists containing this project

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'));
```