add README
This commit is contained in:
parent
be5b1bdb86
commit
2a65270400
|
@ -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
|
||||
```
|
|
@ -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}))
|
||||
|
|
Loading…
Reference in New Issue