Auth routes

The two auth APIs are defined in the auth.routes.js file using express.Router() to declare the route paths with relevant HTTP methods, and assigned corresponding auth controller functions that should be called when requests are received for these routes.

The auth routes are as follows: 

  • '/auth/signin': POST request to authenticate the user with email and password
  • '/auth/signout': GET request to clear the cookie containing a JWT that was set on the response object after sign-in

The resulting mern-skeleton/server/routes/auth.routes.js file will be as follows: 

import express from 'express'import authCtrl from '../controllers/auth.controller'const router = express.Router()router.route('/auth/signin')  .post(authCtrl.signin)router.route('/auth/signout') ...

Get Full-Stack React Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.