In API FullStackOverflow Developer people can freely post and answer questions. Each question can have only one answer or none (if it hasn't been answered yet)
Try it out now at https://back-fullstackdeveloper.herokuapp.com/
This is a API web app that lets you post and answer questions.
- Post a new question
- Register a new user to answer questions
- Answer questions
- See answered and unanswered questions
The following tools and frameworks were used in the construction of the project:
- Clone this repository
git clone https://github.com/thipereira02/API_FullStackOverflow-Developer- Create a Database using the
dump.sqlfile inside thedumpfolder by following these steps:- 2.1 Open your terminal. Important: the terminal must be opened in the same path as the
dump.sqlfile is located. - 2.2 Access PostgreSQL using the command
sudo su postgresand enter your password when prompted. - 2.3 Next, type
psql postgresand hit enter. - 2.4 Create a database by typing
CREATE DATABASE fullstack;and hitting enter. - 2.5 Type
\qand hit enter. - 2.6 Finally, type
psql fullstack < dump.sqland hit enter. Your database should be ready after this step.
- 2.1 Open your terminal. Important: the terminal must be opened in the same path as the
- Set the environment variables by following these steps:
- 3.1 Create a
.envfile in the folder root - 3.2 Copy the content of the
.env.exampleinto it - 3.3 Set the
DATABASE_URLin this format: "postgres://user:password@host:port/fullstack" - 3.4 Set the
PORTfor 4000
- 3.1 Create a
- In your terminal, go back to the root folder and install the dependencies
npm i- Also in the root folder, run the back-end with
npm start-
Your server should be running now.
-
After that, you can optionally test the project following these steps:
- 7.1 Open your terminal.
- 7.2 Access PostgreSQL using the command
sudo su postgresand enter your password when prompted. - 7.3 Next, type
psql postgresand hit enter. - 7.4 Create a test database by typing
CREATE DATABASE fullstack_test TEMPLATE fullstack;and hitting enter. Your database test should be ready after this step. - 7.5 Set the enviroment variable following the step 5 again, with the following changes:
- 7.5.1 The file must be called
.env.test - 7.5.2 The
DATABASE_URLmust be in this format: "postgres://user:password@host:port/fullstack_test"
- 7.5.1 The file must be called
- Important: the tests assume that some tables are pre-populated. Therefore, it is important to use the dump provided to create the test database.
-
In your terminal, go to the root folder and run the tests with:
npm run test