blob: 1f8f3d2aa714050ee1249f6857c804b35f62c814 (
plain)
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
|
# Goodgame Application test
Comes with:
- ES6 support.
- API documentation using Swagger.
- ESLint for code linting.
- Configuration management using dotenv.
- Logging of requests with Winston.
- Tests using Mocha/Chai.
- Coverage report through nyc.
---
## Check the application live
If you don't want to run it locally, just go to [https://goodgame-test.herokuapp.com/docs/](https://goodgame-test.herokuapp.com/docs/) and experiment with the API
### Expert mode
Open a terminal and use the following command:
```bash
curl -X POST "https://goodgame-test.herokuapp.com/" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"amount\": 100}"
```
You can edit the amount directly on the command
---
## Prerequisites
- [Node.js](https://yarnpkg.com/en/docs/install)
- [NPM](https://docs.npmjs.com/getting-started/installing-node)
## Setup
Install the dependencies and get started right away.
$ cd goodgame
$ npm install
Make a copy of `.env.example` as `.env` and update your application details and database credentials.
### Environment variables description
- `NODE_ENV`: The node environment
- `PORT`: Application port. If not specified, it defaults to port 7777.
- `TEST_PORT`: Port to run tests.
- `URL`: The server's URL. Used by swagger docs explorer
This in an example of a `.env` file
```env
NODE_ENV=development
PORT=7777
TEST_PORT=3333
URL=localhost
```
### Starting the application
$ npm start
Navigate to [http://localhost:7777/docs/](http://localhost:7777/docs/) to verify the instalation.
## Tests
If you have set the test database on the .env file, you can run the tests by using
$ npm run test
|