A Node.js application that demonstrates how to connect to and interact with a PostgreSQL database.
- Node.js (v12 or higher recommended)
- PostgreSQL database
- npm or yarn package manager
-
Clone the repository:
git clone <your-repository-url> cd postgres_con
-
Install dependencies:
npm install # or yarn install -
Configure environment variables:
cp .env.example .env
Then edit the
.envfile with your database credentials.
Ensure your .env file includes the following variables:
DB_HOST: PostgreSQL host (default: localhost)DB_PORT: PostgreSQL port (default: 5432)DB_USERNAME: Database usernameDB_PASSWORD: Database passwordDB_NAME: Database namePORT: Application port (default: 3000)
Start the application:
npm start
# or
yarn start(Document your API endpoints here)
Run in development mode:
npm run dev
# or
yarn dev