- Full-Stack React Projects
- Shama Hoque
- 107字
- 2021-06-25 21:45:07
User CRUD API
The user API endpoints exposed by the Express app will allow the frontend to do CRUD operations on the documents generated according to the user model. To implement these working endpoints, we will write Express routes and corresponding controller callback functions that should be executed when HTTP requests come in for these declared routes. In this section, we will look at how these endpoints will work without any auth restrictions.
The user API routes will be declared using Express router in server/routes/user.routes.js, and then mounted on the Express app we configured in server/express.js.
mern-skeleton/server/express.js:
import userRoutes from './routes/user.routes'
...
app.use('/', userRoutes)
...