February 2019
Intermediate to advanced
204 pages
4h 52m
English
Let's implement endpoints for CRUD users. We will need two types of endpoints:
We have two types of routers defined in server/api/index.js:
const router = express.Router();const routerAuth = express.Router();
We are going to use the router for open-access endpoints, and routherAuth for accessing authenticated endpoints. We will inject users into the request to differentiate between these two router types:
app.use('/api', injectUserToReq, router);app.use('/api', authenticate, routerAuth);
We will define authenticate and injectUserToReq inside server/helpers/auth.js:
const getUserFromKey = loginKey => new ...
Read now
Unlock full access