add README

This commit is contained in:
Jakub Sokołowski 2018-10-16 14:03:16 -04:00
parent be5b1bdb86
commit 2a65270400
2 changed files with 21 additions and 2 deletions

19
README.md Normal file
View File

@ -0,0 +1,19 @@
# Description
This is a minimal API done using Koa and Redis for counting clicks.
It exposes just 2 calls:
* `PUT /click` - Increments the counter by 1 and returns current count.
* `GET /clicks` - Returns the JSON with clicks count.
# Usage
For development use:
```
npm run start
```
For building use:
```
npm run build
```

View File

@ -17,11 +17,11 @@ const counter = new Counter(redis)
router.put('/click', async ctx => {
counter.incr()
ctx.body = { 'counter': await counter.state() }
ctx.body = { 'count': await counter.state() }
});
router.get('/clicks', async ctx => {
ctx.body = { 'counter': await counter.state() }
ctx.body = { 'count': await counter.state() }
});
app.use(JSON({pretty: true}))