{"action":"created","comment":{"url":"https://api.github.com/repos/dial-once/node-phone-utils/pulls/comments/66246752","id":66246752,"diff_hunk":"@@ -0,0 +1,163 @@\n+require('dotenv').config();\n+var express = require('express');\n+var app = express();\n+var bodyParser = require('body-parser');\n+var errorHandler = require('api-error-handler');\n+//Take a list of numbers from a fixture\n+//var BIG_NUMBERS_LIST = require('../../fixtures/phone-numbers-big.json').phoneNumbers;\n+// numbers only in mock\n+var BIG_NUMBERS_LIST = ['+33892696992', '+3857811375206', '+16502821370', '+33644125380', '+33644125390'];\n+\n+var cacheManager = require('cache-manager');\n+// cache for six months\n+var TTL = 5778463;\n+/*seconds*/\n+\n+// Uncomment to use REDIS as cache store\n+/*\n+ var redisStore = require('cache-manager-redis');\n+ var redisCacheConfig = {\n+ store: redisStore,\n+ host: 'localhost', // default value\n+ port: 6379, // default value\n+ auth_pass: '',\n+ db: 0,\n+ ttl: TTL,\n+ promiseDependency: Promise\n+ };\n+ var cacheStore = cacheManager.multiCaching([cacheManager.caching(redisCacheConfig)]);\n+ */\n+\n+// comment if using another store\n+var cacheStore = cacheManager.multiCaching([cacheManager.caching({\n+  store: 'memory',\n+  max: 2 * BIG_NUMBERS_LIST.length,\n+  ttl: TTL\n+})]);\n+\n+var phoneUtilsBase = require('../../../lib');\n+\n+var DEFAULT_PORT = 3000;\n+app.use(bodyParser.json());\n+app.use(bodyParser.urlencoded({extended: true}));\n+\n+var winston = require('winston');\n+var LOG_LEVEL = 'debug';\n+winston.level = LOG_LEVEL;\n+\n+var winstonHlrLookupLogger = new winston.Logger({\n+  level: LOG_LEVEL,\n+  transports: [\n+    new (winston.transports.Console)()\n+  ]\n+});\n+\n+var phoneUtils = phoneUtilsBase.createInstance({logger: winstonHlrLookupLogger});\n+\n+var options = {\n+  provider: phoneUtils.getProviders().hlrLookups,\n+  logger: winstonHlrLookupLogger,\n+  callbackUrl: 'http: //localhost:' + DEFAULT_PORT + '/hlr/lookups',\n+  callbackIdQSParam: 'idx',\n+  middlewareSend: true, // override (default true) if you wish to do a res.send in some other middleware\n+  cache: cacheStore,\n+  lookupTimeout: 30,  //seconds\n+  resultCallback: function (err, results) {\n+    //a result was processed and available\n+    winstonHlrLookupLogger.info('resultCallback', err, results);\n+    return results;\n+  },\n+  doneCallback: function (err, results, reqId) {\n+    // do what you need when the entire lookup is done.\n+    winstonHlrLookupLogger.info('doneCallback', err, reqId, results);\n+    return results;\n+  }\n+};\n+\n+var utils = phoneUtils.getAsyncHlrLookup(options);\n+var client = utils.lookupClient;\n+var callbackMiddleware = utils.lookupMiddleware;\n+\n+var expressWinston = require('express-winston');\n+\n+app.use(expressWinston.logger({\n+  transports: [\n+    new winston.transports.Console({\n+      json: true,\n+      colorize: true,\n+      level: LOG_LEVEL\n+    })\n+  ]\n+}));\n+\n+app.get('/ping', function (req, res, next) {\n+  res.sendStatus(200).json({pong: Date.now()});\n+  next();\n+});\n+\n+app.post('/hlr/lookup', function (req, res, next) {\n+  var callbackUrl = req.body.callbackUrl;\n+\n+  if (callbackUrl) {\n+    winstonHlrLookupLogger.info('callbackUrl', callbackUrl);\n+\n+    client.hlrLookup(BIG_NUMBERS_LIST, callbackUrl)\n+    .then(function (numbers) {\n+      winstonHlrLookupLogger.debug('Numbers sent to hlr processing', numbers);\n+      res.json(numbers);\n+      return next();\n+    })\n+    .catch(next);\n+  } else {\n+    res.sendStatus(400);\n+    next();\n+  }\n+});\n+\n+app.post('/hlr/callback', callbackMiddleware, function (req, res, next) {\n+  // results passed in from callbackMiddleware\n+  winstonHlrLookupLogger.info('req.locals.lookup.done', {done: req.locals.lookup.done});\n+  var results = req.locals.lookup.results;\n+  winstonHlrLookupLogger.info('req.locals.lookup.results', {resultNum: results.length, results: results});\n+  next();\n+});\n+\n+app.use(expressWinston.errorLogger({\n+  transports: [\n+    new winston.transports.Console({\n+      json: true,\n+      colorize: true\n+    })\n+  ]\n+}));\n+\n+app.use(errorHandler());\n+\n+var server;\n+\n+module.exports.showCache = function showCache() {","path":"tests/integration/helpers/server.js","position":138,"original_position":138,"commit_id":"2edbb02efaea5eaa02d0c24b941794efa646747c","original_commit_id":"2edbb02efaea5eaa02d0c24b941794efa646747c","user":{"login":"jkernech","id":1616969,"avatar_url":"https://avatars.githubusercontent.com/u/1616969?v=3","gravatar_id":"","url":"https://api.github.com/users/jkernech","html_url":"https://github.com/jkernech","followers_url":"https://api.github.com/users/jkernech/followers","following_url":"https://api.github.com/users/jkernech/following{/other_user}","gists_url":"https://api.github.com/users/jkernech/gists{/gist_id}","starred_url":"https://api.github.com/users/jkernech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkernech/subscriptions","organizations_url":"https://api.github.com/users/jkernech/orgs","repos_url":"https://api.github.com/users/jkernech/repos","events_url":"https://api.github.com/users/jkernech/events{/privacy}","received_events_url":"https://api.github.com/users/jkernech/received_events","type":"User","site_admin":false},"body":"What is the usage of this method ? It is identical to `getCache` below.","created_at":"2016-06-08T12:38:35Z","updated_at":"2016-06-08T12:38:35Z","html_url":"https://github.com/dial-once/node-phone-utils/pull/8#discussion_r66246752","pull_request_url":"https://api.github.com/repos/dial-once/node-phone-utils/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/dial-once/node-phone-utils/pulls/comments/66246752"},"html":{"href":"https://github.com/dial-once/node-phone-utils/pull/8#discussion_r66246752"},"pull_request":{"href":"https://api.github.com/repos/dial-once/node-phone-utils/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/dial-once/node-phone-utils/pulls/8","id":73034191,"html_url":"https://github.com/dial-once/node-phone-utils/pull/8","diff_url":"https://github.com/dial-once/node-phone-utils/pull/8.diff","patch_url":"https://github.com/dial-once/node-phone-utils/pull/8.patch","issue_url":"https://api.github.com/repos/dial-once/node-phone-utils/issues/8","number":8,"state":"open","locked":false,"title":"Add middleware for async hlr lookup of bulk phone numbers.","user":{"login":"mrister","id":1213258,"avatar_url":"https://avatars.githubusercontent.com/u/1213258?v=3","gravatar_id":"","url":"https://api.github.com/users/mrister","html_url":"https://github.com/mrister","followers_url":"https://api.github.com/users/mrister/followers","following_url":"https://api.github.com/users/mrister/following{/other_user}","gists_url":"https://api.github.com/users/mrister/gists{/gist_id}","starred_url":"https://api.github.com/users/mrister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrister/subscriptions","organizations_url":"https://api.github.com/users/mrister/orgs","repos_url":"https://api.github.com/users/mrister/repos","events_url":"https://api.github.com/users/mrister/events{/privacy}","received_events_url":"https://api.github.com/users/mrister/received_events","type":"User","site_admin":false},"body":"NOTE: Do not merge! Needs tests.\r\n\r\nNOTE: It would be good to test more thoroughly so let me know if you need instructions or help.\r\nNOTE: There should be no version braking changes here.\r\n \r\nAdd middleware that processes lookup results\r\nAdd hlr lookup client for issuing bulk hlr lookup requests\r\nAdd dummy data, test data, for easier testing and development\r\nAdd ability to cache and reuse results to aviod unnecessary lookups\r\nAdd timer cleanup for async requests and document new modules\r\nAdd an example server implementation that showcases how to use the middleware","created_at":"2016-06-08T12:04:01Z","updated_at":"2016-06-08T12:38:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fa144fb7484a915300957ecdcb9dd32fa8463e07","assignee":{"login":"PuKoren","id":4202557,"avatar_url":"https://avatars.githubusercontent.com/u/4202557?v=3","gravatar_id":"","url":"https://api.github.com/users/PuKoren","html_url":"https://github.com/PuKoren","followers_url":"https://api.github.com/users/PuKoren/followers","following_url":"https://api.github.com/users/PuKoren/following{/other_user}","gists_url":"https://api.github.com/users/PuKoren/gists{/gist_id}","starred_url":"https://api.github.com/users/PuKoren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PuKoren/subscriptions","organizations_url":"https://api.github.com/users/PuKoren/orgs","repos_url":"https://api.github.com/users/PuKoren/repos","events_url":"https://api.github.com/users/PuKoren/events{/privacy}","received_events_url":"https://api.github.com/users/PuKoren/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/dial-once/node-phone-utils/pulls/8/commits","review_comments_url":"https://api.github.com/repos/dial-once/node-phone-utils/pulls/8/comments","review_comment_url":"https://api.github.com/repos/dial-once/node-phone-utils/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dial-once/node-phone-utils/issues/8/comments","statuses_url":"https://api.github.com/repos/dial-once/node-phone-utils/statuses/2edbb02efaea5eaa02d0c24b941794efa646747c","head":{"label":"dial-once:feature/hlr-lookup-middleware","ref":"feature/hlr-lookup-middleware","sha":"2edbb02efaea5eaa02d0c24b941794efa646747c","user":{"login":"dial-once","id":9366834,"avatar_url":"https://avatars.githubusercontent.com/u/9366834?v=3","gravatar_id":"","url":"https://api.github.com/users/dial-once","html_url":"https://github.com/dial-once","followers_url":"https://api.github.com/users/dial-once/followers","following_url":"https://api.github.com/users/dial-once/following{/other_user}","gists_url":"https://api.github.com/users/dial-once/gists{/gist_id}","starred_url":"https://api.github.com/users/dial-once/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dial-once/subscriptions","organizations_url":"https://api.github.com/users/dial-once/orgs","repos_url":"https://api.github.com/users/dial-once/repos","events_url":"https://api.github.com/users/dial-once/events{/privacy}","received_events_url":"https://api.github.com/users/dial-once/received_events","type":"Organization","site_admin":false},"repo":{"id":49943028,"name":"node-phone-utils","full_name":"dial-once/node-phone-utils","owner":{"login":"dial-once","id":9366834,"avatar_url":"https://avatars.githubusercontent.com/u/9366834?v=3","gravatar_id":"","url":"https://api.github.com/users/dial-once","html_url":"https://github.com/dial-once","followers_url":"https://api.github.com/users/dial-once/followers","following_url":"https://api.github.com/users/dial-once/following{/other_user}","gists_url":"https://api.github.com/users/dial-once/gists{/gist_id}","starred_url":"https://api.github.com/users/dial-once/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dial-once/subscriptions","organizations_url":"https://api.github.com/users/dial-once/orgs","repos_url":"https://api.github.com/users/dial-once/repos","events_url":"https://api.github.com/users/dial-once/events{/privacy}","received_events_url":"https://api.github.com/users/dial-once/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dial-once/node-phone-utils","description":"","fork":false,"url":"https://api.github.com/repos/dial-once/node-phone-utils","forks_url":"https://api.github.com/repos/dial-once/node-phone-utils/forks","keys_url":"https://api.github.com/repos/dial-once/node-phone-utils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dial-once/node-phone-utils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dial-once/node-phone-utils/teams","hooks_url":"https://api.github.com/repos/dial-once/node-phone-utils/hooks","issue_events_url":"https://api.github.com/repos/dial-once/node-phone-utils/issues/events{/number}","events_url":"https://api.github.com/repos/dial-once/node-phone-utils/events","assignees_url":"https://api.github.com/repos/dial-once/node-phone-utils/assignees{/user}","branches_url":"https://api.github.com/repos/dial-once/node-phone-utils/branches{/branch}","tags_url":"https://api.github.com/repos/dial-once/node-phone-utils/tags","blobs_url":"https://api.github.com/repos/dial-once/node-phone-utils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dial-once/node-phone-utils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dial-once/node-phone-utils/git/refs{/sha}","trees_url":"https://api.github.com/repos/dial-once/node-phone-utils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dial-once/node-phone-utils/statuses/{sha}","languages_url":"https://api.github.com/repos/dial-once/node-phone-utils/languages","stargazers_url":"https://api.github.com/repos/dial-once/node-phone-utils/stargazers","contributors_url":"https://api.github.com/repos/dial-once/node-phone-utils/contributors","subscribers_url":"https://api.github.com/repos/dial-once/node-phone-utils/subscribers","subscription_url":"https://api.github.com/repos/dial-once/node-phone-utils/subscription","commits_url":"https://api.github.com/repos/dial-once/node-phone-utils/commits{/sha}","git_commits_url":"https://api.github.com/repos/dial-once/node-phone-utils/git/commits{/sha}","comments_url":"https://api.github.com/repos/dial-once/node-phone-utils/comments{/number}","issue_comment_url":"https://api.github.com/repos/dial-once/node-phone-utils/issues/comments{/number}","contents_url":"https://api.github.com/repos/dial-once/node-phone-utils/contents/{+path}","compare_url":"https://api.github.com/repos/dial-once/node-phone-utils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dial-once/node-phone-utils/merges","archive_url":"https://api.github.com/repos/dial-once/node-phone-utils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dial-once/node-phone-utils/downloads","issues_url":"https://api.github.com/repos/dial-once/node-phone-utils/issues{/number}","pulls_url":"https://api.github.com/repos/dial-once/node-phone-utils/pulls{/number}","milestones_url":"https://api.github.com/repos/dial-once/node-phone-utils/milestones{/number}","notifications_url":"https://api.github.com/repos/dial-once/node-phone-utils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dial-once/node-phone-utils/labels{/name}","releases_url":"https://api.github.com/repos/dial-once/node-phone-utils/releases{/id}","deployments_url":"https://api.github.com/repos/dial-once/node-phone-utils/deployments","created_at":"2016-01-19T09:54:00Z","updated_at":"2016-04-17T12:24:01Z","pushed_at":"2016-06-08T12:04:01Z","git_url":"git://github.com/dial-once/node-phone-utils.git","ssh_url":"git@github.com:dial-once/node-phone-utils.git","clone_url":"https://github.com/dial-once/node-phone-utils.git","svn_url":"https://github.com/dial-once/node-phone-utils","homepage":null,"size":150,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":3,"default_branch":"develop"}},"base":{"label":"dial-once:develop","ref":"develop","sha":"92f9b0429ecc124c8f0ada337505b953fa27677f","user":{"login":"dial-once","id":9366834,"avatar_url":"https://avatars.githubusercontent.com/u/9366834?v=3","gravatar_id":"","url":"https://api.github.com/users/dial-once","html_url":"https://github.com/dial-once","followers_url":"https://api.github.com/users/dial-once/followers","following_url":"https://api.github.com/users/dial-once/following{/other_user}","gists_url":"https://api.github.com/users/dial-once/gists{/gist_id}","starred_url":"https://api.github.com/users/dial-once/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dial-once/subscriptions","organizations_url":"https://api.github.com/users/dial-once/orgs","repos_url":"https://api.github.com/users/dial-once/repos","events_url":"https://api.github.com/users/dial-once/events{/privacy}","received_events_url":"https://api.github.com/users/dial-once/received_events","type":"Organization","site_admin":false},"repo":{"id":49943028,"name":"node-phone-utils","full_name":"dial-once/node-phone-utils","owner":{"login":"dial-once","id":9366834,"avatar_url":"https://avatars.githubusercontent.com/u/9366834?v=3","gravatar_id":"","url":"https://api.github.com/users/dial-once","html_url":"https://github.com/dial-once","followers_url":"https://api.github.com/users/dial-once/followers","following_url":"https://api.github.com/users/dial-once/following{/other_user}","gists_url":"https://api.github.com/users/dial-once/gists{/gist_id}","starred_url":"https://api.github.com/users/dial-once/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dial-once/subscriptions","organizations_url":"https://api.github.com/users/dial-once/orgs","repos_url":"https://api.github.com/users/dial-once/repos","events_url":"https://api.github.com/users/dial-once/events{/privacy}","received_events_url":"https://api.github.com/users/dial-once/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dial-once/node-phone-utils","description":"","fork":false,"url":"https://api.github.com/repos/dial-once/node-phone-utils","forks_url":"https://api.github.com/repos/dial-once/node-phone-utils/forks","keys_url":"https://api.github.com/repos/dial-once/node-phone-utils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dial-once/node-phone-utils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dial-once/node-phone-utils/teams","hooks_url":"https://api.github.com/repos/dial-once/node-phone-utils/hooks","issue_events_url":"https://api.github.com/repos/dial-once/node-phone-utils/issues/events{/number}","events_url":"https://api.github.com/repos/dial-once/node-phone-utils/events","assignees_url":"https://api.github.com/repos/dial-once/node-phone-utils/assignees{/user}","branches_url":"https://api.github.com/repos/dial-once/node-phone-utils/branches{/branch}","tags_url":"https://api.github.com/repos/dial-once/node-phone-utils/tags","blobs_url":"https://api.github.com/repos/dial-once/node-phone-utils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dial-once/node-phone-utils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dial-once/node-phone-utils/git/refs{/sha}","trees_url":"https://api.github.com/repos/dial-once/node-phone-utils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dial-once/node-phone-utils/statuses/{sha}","languages_url":"https://api.github.com/repos/dial-once/node-phone-utils/languages","stargazers_url":"https://api.github.com/repos/dial-once/node-phone-utils/stargazers","contributors_url":"https://api.github.com/repos/dial-once/node-phone-utils/contributors","subscribers_url":"https://api.github.com/repos/dial-once/node-phone-utils/subscribers","subscription_url":"https://api.github.com/repos/dial-once/node-phone-utils/subscription","commits_url":"https://api.github.com/repos/dial-once/node-phone-utils/commits{/sha}","git_commits_url":"https://api.github.com/repos/dial-once/node-phone-utils/git/commits{/sha}","comments_url":"https://api.github.com/repos/dial-once/node-phone-utils/comments{/number}","issue_comment_url":"https://api.github.com/repos/dial-once/node-phone-utils/issues/comments{/number}","contents_url":"https://api.github.com/repos/dial-once/node-phone-utils/contents/{+path}","compare_url":"https://api.github.com/repos/dial-once/node-phone-utils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dial-once/node-phone-utils/merges","archive_url":"https://api.github.com/repos/dial-once/node-phone-utils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dial-once/node-phone-utils/downloads","issues_url":"https://api.github.com/repos/dial-once/node-phone-utils/issues{/number}","pulls_url":"https://api.github.com/repos/dial-once/node-phone-utils/pulls{/number}","milestones_url":"https://api.github.com/repos/dial-once/node-phone-utils/milestones{/number}","notifications_url":"https://api.github.com/repos/dial-once/node-phone-utils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dial-once/node-phone-utils/labels{/name}","releases_url":"https://api.github.com/repos/dial-once/node-phone-utils/releases{/id}","deployments_url":"https://api.github.com/repos/dial-once/node-phone-utils/deployments","created_at":"2016-01-19T09:54:00Z","updated_at":"2016-04-17T12:24:01Z","pushed_at":"2016-06-08T12:04:01Z","git_url":"git://github.com/dial-once/node-phone-utils.git","ssh_url":"git@github.com:dial-once/node-phone-utils.git","clone_url":"https://github.com/dial-once/node-phone-utils.git","svn_url":"https://github.com/dial-once/node-phone-utils","homepage":null,"size":150,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":3,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/dial-once/node-phone-utils/pulls/8"},"html":{"href":"https://github.com/dial-once/node-phone-utils/pull/8"},"issue":{"href":"https://api.github.com/repos/dial-once/node-phone-utils/issues/8"},"comments":{"href":"https://api.github.com/repos/dial-once/node-phone-utils/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/dial-once/node-phone-utils/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/dial-once/node-phone-utils/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dial-once/node-phone-utils/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/dial-once/node-phone-utils/statuses/2edbb02efaea5eaa02d0c24b941794efa646747c"}}}}
{"actor":{"display_login":"jkernech"}}