This guide provides step-by-step instructions for setting up the project and configuring the database locally.
Before you begin, ensure you have the following installed on your machine:
- Node.js
- PostgreSQL
-
Clone the Repository
git clone https://github.com/your-username/your-project.git
Replace
https://github.com/your-username/your-project.git
with the URL of your project repository. -
Navigate to the Project Directory
cd your-project
Replace
your-project
with the name of your project directory. -
Install Dependencies
npm install
-
Start PostgreSQL Service
sudo service postgresql start
-
Access PostgreSQL Shell
psql -U postgres
-
Create Database
CREATE DATABASE your_db_name;
Replace
your_db_name
with the desired name for your database. -
Create User and Grant Privileges
CREATE USER your_db_user WITH ENCRYPTED PASSWORD 'your_db_password';
Replace
your_db_user
andyour_db_password
with your desired database username and password.GRANT ALL PRIVILEGES ON DATABASE your_db_name TO your_db_user;
-
Exit PostgreSQL Shell
\q
-
Create
.env
Filetouch .env
-
Add Database and Application Configuration
Open the
.env
file and add the following configuration:# PostgreSQL Database Configuration DB_HOST=localhost DB_PORT=5432 DB_USER=your_db_user DB_PASSWORD=your_db_password DB_NAME=your_db_name # Express Application Configuration PORT=3000
Replace
your_db_user
,your_db_password
, andyour_db_name
with the database username, password, and name you configured earlier.
-
Start the Application
npm start
The application should now be running on
http://localhost:3000
.