- Have node@16.* or plus and npm@8.* or plus
- Git
- Clone the project
git clone https://github.com/antobrines/Subarashii-BackEnd-Audit-v2.git
- Install the dependencies with
npm i
- Copy paste .env.sample and rename the copy to .env
- Change DB_URL in the .env to your url of mongodb atlas or local mongodb database
- Change TOKEN_SECRET and TOKEN_EXPIRE if needed
- If you have nodemon launch the project with :
nodemon src
- Or else :
npm run dev
The project is deployed to this url :
https://subarashii-backend.vercel.app
We are using vercel for deploying your backend.
- Install the vercel cli
npm i -g vercel
- Create a vercel configuration (.vercel.json)
- Run the command
vercel
And your done !
All routes are starting by /api/
-
URL
/users/register
-
Method:
POST
-
URL Params
None
-
Body Params
Required:
username=[string]
password=[string]
confirm_password=[string]
email=[string]
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/users/register', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: { username: 'John', password: 'Doe69', confirm_password: 'Doe69', email: 'john_doe@lyon.fr' } })
-
URL
/users/login
-
Method:
POST
-
URL Params
None
-
Body Params
Required:
password=[string]
email=[string]
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/users/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: { email: 'john_doe@lyon.fr', password: 'Doe69' } })
Must be an admin
-
URL
/users/ban/:userId
-
Method:
PATCH
-
URL Params
userId=[string]
-
Body Params
None
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/users/ban/1', { method: 'PATCH', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' } })
Must be an admin
-
URL
/users/unban/:userId
-
Method:
PATCH
-
URL Params
userId=[string]
-
Body Params
None
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/users/unban/1', { method: 'PATCH', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' } })
Return information of connected user
-
URL
/users/me
-
Method:
GET
-
URL Params
None
-
Body Params
None
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/users/me', { method: 'GET', headers: { Content-Type: 'application/json', Authorization: 'Bearer token' } })
Update user informations
-
URL
/users
-
Method:
PUT
-
URL Params
None
-
Body Params
username=[string]
email=[string, email, min(6)]
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/users', { method: 'DELETE', headers: { Content-Type: 'application/json', Authorization: 'Bearer token' }, body: { "username": "Alfred", "email": "alfred@gmail.com" } })
Update user password
-
URL
/users/password
-
Method:
PUT
-
URL Params
None
-
Body Params
previousPassword=[string, required]
password=[string, min(6), required]
confirmPassword=[string, same(password), required]
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/users/password', { method: 'DELETE', headers: { Content-Type: 'application/json', Authorization: 'Bearer token' }, body: { "previousPassword": "asghfdozhg", "password": "gieaofjgoefa", "confirmPassword": "gieaofjgoefa" } })
Generate and send reset password key to reset password
-
URL
/users/password/reset/key
-
Method:
POST
-
URL Params
None
-
Body Params
email=[string, email, required]
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/users/password/reset/key', { method: 'DELETE', headers: { Content-Type: 'application/json' }, body: { "email": "alfred@gmail.com" } })
Reset password of user
-
URL
/users/password/reset
-
Method:
POST
-
URL Params
None
-
Body Params
email=[string, email, required]
key=[string, required]
password=[string, required]
confirmPassword=[string, same(password), required]
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/users/password/reset', { method: 'DELETE', headers: { Content-Type: 'application/json' }, body: { "email": "alfred@gmail.com", "key": "9e7d5b481806bca91bf6bed60ae98efb3ef0885d60e8a6f7449ad66e1c847759a5fa9e4471e0bdf32c7f59819e258a873978d6e3138723a938f85a807e8742e5", "password": "Ila1552364", "confirmPassword": "Ila1552364" } })
-
URL
/animes
-
Method:
GET
-
URL Params
page=number
categories=string
adult=boolean
status=number
-
Body Params
None
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/animes?page=1&categories=16,4535&status=1', { method: 'GET', headers: { 'Content-Type': 'application/json' }, body: { username: 'John', password: 'Doe69', confirm_password: 'Doe69', email: 'john_doe@lyon.fr' } })
-
URL
/animes/:animeId
-
Method:
GET
-
URL Params
None
-
Body Params
None
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/animes/8864', { method: 'GET', headers: { 'Content-Type': 'application/json' }, body: { username: 'John', password: 'Doe69', confirm_password: 'Doe69', email: 'john_doe@lyon.fr' } })
-
URL
/animes/:animeId/season/:seasonNumber
-
Method:
GET
-
URL Params
None
-
Body Params
None
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/animes/8864/season/1', { method: 'GET', headers: { 'Content-Type': 'application/json' }, body: { username: 'John', password: 'Doe69', confirm_password: 'Doe69', email: 'john_doe@lyon.fr' } })
Retrieve all the stats of the user
-
URL
/stats
-
Method:
GET
-
URL Params
None
-
Body Params
None
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/stats', { method: 'GET', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' } })
-
URL
/comments
-
Method:
POST
-
URL Params
None
-
Body Params
Required:
content=[string]
animeId=[number]
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/comments', { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' }, body: { content: 'This is a comment', animeId: 1234 } })
Should be yours comment
-
URL
/comments/:id
-
Method:
PUT
-
URL Params
id=[string]
-
Body Params
Required:
content=[string]
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/comments/1', { method: 'PUT', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' }, body: { content: 'This is a comment' } })
Should be yours comment
-
URL
/comments/:id
-
Method:
DELETE
-
URL Params
id=[string]
-
Body Params
None
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/comments/1', { method: 'DELETE', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' } })
-
URL
/comments/anime/:animeId
-
Method:
GET
-
URL Params
animeId=[number]
-
Body Params
None
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/comments/anime/1234', { method: 'GET', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' } })
-
URL
/comments/:id/like
-
Method:
PATCH
-
URL Params
id=[number]
-
Body Params
None
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/comments/1/like', { method: 'PATCH', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' } })
-
URL
/comments/:id/dislike
-
Method:
PATCH
-
URL Params
id=[number]
-
Body Params
None
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/comments/1/dislike', { method: 'PATCH', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' } })
Must be an admin
-
URL
/comments/:id/remove
-
Method:
DELETE
-
URL Params
id=[number]
-
Body Params
None
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/comments/1/remove', { method: 'DELETE', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' } })
-
URL
/lists
-
Method:
GET
-
URL Params
None
-
Body Params
None
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/lists', { method: 'GET', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' } })
-
URL
/lists/:id/animes
-
Method:
GET
-
URL Params
id=[string]
-
Body Params
None
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/lists/62957d16467fe5acaz591f65/animes', { method: 'GET', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' } })
-
URL
/lists/animes
-
Method:
GET
-
URL Params
None
-
Body Params
None
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/lists/animes', { method: 'GET', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' } })
-
URL
/lists
-
Method:
POST
-
URL Params
None
-
Body Params
Required
label[string]
Not required
deletable[boolean]
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/lists', { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' }, body: { label: 'New list' } })
-
URL
/lists/:id
-
Method:
DELETE
-
URL Params
id[string]
-
Body Params
None
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/lists/62957d16467fe5acaz591f65', { method: 'DELETE', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' } })
-
URL
/lists/:id/anime/add
-
Method:
PATCH
-
URL Params
id[string]
-
Body Params
Required
animeId[number]
animeCategories[array(string)]
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/lists/62957d16467fe5acaz591f65/anime/add', { method: 'PATCH', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' }, body: { animeId: 1, animeCategories: ['Adventure', 'Action'] } })
-
URL
/lists/:listId/anime/:animeId
-
Method:
DELETE
-
URL Params
id[string]
animeId[number]
-
Body Params
None
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/lists/1/anime/remove', { method: 'DELETE', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' } })
-
URL
/lists/:listId/anime/:animeId/see
-
Method:
PATCH
-
URL Params
id[string]
animeId[number]
-
Body Params
episodeId[number]
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/lists/62957d16467fe5acaz591f65/anime/1/see', { method: 'PATCH', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' } })
-
URL
/lists/:listId/anime/:animeId/unsee
-
Method:
PATCH
-
URL Params
id[string]
animeId[number]
-
Body Params
episodeId[number]
-
Sample Call:
fetch('https://subarashii-backend.vercel.app/api/lists/62957d16467fe5acaz591f65/anime/1/unsee', { method: 'PATCH', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' } })