A progressive Node.js framework for building efficient and scalable server-side applications.
An API for a vending machine, allowing users with a “seller” role to add, update or remove products, while users with a “buyer” role can deposit coins into the machine and make purchases
Task and Features
- REST API should be implemented consuming and producing “application/json”
- Product model with amountAvailable, cost (should be in multiples of 5), productName and sellerId fields
- User model with username, password, deposit and role fields
- Authentication method (basic, oAuth, JWT or something else, the choice is yours)
- All endpoints authenticated unless stated otherwise
- CRUD for users (POST /user should not require authentication to allow new user registration)
- CRUD for a product model (GET can be called by anyone, while POST, PUT and DELETE can be called only by the seller user who created the product)
- /deposit endpoint so users with a “buyer” role can deposit only 5, 10, 20, 50 and 100 cent coins into their vending machine account
- /buy endpoint (accepts productId, amount of products) so users with a “buyer” role can buy a productwith the money they’ve deposited.
- /reset endpoint so users with a “buyer” role can reset their deposit back to 0
- NestJS
- Postgres
- TypeORM
- Jest
Postman: See documentation
git clone https://github.com/mr-chidex/MVP-vendor-machine
cd MVP-vendor-machine
- Create a file named
.env
in the project root directory - Add the environment variables as described in the
dev.env
file
$ yarn install
# development
yarn run start
# watch mode
$ yarn run start:dev
# production mode
$ yarn run start:prod
# unit tests
$ yarn run test
# e2e tests
$ yarn run test:e2e
# test coverage
$ yarn run test:cov