/routes
— папка с файлами роутера
/controllers
— папка с файлами контроллеров пользователя и карточки
/models
— папка с файлами описания схем пользователя и карточки
/middlewares
— папка с мидлварами
npm run start
— запускает сервер
npm run dev
— запускает сервер с hot-reload
npm run dev_i
— запускает сервер с hot-reload и в режиме inspect
Служит для отработки навыков работы с Express & Node.js & MongoDB & Postman & JWT
- добавить пользователя
- обновить аватар пользователя
- обновить данные профиля пользователя
- добавить карточку
- удалить карточку
- лайкнуть карточку
- убрать лайк карточки
- удалить карточку
- возможность однократно логиниться: реализовано за счёт jwt, который хранится и передается через куки
- хеширование пароля с хранением "соли" на сервере
- Method: GET
- Endpoint: /users
- Description: Get all users from the database.
- Response:
- Success (200 OK): Array of user objects.
- Error (500 Internal Server Error): Default error message.
- Method: POST
- Endpoint: /signup
- Description: Create a new user with provided data (name, about, avatar) in the request body.
- Request Body: JSON object with name, about, and avatar properties.
- Response:
- Success (201 OK): Created user object.
- Error (400 Bad Request): Invalid data provided.
- Error (500 Internal Server Error): Default error message.
- Method: GET
- Endpoint: /users/:userId
- Description: Get a user by their ID (_id).
- Response:
- Success (200 OK): User object.
- Error (404 Not Found): User with the specified ID not found.
- Error (500 Internal Server Error): Default error message.
- Method: PATCH
- Endpoint: /users/me
- Description: Update user profile information.
- Request Body: JSON object with name and about properties.
- Response:
- Success (200 OK): Updated user object.
- Error (400 Bad Request): Invalid data provided.
- Error (404 Not Found): User with the specified ID not found.
- Error (500 Internal Server Error): Default error message.
- Method: PATCH
- Endpoint: /users/me/avatar
- Description: Update user avatar.
- Request Body: JSON object with link property.
- Response:
- Success (200 OK): Updated user object.
- Error (400 Bad Request): Invalid data provided.
- Error (404 Not Found): User with the specified ID not found.
- Error (500 Internal Server Error): Default error message.
- Method: GET
- Endpoint: /cards
- Description: Get all cards from the database.
- Response:
- Success (200 OK): Array of card objects.
- Error (500 Internal Server Error): Default error message.
- Method: POST
- Endpoint: /cards
- Description: Create a new card with provided data (name, link, owner) in the request body.
- Request Body: JSON object with name, link, and owner properties.
- Response:
- Success (201 OK): Created card object.
- Error (400 Bad Request): Invalid data provided.
- Error (500 Internal Server Error): Default error message.
- Method: DELETE
- Endpoint: /cards/:cardId
- Description: Delete a card by its ID (_id).
- Response:
- Success (200 OK): Deleted card object.
- Error (404 Not Found): Card with the specified ID not found.
- Method: PUT
- Endpoint: /cards/:cardId/likes
- Description: Add a like to a card by its ID (_id).
- Response:
- Success (200 OK): Updated card object with added like.
- Error (400 Bad Request): Invalid data provided for adding like.
- Error (404 Not Found): Card with the specified ID not found.
- Error (500 Internal Server Error): Default error message.
- Method: DELETE
- Endpoint: /cards/:cardId/likes
- Description: Remove a like from a card by its ID (_id).
- Response:
- Success (200 OK): Updated card object with removed like.
- Error (400 Bad Request): Invalid data provided for removing like.
- Error (404 Not Found): Card with the specified ID not found.
- Error (500 Internal Server Error): Default error message.
- Method: POST
- Endpoint: /signin
- Description: login and get jwt cookie
- Request Body: JSON object properties of user.
- Response:
- Success (200 OK): Updated user object.
- Error (400 Bad Request): Invalid data provided.
- Error (500 Internal Server Error): Default error message.