Skip to content

mukger/chronos-api

Repository files navigation

chronos_backend

Requirements

  • MySQL 8.0.30
  • Node.js 16.17.0 (npm 8.15.0)

Hosting the API

To host the API just follow these steps:

  1. Install the latest versions of the programs specified in the requirements
  2. Open folder in your terminal and run npm install
  3. Create your database
  4. Create .env file and fill it with your data accordingly to .env.example file (specify your gmail mail address from which messages will be sent to registered users, and a password that can be obtained by two-factor authorization of your Google account and then adding the device from which you plan to send messages to the "Application passwords" section)
  5. Run to fill database with required tables
  6. Start the API server with node index.js

Using the API

You can send API requests from your JS file using fetch or with Postman!

Here's list of possible user API requests:

Authorization module

Action Request Requirements
Register POST - /api/auth/register json data (login, psw, repeatpsw, fname, email)
Login POST - /api/auth/login json data (login, psw)
Log out POST - /api/auth/logout
Forgot password POST - /api/auth/password-reset json data (login)
Reset password POST - /api/auth/password-reset/token json data (newpsw, repeatnewpsw)


User module

Action Request Requirements
Show all users GET - /api/users token
Show specific user GET - /api/users/:id token
Create user by admin POST - /api/users token, json data (login, psw, repeatpsw, fname, email)
Change users avatar PATCH - /api/users/avatar token, json data
Change current user data PATCH - /api/users/:id token, json data (login, psw, repeatpsw, fname, email)
Delete specific user DELETE - /api/users/:id token
Refresh token POST - /api/auth/refresh-tokens token


Post module

Action Request Requirements
Show all posts GET - /api/posts token
Show favorites posts by current user GET - /api/posts/favorites token
Add post to favorites posts by current user POST - /api/posts/:id/favorites token
Delete post from favorites posts by current user DELETE - /api/posts/favorites/:id token
Show subscriptions posts by current user GET - /api/posts/subscriptions token
Add post to subscriptions posts by current user POST - /api/posts/:id/subscriptions token
Delete post from subscriptions posts by current user DELETE - /api/posts/subscriptions/:id token
Show specific post GET - /posts/:id token
Show comments by specific post GET - /posts/:id/comments token
Create comment specific post by current user POST - /posts/:id/comments token, json data (content)
Show categories by specific post GET - /posts/:id/categories token
Show likes by specific post GET - /posts/:id/like token
Create post by current user POST - /posts/ token, json data (title, content, categories)
Like post by current user POST - /posts/:id/like token, json data (type)
Change post by current user PATCH - /posts/:id token, json data (user: title, content, categories; admin: status)
Delete specific post by current user DELETE - /posts/:id token
Delete like specific post by current user DELETE - /posts/:id/like token


Categories module

Action Request Requirements
Show all categories GET - /api/categories token
Show specific category GET - /api/categories/:id token
Show all posts by category GET - /api/categories/:id/posts token
Create new category POST - /api/categories token, json data (title, description)
Change specific category PATCH - /api/categories/:id token, json data (title, description)
Delete specific category DELETE - /api/categories/:id token


Comments module

Action Request Requirements
Show specific comment GET - /api/comments/:id token
Show likes by specific comment GET - /api/comments/:id/like token
Like comment by current user POST - /api/comments/:id/like token, json data (type)
Change specific comment PATCH - /api/comments/:id token, json data (content)
Delete specific comment DELETE - /api/comments/:id token
Delete like specific comment DELETE - /api/comments/:id/like token

Have a good day!

About

Website for calendar managment (creating events, scheduling etc.)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors