File size: 1,863 Bytes
a3225c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43860d6
a3225c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cae70c5
 
a3225c5
 
 
 
 
 
 
 
 
 
 
 
cae70c5
a3225c5
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# βŒ›οΈ API Node - Warren Code Challenge

<br>

----

<br>

## πŸš€ Challenge
Create an API that process deposits, payments and withdrawls

## πŸ‘¨πŸ½β€πŸ’» Tech Stack
- Node.js
- Typescript
- Express
- Jest
- Docker
- Mongoose
- MongoDB
- React
- Javascript

## πŸ“ Functional Requirements
- Get user statement
- Make a deposit
- Make a payment
- Make a withdrawl

- `TODO` Monetize the balance
- `TODO` Add transactions seed

## πŸš™ How to run this application

1. `git clone` to download the repository;
2. `npm install` to install the dependencies;
3. `migrate:up` to seed the Docker database; 
3. `cd api && npm run start` to run the project locally;
4. `cd api && docker-compose build --no-cache && docker-compose up -d --force-recreate` to run in Docker

## πŸ›€ Endpoints

### πŸ›’ Base URL: If the backend is running locally, the base url is: http://localhost:3000/, else it's http://localhost/ .

### πŸ” Routes

<br>

**`GET /users/all`** This endpoint returns a list the users registered
<br>
**`GET /users/{id}`** This endpoint returns the details of a given user from it's `id`
<br>
**`POST /users/signup`** This endpoint registers an user

The body of the resquest must be:

```
{
    "email": "warren@mail.com",
    "password": "123456",
    "name": "Warren"
}

```
<br>

**`POST /wallet` ** This is a generic endpoint to handle the user transactions. The transaction `category` must be `deposit`, `payment` or `withdrawl`.

```
{
    "user_id": "602c982bba4ca81124ae0b2b",
    "category": "payment",
    "amount": 100
}

```


<br>

**`GET /wallet/{id}`** This endpoint returns the user statement from it's `id`. Also it must be provided the _query parameters_ `limit`,`skip` and `order_by` for the pagination.  


#### πŸ‘‹πŸ½ How to reach me

LourenΓ§o Passos | Fullstack Software Engineer | lo.passos93@gmail.com | 55-51-996106010