Skip to content

Latest commit

 

History

History
84 lines (78 loc) · 3.82 KB

README.md

File metadata and controls

84 lines (78 loc) · 3.82 KB

Orbital

Introduction

Welcome to our Orbital project, Adventus. Adventus is a social media platform catered towards NUS students, providing a platform to make new friends with others outside one's typical social circle.

Installation and Setup

Other required apps

First, make sure you have both node.js as well as postgreSQL. You can install them with the default configurations. Once you've installed postgreSQL, boot up pgAdmin and sign in to your account. Then, from the Object Explorer in the left sidebar, under PostgreSQL > Databases, create a new database with a name of your choice.

Setup

  1. Clone this repository onto your local device.
  2. In your terminal, navigate to the directory in which you saved the repository. For the purposes of this demonstration, let's assume it's saved in a folder named 'Adventus'.
  3. In the terminal, run npm install in both Adventus/frontend and Adventus/backend separately to install the required dependencies.
  4. In the terminal, under directory Adventus/backend, run prisma generate followed by prisma db push.
  5. In Adventus/backend, create a new file named .env.
    • In the new .env file, add the following lines of text, replacing the contents within the curly braces '{}' with the relevant details.
      PORT=8000 
      DATABASE_URL="postgresql://{Your postgreSQL account username}:{Your postgreSQL account password}@localhost:5432/{Your postgreSQL database name}?schema=public"
      JWTDuration="14d"
      

Running the app

  1. In a separate terminal, under directory Adventus/backend, run npm tsc (or any other typescript transpilier, ensuring that the tsconfig file is used), followed by node index.js to start the backend server. For developers, when you are coding on your IDE, change the "module" in tsconfig to "CommonJS". When trasnpilling, change it back to "ESNext". This is due to ESM incompatability of some modules we are using and just a temporary getaround.
  2. In the terminal, under directory Adventus/frontend, run npm run dev. Take note of the address shown (for us, it's "http://localhost:3000")
  3. In your browser of choice, type in "localhost:3000/" (or the address you were given) in your address bar and enter.
  4. You should see the homepage of our app Adventus!

Backend routes

Here we list all the backend API routes and what they expect.

Note that routes marked with an * expect a user's JWT in the 'Authorization' header.

Authentication

Routes in this section all begin with /api/v1/auth

  1. POST /login
    • This route allows a user to login and returns a JWT upon successful authentication.
    • Expects the following Request Body parameters:
      • email: The user's email
      • password: The user's password
    • Responses
      • Status 200 OK
        • {
             "user": {
                "name": "...",
                "image": "..."
             },
             "token": "Bearer ..."
          }
      • Status 401 Unauthorized
        • Occurs when user supplies invalid credentials
        • {
             "error": "..."
          }
  2. POST /signup
    • This route allows a user to signup for an account.
    • Expects the following Request Body parameters:
      • name: The user's name
      • email: The user's email
      • password: The user's password
    • Responses
      • Status 200 OK
        • {
             "user": {
                "name": "...",
                "image": "..."
             },
             "token": "Bearer ..."
          }
      • Status 400 Bad Request
        • Occurs when user supplies duplicate credentials (their email has already been used to sign up for an account)
        • {
             "error": "..."
          }

Activities

WIP