A server-side project for web apllication with users and cards
-
Open vsCode and clone the repository from GitHub:
-
Install the dependencies:
npm i- Run the server
npm run devIn order to check it, you can use the postman program
The following API endpoints are available in this project:
- REST Method: GET
- URL Request: /users
- Authentication: admin only
- Request:
- must provide token
Retrieves a list of all users in the system.
- REST Method: GET
- URL Request: /users/:id
- Authentication: admin or the registered user
- Request:
- must provide token
- REST Method: POST
- URL Request: /register
- Authentication: No
- Request:
- body:
name: The name of the user. [object]first: The first name of the user. [string]- Required.
middle: The middle name of the user. [string]last: The last name of the user. [string]- Required.
phone: The phone number of the user. [string]- Required.
- Format: 0XX-XXXXXXX (e.g., 050-0000000)
email: The email address of the user. [string]- Required.
- Format: valid email address.
- Unique.
password: The password for the user account. [string]- Required.
- Format: At least 8 characters long with at least one uppercase letter, one lowercase letter, one digit, and one special character (#?!@$%^&*-).
image: The image of the user. [object]url: The URL of the image. [string]- Format: valid URL.
- Required.
alt: The alt text for the image. [string]- Required.
address: The address of the user. [object]state: The state of the user's address. [string]country: The country of the user's address. [string]- Required.
city: The city of the user's address. [string]- Required.
street: The street of the user's address. [string]- Required.
houseNumber: The house number of the user's address. [number]- Required.
- Minimum length: 1.
zip: The ZIP code of the user's address. [number]- Minimum length: 4.
- body:
Registers a new user in the system.
- REST Method: POST
- URL Request: /users/login
- Authentication: None
- Request:
- body:
email: The email address of the user. [string]- Required.
- Format: valid email address.
password: The password for the user account. [string]- Required.
- Format: At least 8 characters long with at least one uppercase letter, one lowercase letter, one digit, and one special character (#?!@$%^&*-).
- body:
Logs in a user with the provided email and password.
- REST Method: PATCH
- URL Request: /users/:id
- Authentication: admin or the registered user
- Request:
- must provide token
Updates the user role to a business user
- REST Method: PUT
- URL Request: /users/:id
- Authentication: the registered user only
- Request:
- must provide token
- body:
name: The name of the user. [object]first: The first name of the user. [string]- Required.
middle: The middle name of the user. [string]last: The last name of the user. [string]- Required.
phone: The phone number of the user. [string]- Required.
- Format: 0XX-XXXXXXX (e.g., 050-0000000)
email: The email address of the user. [string]- Required.
- Format: valid email address.
- Unique.
image: The image of the user. [object]url: The URL of the image. [string]- Format: valid URL.
- Required.
alt: The alt text for the image. [string]- Required.
address: The address of the user. [object]state: The state of the user's address. [string]country: The country of the user's address. [string]- Required.
city: The city of the user's address. [string]- Required.
street: The street of the user's address. [string]- Required.
houseNumber: The house number of the user's address. [number]- Required.
- Minimum length: 1.
zip: The ZIP code of the user's address. [number]- Minimum length: 4.
Updates a specific user by their ID.
- REST Method: DELETE
- URL Request: /users/:id
- Authentication: admin or the registered user
- Request:
- must provide token
Deletes a specific user by their ID.
- REST Method: GET
- URL Request: /cards
- Authentication: None
- Request: None
Retrieves a list of all cards.
- REST Method: GET
- URL Request: /cards/my-card
- Authentication Needed: owner user only
- Request:
- must provide token
Retrieves the card associated with the authenticated user.
- REST Method: POST
- URL Request: /cards
- Authentication: business user
- Request:
- must provide token
- body: -
title: The title of the card. [string]- Required.
subTitle: The subtitle of the card. [string]- Required.
description: The description of the card. [string]- Required.
- Maximum length: 1024 characters.
phone: The phone number associated with the card. [string]- Required.
- Format: 0XX-XXXXXXX (e.g., 0502-0000000).
email: The email address associated with the card. [string]- Required.
- Format: valid email address.
- Unique.
web: The website URL associated with the card. [string]- Format: valid URL.
image: The image associated with the card. [object]url: The URL of the image. [string]alt: The alt text for the image. [string]
address: The address associated with the card. [object]state: The state of the card's address. [string]country: The country of the card's address. [string]- Required.
city: The city of the card's address. [string]- Required.
street: The street of the card's address. [string]- Required.
houseNumber: The house number of the card's address. [number]- Required.
- Minimum length: 1.
zip: The ZIP code of the card's address. [number]- Minimum length: 4.
Creates a new card.
- REST Method: PUT
- URL Request: /cards/:id
- Authentication: owner user only and admin
- Request:
- must provide token
- body: -
title: The title of the card. [string]- Required.
subTitle: The subtitle of the card. [string]- Required.
description: The description of the card. [string]- Required.
- Maximum length: 1024 characters.
phone: The phone number associated with the card. [string]- Required.
- Format: 0XX-XXXXXXX (e.g., 0502-0000000).
email: The email address associated with the card. [string]- Required.
- Format: valid email address.
- Unique.
web: The website URL associated with the card. [string]- Format: valid URL.
image: The image associated with the card. [object]url: The URL of the image. [string]alt: The alt text for the image. [string]
address: The address associated with the card. [object]state: The state of the card's address. [string]country: The country of the card's address. [string]- Required.
city: The city of the card's address. [string]- Required.
street: The street of the card's address. [string]- Required.
houseNumber: The house number of the card's address. [number]- Required.
- Minimum length: 1.
zip: The ZIP code of the card's address. [number]- Minimum length: 4.
Updates a specific card by its ID.
- REST Method: PATCH
- URL Request: /cards/:id
- Authentication: registered user
- Request:
- must provide token
Add or remove like from the card's likes array
- REST Method: DELETE
- URL Request: /cards/:id
- Authentication: admin or owner user
- Request:
- must provide token
Deletes a specific card by its ID.