From a324047cd784ce55b21f23795ac3ab9926e13b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 14 Nov 2018 16:25:25 +0100 Subject: [PATCH] change path to /clicks for all calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- README.md | 5 +++-- src/app.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dc541b9..9678f6b 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,9 @@ 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. +* `PUT /clicks/:id` - Bumps the counter by 1 and returns current count for ID. +* `GET /clicks/:id` - Returns the JSON with clicks count for the ID. +* `GET /clicks` - Returns the JSON with all the clicks counts. # Requirements diff --git a/src/app.js b/src/app.js index 639335a..31438e6 100644 --- a/src/app.js +++ b/src/app.js @@ -15,7 +15,7 @@ const router = new Router() const redis = Redis.createClient(REDIS_PORT, REDIS_HOST) const counter = new Counter(redis) -router.put('/click/:id', async ctx => { +router.put('/clicks/:id', async ctx => { counter.incr(ctx.params.id) ctx.body = { [ctx.params.id]: await counter.state(ctx.params.id) } });