Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

Bingus API

Backend for Bingus repo

Demo for bingus Live

Built with

  • ExpressJS
  • Postgresql

Tools

  • Cloudinary : cloud based media management service
  • Socket.IO: for live communication between client and server
  • Prisma: ORM to connect and query database

Development

Here are the steps to start the project locally.

Prerequisites:

  • Installed psql
  • Installed npm

1. Clone the repo

# HTTPS
$ git clone https://github.com/Legalunicorn/bingus-api.git

#SSH
$ git clone git@github.com:Legalunicorn/bingus-api.git

2. Download dependencies

cd bingus-api
npm i

3. Get your google API Keys.

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

5. Create postgresql database

  • $ psql
  • 'CREATE DATABASE bingus;`

6. Create and populate .env

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"

7. Run the server

$ npm run serverstart 

[Optional] 8. clone the frontend repo and run it

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

ERD

erd

features todo

  • 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)

API Check list

Auth

  • /auth/local/login __POST
  • /auth/local/signup POST
  • /auth/oauth/google/ GET
  • /auth/oauth/google/redirect GET
  • /auth/oauth/username PATCH

Post

  • /posts/:userId? GET - get posts by everyone or by one user

  • /posts/following GET get post only by users who userId is following

  • /posts/single/:postId GET

  • /posts POST

  • /posts/:postId/like POST

  • /posts/:postId/unlike POST

  • /posts/:postId DELTE

  • /posts/:postId PATCH

  • /posts/:postId//link PATCH

User

  • /users GET
  • /users/:userId GET
  • /users/self/:userId GET
  • /users/:userId/followers GET
  • /users/:userId/following GET
  • /users/:userId/profile PATCH
  • /users/:userId/bio PATCH (not in use)
  • /users/:userId/settings PATCH (not in use)
  • /users/:userId DELETE (not in use yet)
  • /users/:userId/follow POST
  • /users/:userId/unfollow POST

Comment

  • /comments/:commentId GET delete a comment
  • /comments/ POST
  • /comments/:commentId/like POST
  • /comments/:commentId/unlike POST
  • /comments/:commentId DELETE

Chats

  • /chats/ GET
  • /chats/:chatId GET
  • /chats/user/:userId PUT

Tags_

  • -/tags/:tagId/posts GET> get all post by tags

Init

  • /init GET

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

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages