Backend for Bingus repo
Demo for bingus Live
- ExpressJS
- Postgresql
- Cloudinary : cloud based media management service
- Socket.IO: for live communication between client and server
- Prisma: ORM to connect and query database
Here are the steps to start the project locally.
Prerequisites:
- Installed psql
- Installed npm
# HTTPS
$ git clone https://github.com/Legalunicorn/bingus-api.git
#SSH
$ git clone git@github.com:Legalunicorn/bingus-api.gitcd bingus-api
npm i
follow this.Set up a project and Under API and services, add the following url to Authorized redirect URIs.:
https://localhost:3000/api/auth/oauth/google/redirect
Proceed to the next step if you can do this else read below.
If you cant get this step done, you can comment out /config/passportSetup.js. Also head to /routes/authRoutes.js and comment out
//router.get('/oauth/google',controller.googleGet)
//router.get('/oauth/google/redirect',controller.googleRedirectGet)Also head over to /controllsers/authControllers/js and comment out two functions:
exports.googleGet and exports.googleRedirectGet
4. Create a Cloudinary account
This will give you access the following:
- CLOUDINARY_API_NAME
- CLOUDINARY_API_KEY
- CLOUDINARY_API_SECRET
$ psql- 'CREATE DATABASE bingus;`
touch .env
Values:
DATABASE_URL="postgresql://<user>:<password>@localhost:5432/bingus?schema=public"
SECRET= #Create your own secret, it can be anything.
GOOGLE_CLIENT_ID= #from your google account
GOOGLE_CLIENT_SECRET= #from your google account
CLOUDINARY_CLOUD_NAME= #from your cloudinary account
CLOUDINARY_API_KEY= #from your cloudinary account
CLOUDINARY_API_SECRET= #from your cloudinary account
DEFAULT_PFP="https://res.cloudinary.com/ds80ayjp7/image/upload/v1725690182/bingus_pfp_bzezbh.png"$ npm run serverstart
If you wish to use the UI, head over to the Bingus frontend repo and follow the instructions to run it.
Otherwise you can use a service like Postman to test and build the API.
If I've missed a step or something please create an issue or contact me at nyeo700@gmail.com
- Implement Access and Refresh Tokens with JWT (currently just basic JWT)
- Integrate notifications model for messages, likes, comments (currenot no notifications modal used or made)
-
/auth/local/login__POST -
/auth/local/signupPOST -
/auth/oauth/google/GET -
/auth/oauth/google/redirectGET -
/auth/oauth/usernamePATCH
-
/posts/:userId?GET - get posts by everyone or by one user -
/posts/followingGET get post only by users who userId is following -
/posts/single/:postIdGET -
/postsPOST -
/posts/:postId/likePOST -
/posts/:postId/unlikePOST -
/posts/:postIdDELTE -
/posts/:postIdPATCH -
/posts/:postId//linkPATCH
-
/usersGET -
/users/:userIdGET -
/users/self/:userIdGET -
/users/:userId/followersGET -
/users/:userId/followingGET -
/users/:userId/profilePATCH -
/users/:userId/bioPATCH (not in use) -
/users/:userId/settingsPATCH (not in use) -
/users/:userIdDELETE (not in use yet) -
/users/:userId/followPOST -
/users/:userId/unfollowPOST
-
/comments/:commentIdGET delete a comment -
/comments/POST -
/comments/:commentId/likePOST -
/comments/:commentId/unlikePOST -
/comments/:commentIdDELETE
-
/chats/GET -
/chats/:chatIdGET -
/chats/user/:userIdPUT
- -
/tags/:tagId/postsGET> get all post by tags
-
/initGET
Note: Some endpoints I did not end up using have not been used yet, will refine them when I have time. Same goes for certain Prisma model fields I ended up not using.
There are also some insistensies in the way i throw errors, but the have the same results. such as using res.status(400).json() vs throwing my own custom error with throw new myError
