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.
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.
- Clone this repository onto your local device.
- 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'.
- In the terminal, run
npm install
in bothAdventus/frontend
andAdventus/backend
separately to install the required dependencies. - In the terminal, under directory
Adventus/backend
, runprisma generate
followed byprisma db push
. - 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"
- In the new
- In a separate terminal, under directory
Adventus/backend
, runnpm tsc
(or any other typescript transpilier, ensuring that the tsconfig file is used), followed bynode 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. - In the terminal, under directory
Adventus/frontend
, runnpm run dev
. Take note of the address shown (for us, it's "http://localhost:3000") - In your browser of choice, type in "localhost:3000/" (or the address you were given) in your address bar and enter.
- You should see the homepage of our app Adventus!
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.
Routes in this section all begin with /api/v1/auth
- 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": "..." }
- Status 200 OK
- 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": "..." }
- Status 200 OK