FUNCTIONALITY:-
- User, Post, Like, Comment are the db resources
- Can signup (create), login users using jwt based authentication
- Logged in users can upload images when creating posts and setting profile pictures (implemented using multer)
- One post can have maximum 7 images
- Each file can be a maximum of 3MB
- Logged in users can do CUD actions on their own posts, comments and likes (only CD for likes)
- Unauthenticated users can only perform read operations
- We can also access data about the posts of the user when we search for a user
SETUP INSTRUCTIONS:-
- run
npm i
- install postgresql in your pc if not already installed. Watch this installation tutorial: https://www.youtube.com/watch?v=HmziePvMwkE
- open
psql
using your credentials and keep the server running while testing the api - create .env file with apprepriate values of fields as shown in .env.example
- run
npx prisma migrate dev --name init
- run
prisma generate
- run
node app.js
and using postman run test the api endpoints
API ENDPOINTS:- (NOTE: ** means it is a protected route hence should send authorization token in header) (Did not include returned values for the api endpoints will do it later)
USERS:
- GET /user/all [get all users]
- GET /user/my-details** [get current logged in user]
- GET /user/search/:username [get user based on searched username]
- PUT /user/change-details** [update user details]
- DELETE /user/delete-profile** [delete logged in user]
AUTH:
- POST /auth/signup [create new user]
- GET /auth/login [login user]
(NOTE check which data to send in body by the schema of the resouces defined on schema.prisma
file)
(NOTE on endpoints /user/auth/signup and /user/change-details can upload minimum 0 files and maximum 1 file with key = file
in formData field of body on postman)