Skip to content
This repository was archived by the owner on Jul 6, 2018. It is now read-only.

accounts-js/rest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

195 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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))
}

Packages

 
 
 

Contributors