Map Sorter - Product of GDSC-DUT
API for Map Sorter Product
# install packages
$ npm ci
# init database
$ docker compose up -d init_db
Remember to add --build
option when running at the first time
$ docker compose up -d api_dev
Remember to add --build
option when running at the first time
# show the running container
$ docker ps
# get the CONTAINER ID or NAME of the running container of map-sorter-api
# restart the container
$ docker restart <container_id>
- Using TypeORM
# run migration
$ npm run typeorm:run-migration
# generate migration
$ npm run typeorm:generate-migration --name=some-name
# if script above doesn't work, try using git bash, change $npm_config_name in package.json to %name% and run the following script:
$ name=migration-name npm run typeorm:generate-migration
- Create seed file with
npm run seed:create -- --name=Demo
. WhereDemo
is name of entity. - Go to
src/database/typeorm/seeds/demo/demo-seed.service.ts
. - In
run
method extend your logic.
$ npm run seed:run
# Generate module
$ name=demo npm run module:generate
# Generate controller
$ name=demo npm run controller:generate
# Generate service
$ name=demo npm run service:generate
Module, controller & service of Demo will be created in src/modules/demo
- Change the desired database name in the
gen-entity-local
script inpackage.json
- Run the following command
$ npm run gen-entity-local
The new entities can be found at src/database/typeorm/generated
folder
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# unit tests in watch mode
$ npm run test:watch
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov