REST client for accounts


Keywords
rest, graphql, grant, auth, authentication, accounts, users, oauth
License
MIT
Install
npm install @accounts/rest-client@0.33.1

Documentation

rest

REST client and server for accounts.

CircleCI codecov MIT License

Getting Started

npm i -S @accounts/rest-express
import express from 'express';
import bodyParser from 'body-parser';
import { AccountsServer } from '@accounts/server';
import accountsExpress, { userLoader } from '@accounts/rest-express';

const app = express();
app.use(bodyParser.json());

const accountsServer = new AccountsServer({ ...options });
const accountsExpressOptions = { ...options };
app.use(accountsExpress(accountsServer, accountsExpressOptions));

// To bind all routes
app.use(userLoader(accountsServer));

// to bind a specific route
app.get('/protected', userLoader(accountsServer), (req, res) => {
  if (!req.user) {
    res.status(401).send();
    return;
  }
  res.send(req.user))
}