|
| 1 | +# Koa Example (JavaScript) |
| 2 | + |
| 3 | +Sample project for with [koa](https://koajs.com//). |
| 4 | + |
| 5 | +## Running |
| 6 | + |
| 7 | +Install dependencies. |
| 8 | + |
| 9 | +```bash |
| 10 | +$ yarn |
| 11 | +``` |
| 12 | + |
| 13 | +Run the koa app server. |
| 14 | + |
| 15 | +``` |
| 16 | +$ yarn start |
| 17 | +``` |
| 18 | + |
| 19 | +Now you can test it through `curl`. |
| 20 | + |
| 21 | +``` |
| 22 | +$ curl 'http://localhost:3000?a=20&b=30' && curl 'http://localhost:3000?a=10&b=50' && curl 'http://localhost:3000?a=50&b=100' |
| 23 | +``` |
| 24 | + |
| 25 | +**Output** |
| 26 | + |
| 27 | +``` |
| 28 | +2019-10-26T08:42:23.335Z [ INFO ] HTTP server listening on port 3000! |
| 29 | +
|
| 30 | +2019-10-26T08:42:31.037Z [ DEBUG ] f45b64f0 - Persisted a: 20 |
| 31 | +2019-10-26T08:42:31.037Z [ DEBUG ] f45b64f0 - Persisted b: 30 |
| 32 | +2019-10-26T08:42:31.038Z [ DEBUG ] f45b64f0 - Simulating delayed access |
| 33 | +2019-10-26T08:42:31.039Z [ DEBUG ] f45b64f0 - Calculated sum: 50 |
| 34 | +2019-10-26T08:42:31.039Z [ DEBUG ] f45b64f0 - Persisted sum: 50 |
| 35 | +2019-10-26T08:42:31.042Z [ INFO ] f45b64f0 - Response sent |
| 36 | +2019-10-26T08:42:31.078Z [ DEBUG ] f5d8bbdb - Persisted a: 10 |
| 37 | +2019-10-26T08:42:31.079Z [ DEBUG ] f5d8bbdb - Persisted b: 50 |
| 38 | +2019-10-26T08:42:31.079Z [ DEBUG ] f5d8bbdb - Simulating delayed access |
| 39 | +2019-10-26T08:42:31.079Z [ DEBUG ] f5d8bbdb - Calculated sum: 60 |
| 40 | +2019-10-26T08:42:31.079Z [ DEBUG ] f5d8bbdb - Persisted sum: 60 |
| 41 | +2019-10-26T08:42:31.079Z [ INFO ] f5d8bbdb - Response sent |
| 42 | +2019-10-26T08:42:31.100Z [ DEBUG ] 9f06d9ba - Persisted a: 50 |
| 43 | +2019-10-26T08:42:31.100Z [ DEBUG ] 9f06d9ba - Persisted b: 100 |
| 44 | +2019-10-26T08:42:31.100Z [ DEBUG ] 9f06d9ba - Simulating delayed access |
| 45 | +2019-10-26T08:42:31.100Z [ DEBUG ] 9f06d9ba - Calculated sum: 150 |
| 46 | +2019-10-26T08:42:31.100Z [ DEBUG ] 9f06d9ba - Persisted sum: 150 |
| 47 | +2019-10-26T08:42:31.101Z [ INFO ] 9f06d9ba - Response sent |
| 48 | +2019-10-26T08:42:33.039Z [ INFO ] f45b64f0 - Store contents: {"a":"20","b":"30","sum":50} |
| 49 | +2019-10-26T08:42:33.080Z [ INFO ] f5d8bbdb - Store contents: {"a":"10","b":"50","sum":60} |
| 50 | +2019-10-26T08:42:33.106Z [ INFO ] 9f06d9ba - Store contents: {"a":"50","b":"100","sum":150} |
| 51 | +
|
| 52 | +``` |
0 commit comments