Minimal Express / Nodejs Starter with PostgreSQL Database(No ORM)
- Node.js >= 6.x
- PostgreSQL
- Clone repo:
git clone [email protected]:BaharaJr/nodejs-starter.git
$ git clone [email protected]:BaharaJr/nodejs-starter.git
- change directory to nodejs-starter:
$ cd nodejs-starter
- Create .env file and add db URL. Sample:
DATABASE_URL=postgres://username(DEFAULT is postgres):your-db-passowrd@your-hostname(i.e localhost):postgres-port(DEFAULT is 5432)/your-db-name
$ cp .env.example .env
- In the .env file, also add the port you would like to use. i.e
PORT=4000
- Install packages with
$ npm i
Run
$ npm run start
Runs the application with nodemon. Server is listening on Port 4000 by default. This can be overwritten by
PORT
constant in.env
file.
The App will run on the port you added in your .env file (
localhost:YOUR-PORT
)
Request
GET test
Host: localhost:4000
Response
{
"title": "NodeJs Club is awesome"
}
GET test
Host: localhost:4000
Response
{
"databasename": "databse_name",
"command": "SELECT",
"catalogname": "current_catalog",
"format": "text",
"message": "Database was connected successfully"
}
npm test
Give a ⭐️ if this project helped you!
This project is WTFPL licensed.