{"_id":"@acruzjr/express-routes-versioning","_rev":"2-cb9a998162f83c42c1cfeec49d12170d","name":"@acruzjr/express-routes-versioning","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@acruzjr/express-routes-versioning","version":"1.0.0","description":"A simple node.js module that provides routes versioning for express. You can use middleware easier using a middlewares vector.","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"prepare":"npm run build","prepublishOnly":"npm test","version":"git add -A src","postversion":"git push && git push --tags","build":"tsc","test":"tsc ; mocha"},"repository":{"type":"git","url":"git+https://github.com/juninhocruzg3/express-routes-versioning.git"},"keywords":["routes","api","express","express","version","versioning","restiful","handler"],"author":{"name":"juninhocruzg3"},"license":"MIT","bugs":{"url":"https://github.com/juninhocruzg3/express-routes-versioning/issues"},"homepage":"https://github.com/juninhocruzg3/express-routes-versioning","devDependencies":{"@types/express":"^4.17.6","coveralls":"^3.1.0","express":"^4.17.1","istanbul":"^0.4.5","js-yaml":">=3.13.1","mocha":"^8.0.1","mocha-lcov-reporter":"^1.3.0","sinon":"^9.0.2","typescript":"^3.9.6"},"gitHead":"32cc0f1146cfc33fc6589f5690c216d11b1a0832","_id":"@acruzjr/express-routes-versioning@1.0.0","_nodeVersion":"12.16.3","_npmVersion":"6.14.4","dist":{"integrity":"sha512-9DB+usHyq2YQ1gPQcCvftlltamvWS4LBgRHjrz94VoqylJdlt9CJS+UIx3YJX+K/sxww9/jh3UfTY3cb1ZPGNA==","shasum":"0fa7b07b2d3b852f5b9e4851713236ae66ae4322","tarball":"https://registry.npmjs.org/@acruzjr/express-routes-versioning/-/express-routes-versioning-1.0.0.tgz","fileCount":6,"unpackedSize":13279,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/5KZCRA9TVsSAnZWagAAk/AP/1qMdahKb+YeLp/OvoJ4\ndXm3gLYtTXuAuz8mV4yRnv6wRt0VdxVIS5zfgAm7mLjooxOaXyJUCr/uhzcn\nMzLR3ZW+Flna4gdOJDcU7AMqBHMLyGZa3IcssTOf+WDfQYl/TKj+3GEUQz3o\nua4chI2VaBKAeERNv9GVID0cl17NOXypj/orcPL9joyyrVyUjQROiFA2aVNa\n57UdbqzZD7sWdogS+K22iya9yuR8jjUpr2kfyJIhTI3l0yeHpouuy2C4ap8z\nrcR/twevf/G+2Vu/K4zQr/KOftyOyJU9KqNkCbjoJMeOLh7GZOODWw/mzz13\nXZBYt2eKGyzr3Ml95NoRYg+J2M0hhLnsdxNra2OM8kTFiIDM5tu0eWBZiV6l\nVwy48sB9gb3J6gYSHX3WCA9Gp0Gp3I2pGNn/GYOhXsvS8VkqjNzmNkaB2mvU\nyEu0fqGQzkAahegw8D2F+aH0Lp1xZEGRdVN/KVhw9sw4wKlW+D10ZnS95E7r\nHM2Vs0unzGZKbGPKfwT+Dp0uEN9eh2CO4OV3XPfTfuwZxa1+XFwqIIyEDgxR\nbAD+1YRKV5287qcJEVwBAQNyAZEbd83boTzXk+UP1jnkrOYQDnTLuYhPcSGv\nAwohnDcewkn1CTDrmiQidGH8v9FZTyz456jEVtTjXacwEi/zkuyTP3plJV3m\n6MVm\r\n=9ar+\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDSBwKjnEfMDSPl92AAYarWgRfqZjI15bDPUfDvXbTZdAIhAN75cCJ+O97pjC1Ys+RWDXW7+moPe5hw0UmdEAkI6Myh"}]},"maintainers":[{"name":"acruzjr","email":"antoniojr.ufam@gmail.com"}],"_npmUser":{"name":"acruzjr","email":"antoniojr.ufam@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/express-routes-versioning_1.0.0_1593807512447_0.33095498143429536"},"_hasShrinkwrap":false},"1.0.2":{"name":"@acruzjr/express-routes-versioning","version":"1.0.2","description":"A simple node.js module that provides routes versioning for express. You can use middleware easier using a middlewares vector.","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"prepare":"npm run build","prepublishOnly":"npm test","version":"git add -A src","postversion":"git push && git push --tags","build":"tsc","test":"tsc ; mocha"},"repository":{"type":"git","url":"git+https://github.com/juninhocruzg3/express-routes-versioning.git"},"keywords":["routes","api","express","express","version","versioning","restiful","handler"],"author":{"name":"juninhocruzg3"},"license":"MIT","bugs":{"url":"https://github.com/juninhocruzg3/express-routes-versioning/issues"},"homepage":"https://github.com/juninhocruzg3/express-routes-versioning","devDependencies":{"@types/express":"^4.17.13","coveralls":"^3.1.1","express":"^4.17.3","istanbul":"^0.4.5","js-yaml":"^4.1.0","mocha":"^9.2.1","mocha-lcov-reporter":"^1.3.0","sinon":"^13.0.1","typescript":"^4.5.5"},"gitHead":"06e0431017236c8c1e15627b8f4de965fb0d1964","_id":"@acruzjr/express-routes-versioning@1.0.2","_nodeVersion":"16.13.1","_npmVersion":"8.4.1","dist":{"integrity":"sha512-MZO7XdSUtk1nrHGh3wiIsodQ+gBtqtnm7G/3aT2uqKMJvQwtST7Zfgfe6+jGSD9hw/DgksVj2Vu5hNOwZvqMyQ==","shasum":"e0e0c0fdf40c7cdc715749b34c71b1263792c001","tarball":"https://registry.npmjs.org/@acruzjr/express-routes-versioning/-/express-routes-versioning-1.0.2.tgz","fileCount":6,"unpackedSize":13320,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiGs3hACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpnhQ/+NI7IGZy0dep7PnELgNX0b6v3+5ULSB2Ere2FUJDA6ZtT6eVx\r\nOZqU/pF49K3c7VZnEA+YB43GM7Xs/BswTkGp7w+xfLJnNzrHjXmkpLeRp9uF\r\nLgwBk727x2RSLN/4UvKGr5ufl7rX/YXokfo4IRyRQsZUY8nMKfvEKKHm8adC\r\nTtxyB+XlNFUzQtOBV+OuEvAT4O3TqVv9kIbPO9Z57vmUalKLxKv02BbmAX1y\r\n4m4eyRmPXJk23LY0vKhA3fOqeIz+VEWbEH8nDflGznuxvEk608uqCnZ93Q/S\r\nttBFyOddTeXxsZRCwW8vTsZ9dLgkC/HUieXwOrrd/6UvWsgA52cvKex/3Gxy\r\nZEDzgZp/CkgUMTl7Q/qUDja79XOr91FcaMSGUdk8f+iBusL6mKr5XIY7B2gt\r\nfaRKe5a68EeYdOKoNE6rBY6+mDroyNeYT7YmhV++qIWv7Ctmp1Pp94YKYpKh\r\ne3RLulPrB/bvwdHSp6B78vtVW0YZmodFyFEDjkvq8dUeQSzf6GuJY9DHpJ+g\r\nn2fByLqwCLr99SnsIsTzhMRPOOZsofgJE80Lu+GRmzW55AOjkNQFp6qgpvQJ\r\n2vgAUjBHb2vrHhnzvhXFtJmKnHu1/9TgrVxqxkQUVTG59bBjl438O0YwDeyC\r\nBuOVAKPTN+pXdzhIaf4d8Bq5sOKyWmuJrdk=\r\n=rhma\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAC+LyMREhDnhjRXC0cLUnwSeVb18ImWNh9ShqfKKGpjAiB7ySzJ7l0eGw+WDZI1XyCtBGUrDcmRscSfbBcoh74kqQ=="}]},"_npmUser":{"name":"acruzjr","email":"antoniojr.ufam@gmail.com"},"directories":{},"maintainers":[{"name":"acruzjr","email":"antoniojr.ufam@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/express-routes-versioning_1.0.2_1645923809787_0.7778099554172031"},"_hasShrinkwrap":false}},"time":{"created":"2020-07-03T20:18:32.418Z","1.0.0":"2020-07-03T20:18:32.567Z","modified":"2022-04-04T11:16:31.891Z","1.0.2":"2022-02-27T01:03:29.952Z"},"maintainers":[{"name":"acruzjr","email":"antoniojr.ufam@gmail.com"}],"description":"A simple node.js module that provides routes versioning for express. You can use middleware easier using a middlewares vector.","homepage":"https://github.com/juninhocruzg3/express-routes-versioning","keywords":["routes","api","express","express","version","versioning","restiful","handler"],"repository":{"type":"git","url":"git+https://github.com/juninhocruzg3/express-routes-versioning.git"},"author":{"name":"juninhocruzg3"},"bugs":{"url":"https://github.com/juninhocruzg3/express-routes-versioning/issues"},"license":"MIT","readme":"# Express routes versioning\n\n[![Build Status](https://travis-ci.org/juninhocruzg3/express-routes-versioning.svg?branch=master)](https://travis-ci.org/juninhocruzg3/express-routes-versioning)\n[![npm version](https://badge.fury.io/js/%40acruzjr%2Fexpress-routes-versioning.svg)](https://badge.fury.io/js/%40acruzjr%2Fexpress-routes-versioning)\n\nA simple node.js module that provides routes versioning for express. You can use middleware easier using a middlewares vector.\n\n## Install\n\n`npm install @acruzjr/express-routes-versioning`\n\n## Usage\n\nFollows semver versioning format. Supports '^, ~' symbols for matching version numbers.\n\n```js\nvar app = require(\"express\")();\nvar { routesVersioning } = require(\"@acruzjr/express-routes-versioning\");\n\napp.get(\n  \"/test\",\n  routesVersioning([\n    { version: \"1.0.0\", handler: respondV1 },\n    { version: \"2.2.9\", handler: [respondV2] },\n    { version: \"2.5.0\", handler: [anyMiddleware, respondV3] },\n  ])\n);\n\n//curl -s -H 'accept-version: 1.0.0' localhost:3000/test\n// version 1.0.0 or 1.0 or 1 !\nfunction respondV1(req, res, next) {\n  res.status(200).send(\"ok v1\");\n}\n\n//curl -s -H 'accept-version: ~2.2.0' localhost:3000/test\n//curl -s -H 'accept-version: 2.2.9' localhost:3000/test\n//Anything from 2.2.0 to 2.4.9\nfunction respondV2(req, res, next) {\n  res.status(200).send(\"ok v2\");\n}\n\n//curl -s -H 'accept-version: ^2.2.0' localhost:3000/test\n//curl -s -H 'accept-version: 2.5.0' localhost:3000/test\n//curl -s -H 'accept-version: 3.0.0' localhost:3000/test\nfunction anyMiddleware(req, res, next) {\n  return next();\n}\nfunction respondV3(req, res, next) {\n  res.status(200).send(\"ok v3\");\n}\n\napp.listen(3000);\n```\n\n**API**\n\n`routesVersioning(versions)`\n\n**versions** - array, containing VersionHandler list.\n\n```\nVersionHandler {\n    version: string;\n    handler: RequestHandler[] | RequestHandler;\n}\n```\n\n**version** - string, version in semver format as key\n\n**handler** - RequestHandler[] or RequestHandler - function(s) callback (connect middleware format) to invoke when the request matches the version as value.\n\n**How version is determined for each request ?**\n\nDefault behaviour is to use `accept-version` headers from the client.\n\n**How versions are matched ?**\n\nsemver versioning format is used to match version, supports ^,~ symbols on the request headers.\n\n## Examples\n\nExamples are available [here](https://github.com/juninhocruzg3/express-routes-versioning/tree/master/examples)\n\n## Test\n\n`npm test`\n","readmeFilename":"README.md"}