1. Use Create React App to create the app itself and set up the environment.
Two routes for unauthorized users in a separate utils/auth.js
file:
/signup
/signin
ProtectedRoute
— to protect the /profile route so that unauthorized users can’t access it- The modal window for user login and registration
The header must be different for authorized and unauthorized users.
Implement localStorage
to store and access the token when working with the site. On repeat visits, users shouldn't have to log in.
There will be two entities in the project: user
and item
- email — each user's
email
must be unique and validated against the email schema - password
- name (optional)
- avatar (optional)
If optional fields are left empty when creating a user, give them default values.
- name
- type
- weather
- owner
- likes
- createdAt
GET /users - returns all users
GET /users/:userId - returns a user by _id
POST /users - creates a new user
PATCH /users/me — update profile
PATCH /users/me/avatar — update avatar
GET /items - returns all items
POST /items - creates a new item
DELETE /items/:itemId - deletes an item by _id
PUT /items/:itemId/likes — like an item
DELETE /items/:itemId/likes — unlike an item
Each route will need the _id
of the user who is performing the action. Get it from req.user._id
.