Minimal Express / Nodejs Starter with PostgreSQL Database(No ORM)
- Node.js >= 6.x
- PostgreSQL
- Clone repo:
git clone git@github.com:BaharaJr/nodejs-starter.git
$ git clone git@github.com: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 iRun
$ npm run startRuns the application with nodemon. Server is listening on Port 4000 by default. This can be overwritten by
PORTconstant in.envfile.
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 testGive a ⭐️ if this project helped you!
This project is WTFPL licensed.