A voucher pool is a collection of voucher codes that can be used by customers to get discounts on website. Each code may only be used once, and we would like to know when it was used by the customer. Since there can be many customers in a voucher pool, we need a call that auto-generates voucher codes for each customer.
- Design a database schema
migrations - Write an application
- API endpoint for verifying and redeeming vouchers
- Implement API Rate Limiting: Protect the API from abuse by implementing rate limiting on the endpoints.
- Use Database Transactions: Ensure data consistency by implementing use of transactions in your application.
- Write unit tests
- Using Typescript
- A nice little Readme on how to run
- PLUS POINT: Writing swagger for the API
- PLUS POINT: Docker file to setup the whole application with all the dependencies (database, nodejs)
- Docker and Docker-compose installed on your machine
- Ports
3001and5432are free
Docker Compose
The below command will make everything Database, Migrations, App up and running
$ docker-compose up --buildHint: I kept the
.envfile in repo intentionally for easy setup
Swagger API documentation
http://localhost:3001/api
```bash
# unit tests
$ npm run test