The main objective of this challenge is to allow the creation of customers, products and orders, where the customer can generate new purchase orders for certain products.
- Node.js - evented I/O for the backend
- Express - fast node.js network app framework
- Typescript - typed superset of JavaScript that compiles to plain JavaScript.
- TypeORM - an ORM that can run in Nodej, browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms and can be used with TypeScript and JavaScript
- Yarn - package manager that doubles down as project manager.
- Tsyringe - A lightweight dependency injection container for TypeScript/JavaScript for constructor injection.
- DotEnv - A module that loads environment variables from a .env file.
With docker hub installed, follow the commands:
$ docker run --name postgres -e POSTGRES_PASSWORD=docker -p 5432:5432 -d postgrees
$ docker start postgres
Install dependencies and start the server.
$ yarn
$ yarn typeorm migrations:run
$ yarn dev:server
POST /customers
: This route must receivename
andemail
inside body of request.POST /products
: This route must receivename
,price
equantity
inside body of request.POST /orders
: This route must receive in inside body of request thecustomer_id
e an array of products, containing theid
andquantity
that you want to add to a new order.
Before running the tests, create a database with the name "gostack_desafio09_tests" so that all tests can run correctly
$ yarn test
๐ should be able to create a new customer
๐ should not be able to create a customer with one e-mail thats already registered
๐ should be able to create a new product
๐ should not be able to create a duplicated product
๐ should be able to create a new order
๐ should not be able to create an order with a invalid customer
๐ should not be able to create an order with invalid products
๐ should not be able to create an order with products with insufficient quantities
๐ should be able to subtract an product total quantity when it is ordered
๐ should be able to list one specific order