{"id":22059262,"url":"https://github.com/opentable/hapi-version-prereq","last_synced_at":"2025-03-23T17:13:28.165Z","repository":{"id":22578262,"uuid":"25919805","full_name":"opentable/hapi-version-prereq","owner":"opentable","description":"detects version info in the url/headers and populates the prereq object","archived":false,"fork":false,"pushed_at":"2017-06-30T15:41:34.000Z","size":9,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":26,"default_branch":"master","last_synced_at":"2024-05-14T00:26:37.567Z","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":null,"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-10-29T12:27:26.000Z","updated_at":"2019-04-11T17:14:36.000Z","dependencies_parsed_at":"2022-07-23T19:02:21.262Z","dependency_job_id":null,"html_url":"https://github.com/opentable/hapi-version-prereq","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fhapi-version-prereq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fhapi-version-prereq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fhapi-version-prereq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fhapi-version-prereq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opentable","download_url":"https://codeload.github.com/opentable/hapi-version-prereq/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:46.896Z","updated_at":"2025-03-23T17:13:28.128Z","avatar_url":"https://github.com/opentable.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#Hapi-version-prereq\n[![Build Status](https://travis-ci.org/opentable/hapi-version-prereq.png?branch=master)](https://travis-ci.org/opentable/hapi-version-prereq) [![NPM version](https://badge.fury.io/js/hapi-version-prereq.png)](http://badge.fury.io/js/hapi-version-prereq) ![Dependencies](https://david-dm.org/opentable/hapi-version-prereq.png)\n\nHapi plugin for automagically populating the version header on routes that support it. At OT we use a mix of url-versioning and header-versioning. In some cases our APIs need to support both. This module represents some shared code for our narrow use-case.\n\ninstallation:\n\n```npm install hapi-version-prereq```\n\nusage:\n\n```\nvar hapi = require(\"hapi\");\nvar joi = require(\"joi\");\n\nvar server = Hapi.createServer('127.0.0.1', 3000, {});\n\nserver.route([{\n  method: 'GET',\n  path: '/v1/my-url',\n  config: {\n    handler: function(request, reply){\n      reply(request.pre.version)\n    }\n  }\n},\n{\n  method: 'GET',\n  path: '/my-url',\n  config: {\n    handler: function(request, reply){\n      reply(request.pre.version)\n    },\n    validate: {\n      headers: {\n        accept: joi.string().regex(/application\\/vnd.myorg.mytype.v1\\+json/)\n      }\n    }\n  }\n}]);\n\nserver.pack.register([\n  {\n    plugin: require('hapi-version-prereq'),\n    options: {}\n  }], function(err){\n    if(err){\n      throw err;\n    }\n\n    server.start(function(){\n      server.log('server started');\n    });\n});\n\n```\n\n- `/v1/my-url =\u003e { version: 'v1', mode: 'url' }`\n- `/my-url =\u003e { version: 'v1', mode: 'header' }`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentable%2Fhapi-version-prereq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopentable%2Fhapi-version-prereq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentable%2Fhapi-version-prereq/lists"}