https://github.com/zypeh/setel-practice
https://github.com/zypeh/setel-practice
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/zypeh/setel-practice
- Owner: zypeh
- Created: 2020-05-29T13:56:44.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T17:09:06.000Z (over 3 years ago)
- Last Synced: 2024-04-18T21:02:58.594Z (about 2 years ago)
- Language: TypeScript
- Size: 423 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Setel Interview Challange
Is okay bro... they ghosted me after I submitted this repo anyway.
### Notes
* We are using embedded persistent memory instead of using ORM and database. So the content will be flushed away when the node instance get terminated.
* After 10 seconds the confirmed order will be set to 'DELIVERED' state using Nodejs eventloop mechanism -- `setTimeout` will register the tasklet to eventloop and loop until it reached the time.
But in real world there are message queues and other solution to get this job right.
* The payment app will randomly reject your order. (like 50/50 percent change you will get unsuccessful order create; if you can't create an order, don't worry)
### API
1. To create an order
```POST http://localhost:3000/order
{
"id": "123"
}
```
2. To check order
```GET http://localhost:3000/order/:order_id```
> where order_id is the id of the order
3. To cancelled an order
```PUT http://localhost:3000/order
{
"id": "123"
}
```
> This operation will success if it is not set to 'DELIVERED' state
### Run this thing
```
cd order-app
yarn
yarn start
```
In another shell:
```
cd payment-app
yarn
yarn start
```