This project is a back-end API built with Express.js for a personal platform called USOF. The API allows users to register, log in, create posts/comments, like/dislike posts, and manage other interactions.
-
Clone this repository.
git clone git@gitlab.ucode.world:connect-khpi/connect-fullstack-usof-backend/vzharyi.git
-
Customize the config/config.json file. Change the user and password to your existing user. Example:
"user": "vzharyi" "password": "securepass" -
Install the dependencies.
npm install
-
Run the command MySQL:
mysql -u {USER_NAME} -p < config/db.sql.You need to enter your login, press enter, and provide your MySQL password.
-
Start the server.
npm run start
Ethereal is a fake SMTP service primarily intended for, but not limited to, Nodemailer and EmailEngine users. This free anti-transactional email service does not deliver messages, allowing you to view sent emails by logging in with a test login and password.
login: rosemarie.windler@ethereal.email
password: pXUV3PeFKkXncqdehZ
POST /api/auth/register— Register a new userPOST /api/auth/verify-email/:confirm_token— Verify user’s email with tokenPOST /api/auth/login— Log in and receive an access tokenPOST /api/auth/logout— Log out the userPOST /api/auth/password-reset— Send password reset email (requires authentication)POST /api/auth/password-reset/:confirm_token— Confirm and reset password with token (requires authentication)
GET /api/users— Get all usersGET /api/users/:user_id— Get specific user informationGET /api/users/:user_id/posts— Get all posts of a userPOST /api/users— Create a new user (admin only)PATCH /api/users/avatar— Update user avatarPATCH /api/users/:user_id— Update user profileDELETE /api/users/:user_id— Delete a user
GET /api/posts— Get all posts with filtering and sortingGET /api/posts/:post_id— Get specific post by IDGET /api/posts/:post_id/comments— Get comments on a specific postPOST /api/posts/:post_id/comments— Add a comment to a postGET /api/posts/:post_id/categories— Get categories of a specific postGET /api/posts/:post_id/like— Get likes for a specific postPOST /api/posts— Create a new postPOST /api/posts/:post_id/like— Add a like/dislike to a postGET /api/favorites— Get all favorite posts of the userPOST /api/favorites/:post_id— Add a post to favoritesPATCH /api/posts/:post_id— Update a post (author or admin)DELETE /api/posts/:post_id— Delete a post (author or admin)DELETE /api/posts/:post_id/like— Remove a like/dislike from a postDELETE /api/favorites/:post_id— Remove a post from favorites
GET /api/categories— Get all categoriesGET /api/categories/:category_id— Get a specific category by IDGET /api/categories/:category_id/posts— Get posts in a specific categoryPOST /api/categories— Create a new category (admin only)PATCH /api/categories/:category_id— Update a category (admin only)DELETE /api/categories/:category_id— Delete a category (admin only)
GET /api/comments/:comment_id— Get a specific comment by IDGET /api/comments/:comment_id/like— Get likes for a specific commentPOST /api/comments/:comment_id/like— Add a like/dislike to a commentPATCH /api/comments/:comment_id— Update a commentDELETE /api/comments/:comment_id— Delete a commentDELETE /api/comments/:comment_id/like— Remove a like/dislike from a comment
AdminJS library is used. The admin panel is available at http://localhost:8080/admin.
- Favorite posts - users can add posts to favorites and see this list.
- Automatic post blocking - automatically blocks a post a month after it was created. After blocking, the author will not be able to edit the post, and other users will not be able to leave comments on it.
email: john.smith@example.com
password: Adm1nP@ss!