NodeJS backend template
Belows should be installed on your system before running this code of server.
- Node.js version 18.14.x or more latest version
- npm version 9.5.x or more latest version
- PostgresQL 14.6 (It can be downloaded as a docker image from general)
- Docker latest version
- Docker-compose latest version (for development)
npm install --save
There are all default values in the env files already
- Backend environment
- open
./env/backend.env
file and update your desired values.
- open
- DB environment
- open
./env/backend.env
file and update your loca values.
- open
It's for local developing. The Production DB will be running standalone, please do not connect while you are developing
-
Start DB
docker-compose -f ./docker/DB-docker-compose.yml --env-file ./deploy/env/postgresql.env up -d
-
Stop and clean up DB
docker-compose -f ./docker/DB-docker-compose.yml --env-file ./deploy/env/postgresql.env down
- DB Migration
- install migration tool
npm install knex -g
- Run migration
knex migrate:latest
- install migration tool
- Full test
npm run test
- Module test
npm run test:{folder name}
- ex>
npm run test:dao
,npm run test:dao:repositories
,npm run test:services
- ex>
npm run start:local
npm run start:dev
npm run start:prod
- Install (for Mac)
brew install pgcli
- Usage
- connect
pgcli -h {HOST} -p {PORT} -u {user} ex> $pgcli -h 127.0.0.1 -p 5432 -u book
- connect
- DBeaver
- Ref : https://dbeaver.io/