From ab0cbeeda8b06464b3d554601d00ef9f2513bf69 Mon Sep 17 00:00:00 2001 From: DEFSTREAM Date: Fri, 7 Apr 2017 09:50:50 -0700 Subject: [PATCH 1/2] including case insensitivy support --- api/index.js | 2 +- test/api-test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/index.js b/api/index.js index 4a95ef1..16b09d4 100644 --- a/api/index.js +++ b/api/index.js @@ -10,5 +10,5 @@ module.exports = { }; function kickable (it) { - return it == "it" ? true : false; + return it && it.toUpperCase() == "IT" ? true : false; } \ No newline at end of file diff --git a/test/api-test.js b/test/api-test.js index b513fa5..5979ab7 100644 --- a/test/api-test.js +++ b/test/api-test.js @@ -27,7 +27,7 @@ test("successful", (t) => { t.is(res.body, true) }); -test.skip("case sensitive", (t) => { +test("case sensitive", (t) => { const res = kick("IT") t.is(res.body, true) }); \ No newline at end of file From 3fe920bb9e48cd3ee9443a449a224f3ac67bcaea Mon Sep 17 00:00:00 2001 From: DEFSTREAM Date: Fri, 7 Apr 2017 09:56:48 -0700 Subject: [PATCH 2/2] including request logging --- index.js | 10 ++++++++-- package.json | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index b2977ec..651ec7d 100755 --- a/index.js +++ b/index.js @@ -6,10 +6,16 @@ const Koa = require('koa'); const route = require('koa-route'); -const api = require('./api') +const logger = require('koa-logger'); + +const api = require('./api'); const app = new Koa(); +const port = process.env.PORT || 3000; +app.use(logger()) app.use(route.get('/kick/:it', api.kick)); -app.listen(3000); +app.listen(port); + +console.log(`kickable now running on port ${port}`); \ No newline at end of file diff --git a/package.json b/package.json index aa80972..f6f7745 100644 --- a/package.json +++ b/package.json @@ -8,13 +8,14 @@ "test": "ava -v", "cover": "nyc npm run test", "report": "npm run codecov & npm run coveralls", - "codecov": "./node_modules/.bin/nyc report --reporter=lcov | ./node_modules/.bin/codecov -B $(date \"+%Y%m%d%H%M%S\")", + "codecov": "./node_modules/.bin/nyc report --reporter=lcov | ./node_modules/.bin/codecov -B $(date \"+%Y%m%d%H%M%S\")", "coveralls": "./node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls" }, "author": "", "license": "ISC", "dependencies": { "koa": "^2.2.0", + "koa-logger": "^2.0.1", "koa-route": "^3.2.0" }, "devDependencies": {