Sample Typescript backend service, docker based.
Docker compose starts 3 services:
- backend api service (storage-service)
- database (Postgresql)
- Database client (PGAdmin)
- Docker environment
- Local environment
From console, run
docker-compose up
Setup local environment
- Install locally postgres
- create a user:
uid: sample
pwd: sample-pwd
- install node >= 10.15
- open console and run
npm i
After first boot, goto postgres admin console and execute: db/init.sql
example users:
user: admin
pwd: admin
user: user
pwd: user
-
Run in developer mode
npm run start
3.1 Debug Code
After start, goto vscode debug view, and launch "Attach to storage-service"
-
Run tests
npm run test
-
Build
npm run build
-
Generate docs
Open console and run
npm run generate-apidoc
Install Postman and use provided collection in ./postman/sample.storage-service.json
Launch docker (or backend locally) and go to:
http://localhost:8005/apidoc/
Docker environment provide a PGAdmin 4 container in order to manage database. In order to connect, open a browser and go to:
http://localhost:5050
Then, login with these credentials:
user:[email protected]
pwd:admin
- Using
volumes:
- ./storage-service:/usr/local/storage-service
- /usr/local/storage-service/node_modules/
let you avoid to copy all node_modules dependency from container to host machine