{"id":22059233,"url":"https://github.com/opentable/hapi-methods","last_synced_at":"2025-03-23T17:13:23.010Z","repository":{"id":20601120,"uuid":"23882056","full_name":"opentable/hapi-methods","owner":"opentable","description":"helper for registering cached server methods","archived":false,"fork":false,"pushed_at":"2016-04-08T11:32:35.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-03-02T15:18:07.586Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"juliangarnier/anime","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opentable.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-10T16:25:35.000Z","updated_at":"2019-04-11T17:12:57.000Z","dependencies_parsed_at":"2022-07-08T02:10:44.181Z","dependency_job_id":null,"html_url":"https://github.com/opentable/hapi-methods","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fhapi-methods","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fhapi-methods/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fhapi-methods/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fhapi-methods/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opentable","download_url":"https://codeload.github.com/opentable/hapi-methods/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245136405,"owners_count":20566588,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-30T17:27:41.627Z","updated_at":"2025-03-23T17:13:22.983Z","avatar_url":"https://github.com/opentable.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#hapi-methods\n[![Build Status](https://travis-ci.org/opentable/hapi-methods.png?branch=master)](https://travis-ci.org/opentable/hapi-methods) [![NPM version](https://badge.fury.io/js/hapi-methods.png)](http://badge.fury.io/js/hapi-methods) ![Dependencies](https://david-dm.org/opentable/hapi-methods.png)\n\n\nMy narrow helper for server-methods, use it, or don't. Assumes that you are caching your method results.\n\nBenefits:\n - does a request.log([\"cachemiss\"], ...) so you can track the hit/miss ratio\n - generates a sha1 key instead of stringifying the input args (useful if you have large input objects)\n - what more do you need?\n\n```\nvar catbox-redis = require(\"catbox-redis\");\nvar Hapi = require(\"hapi\");\nvar server = new Hapi.Server({\n  cache: {\n        engine: require(\"catbox-redis\"),\n        host: 127.0.0.1\n    }\n});\n\nserver.connection({ port: 3000 });\n\nvar methods = require(\"hapi-methods\");\nvar config = {\n  expiryInSeconds: 60\n};\n\nvar methods = {\n  add: function(a, b, next){\n    next(null, a+b);\n  }\n};\n\nmethods.register(server, config, methods);\n\nserver.route({\n    method: 'GET',\n    path: '/add/{one}/{two}'\n    handler: function(req, res){\n      req.server.methods.add(req.params.one, req.params.two, req, function(err, result){\n        if(err){\n          reply(err);\n        }\n\n        reply(result);\n      });\n    }\n});\n\nserver.start(function(){\n  console.log('server started...');\n});\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentable%2Fhapi-methods","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopentable%2Fhapi-methods","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentable%2Fhapi-methods/lists"}