cp env-example .env
docker-compose up
You can open below service to see!
- Swagger: http://localhost:3000/docs
- Adminer (client for DB): http://localhost:8080
- update the env
cp env-example .env
Change DATABASE_HOST=postgres to DATABASE_HOST=localhost
- run additional container:
docker-compose up -d postgres adminer
3.1 for the first time:
npm install
npm run migration:run
npm run seed:run
3.2 make sure everything is okay before development (code style, format, unit test, ts compile issue)
npm run pre:dev
3.3 kick off the dev server
npm run start:dev
You can open below service to see!
- Swagger: http://localhost:3011/docs
npm run test:coverage
npm run test:e2e:docker
- [] handle co-current issue when update, think about which level I want to use
- [] fix create logic bug: will still return valid object if we go into catch block. Even you try to solve this by ret -2, this is not a good way, better try to get the db error code and translate to meaning log and ret to front-end
- [] fix update logic bug: this need to and a lock
- [] try to setup a many-to-many relationship for demo (like say we can have multiple owner for a motor-vehicle)
- [] the way your update's DTO might not be efficient enough say you always re-create and save the whole into it. Many be try to use repo.update instead?
- use docker-compose.dev.yaml to docker compose up
- use your prefer db client to check if db is alive
- follow above to "run migration" and "apply seed"
- you shall good to go
- do something about db in code, like add a new db entity
- npm run
migration:generate
, which will detect the dif between ur db and local code and gen a migration file at ./tmp/migrations-local - check the file
- cut over the file into ./src/database/migrations and update its name to make it meaningful
- npm run
migration:run
, which apply the migration