MInimal API for counting clicks
Go to file
Jakub Sokołowski 1d115164f0
add exception for when there are no keys
2018-11-15 14:30:19 +01:00
src add exception for when there are no keys 2018-11-15 14:30:19 +01:00
test make it possible to stub the counter for tests, add more tests 2018-11-14 17:59:12 +01:00
.babelrc drop unused packages and stage-2 2018-10-17 10:08:25 -04:00
.gitignore add building of counter app with gulp 2018-10-16 16:04:08 -04:00
Dockerfile add npm scripts for building docker image 2018-10-17 10:24:16 -04:00
README.md change path to /clicks for all calls 2018-11-14 16:25:25 +01:00
gulpfile.js add jest for running tests 2018-11-14 17:18:44 +01:00
package.json remove global coverage thresholds 2018-11-14 18:00:43 +01:00

README.md

Description

This is a minimal API done using Koa and Redis for counting clicks.

It exposes just 2 calls:

  • 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

This app requires Redis, and assumes it's available at localhost:6379

Configuration

There are few environment variables you can set:

  • REDIS_HOST - Default: localhost
  • REDIS_PORT - Default: 6379
  • LISTEN_PORT - Default: 3000

Usage

For development use:

npm run start

For building use:

npm run build

To create the docker image use:

npm run image

To push the image use:

npm run push