Simple Order API is a simple rest API created with the excellent NestJs Framework. This API server has only one functional endpoint [post] /api/order
which, receives the order's JSON object and saves it in a database.
The purpose of this project is to demonstrate the followings:
TypeScript
and NestJs
framework.TypeORM
to design data models and insert / query data.jest
and achieving almost 100% code coverage:
Docker
and docker-compose
Swagger
to document the API specificationssrc/
contains all typescript source files
dto/
contains data type definitions for api interfacesmodels/
contains data models and entitiesservices/
contains services required for creating and validating Orders and Productsapp.module.ts
file is the main Nest module and contains the dependency injection configurationsorder.controller.ts
file is the controller class to handler api/order
endpoint*.spec.ts
files are the unit tests files (for example order.controller.spec.ts
)test/
directory contains e2e testsAccording to the KISS
Principle (Keep It Stupid Simple), the complexity of this project seems too high for now. But there is a consideration for support new product and order types in the future with minimum changes:
dto/
and models/
directories.services/
folder.app.module.ts
file.http://localhost:3000/docs
pathsimple_order
for developmentsimple_order_test
for e2e tests$ yarn install
# development
$ yarn start
# watch mode
$ yarn start:dev
# production build
$ yarn build
# production mode
$ yarn start:prod
# run all tests and calculate the coverage
$ yarn test
# unit tests only
$ yarn test:unit
# e2e tests only
$ yarn test:e2e
$ docker-compose up