{"_id":"hapi-demo","_rev":"37-10f0c18dde8c97384c2d6e1db3a47787","name":"hapi-demo","dist-tags":{"latest":"0.0.5"},"versions":{"0.0.2":{"name":"hapi-demo","version":"0.0.2","keywords":["hapi","demo","handler","test-handler","hapi-plugin"],"author":{"name":"blogfoster engineering team"},"license":"ISC","_id":"hapi-demo@0.0.2","maintainers":[{"name":"blogfoster","email":"npm@blogfoster.com"}],"homepage":"https://github.com/blogfoster/hapi-demo#readme","bugs":{"url":"https://github.com/blogfoster/hapi-demo/issues"},"dist":{"shasum":"ae7a485feb6a656d50a8d9c6131e3e1b63c7ab59","tarball":"https://registry.npmjs.org/hapi-demo/-/hapi-demo-0.0.2.tgz","integrity":"sha512-2JpaZq1Id1sngJtsrv16bbWqhnRo3u5cA/vLtBoOWVp3qSeA6mEDfyzugmEXk1w/zkdkX/C3MWv4S66IFYSH4g==","signatures":[{"sig":"MEUCIQDEZ7HwABPVRSnj4FTdokpVWOonoIXyF6QsKgJillYtJAIgGk/cDd6cjjpetJ2UIQB4SjDmhP8R7ucQQx5qmP8LeKA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"dist/index.js","_from":".","files":["dist"],"_shasum":"ae7a485feb6a656d50a8d9c6131e3e1b63c7ab59","gitHead":"4fc1ce3475dfd523fbcc76901566caf9a90a3dcd","scripts":{"test":"NODE_ENV=test mocha","build":"rm -rf ./dist && babel -d ./dist ./source -s","eslint":"eslint .","prepublish":"npm run build","test:coverage":"rm -rf ./coverage && NODE_ENV=test babel-node node_modules/.bin/isparta cover --report html node_modules/.bin/_mocha"},"_npmUser":{"name":"blogfoster","email":"npm@blogfoster.com"},"repository":{"url":"git+https://github.com/blogfoster/hapi-demo.git","type":"git"},"_npmVersion":"3.8.6","description":"hapi plugin to configure demo handlers","directories":{},"_nodeVersion":"5.12.0","dependencies":{"joi":"^8.4.2"},"devDependencies":{"hapi":"^13.5.0","mocha":"^2.5.3","eslint":"^2.13.1","isparta":"^4.0.0","babel-cli":"^6.10.1","babel-core":"^6.10.4","babel-preset-es2015":"^6.9.0","babel-preset-stage-0":"^6.5.0","eslint-config-blogfoster":"^1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/hapi-demo-0.0.2.tgz_1467966957257_0.3076797779649496","host":"packages-16-east.internal.npmjs.com"}},"0.0.5":{"name":"hapi-demo","version":"0.0.5","keywords":["hapi","demo","handler","test-handler","hapi-plugin"],"author":{"name":"blogfoster engineering team"},"license":"ISC","_id":"hapi-demo@0.0.5","maintainers":[{"name":"dominicumbeer","email":"npm@blogfoster.com"},{"name":"alexanderbeletsky","email":"alexander.beletsky@gmail.com"},{"name":"vendura","email":"npm@blogfoster.com"},{"name":"anton-syrovatka","email":"syrovatka.anton@gmail.com"},{"name":"simon.staib","email":"simon.staib@blogfoster.com"},{"name":"gabriel-r","email":"gr.npmjs@timbru.com"},{"name":"pewlowz","email":"tormen.rassmann@gmail.com"},{"name":"eneax","email":"eneaxharja@gmail.com"}],"homepage":"https://github.com/blogfoster/hapi-demo#readme","bugs":{"url":"https://github.com/blogfoster/hapi-demo/issues"},"dist":{"shasum":"a17d3937e4d1a7454bc66c3c97fda39d08f31549","tarball":"https://registry.npmjs.org/hapi-demo/-/hapi-demo-0.0.5.tgz","fileCount":5,"integrity":"sha512-UsuUF4b1tpPu9y2xfN/gdIk6PSOaituH6VJLQNGg/jOhcKgeig/pb5UQAeIXenykz95KhWfnYAM9I5Lq3N4fng==","signatures":[{"sig":"MEQCIFJqWJfUHOuZu0qrtvXW2KPuTod6Bg8piBy7EU7/gLbzAiBZflgNmMrbfqV+Bfwu3zSDn0VsiNaOsKRImVjZgbsLXg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10258,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg8WWHCRA9TVsSAnZWagAAgXsP/A9KeFDzDhV7EPb3Ldfm\n//ug8ePt5gmDWohca6D4c35JYmJ8oQXooCoQ0VvATFL/EKYz2pjFSvuxxWMi\n1evxqrFcTmy8AwvXlRcUOFLg8KskZbjP4QKROc6vsaSDXKL3RIwRf0taHsMc\nt/raHXavC9M1+UGWquTaMlLi0W9NfNGdA1BZ1pbYq8qS+F79SoXxMzIMEdR/\nSMldAmtPTtM6Qk7JoD5Zw1NzdDV/XXmlWHqgzoy5t9ca5tka57zosL3y5vtM\nO0tZQsW69NQvuxn/we0G3vuxp9dA17M1YPqMnlL3N3JabUlM6lXekQu3OEgV\nZ3xjg/qKuWS1o9sFe6DnhNwPQIjP/g3sOy4GKk5BRRkqBBRLXFAj0smYUtgf\nBiDQm9sZq/BT1MUrSAOkLIfI7WaZURUcjuaJjPv9QdhACnHIhs9/NVj4rJtM\nFr2QIJoLb0FPATNCPE58qopOKXWhZ7E+E2tWLBLVPdYeWkgHXpyLqjfbL8LC\nnzmuqXzTWe7vA9G4jglzs44kcHx2bhYEOZ9ieghrUFpHd+M7lCSoUC0UDXep\niUXu1KZZiMrLg1cgjvUYPJ/DPv7X78h/sezO0KPsT3hRIXyDUQwN79Ca1r2t\nz/9nj0x8ii80uaJZ5s+8V+EezLm7hFuJhUdsj+4BHdJX5BMGKcp5Irrfg+Rs\npHVb\r\n=I3RE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","gitHead":"af5acf8ce1e9b607e6071aeacbb49f365bb21956","scripts":{"fix":"npx eslint . --fix","test":"NODE_ENV=test mocha","build":"rm -rf ./dist && babel -d ./dist ./source -s","check":"eslint .","prepublish":"npm run build","test:coverage":"rm -rf ./coverage && NODE_ENV=test babel-node node_modules/.bin/isparta cover --report html node_modules/.bin/_mocha"},"_npmUser":{"name":"vendura","email":"npm@blogfoster.com"},"repository":{"url":"git+https://github.com/blogfoster/hapi-demo.git","type":"git"},"_npmVersion":"6.13.4","description":"hapi plugin to configure demo handlers","directories":{},"_nodeVersion":"8.17.0","dependencies":{"joi":"^8.4.2"},"_hasShrinkwrap":false,"devDependencies":{"hapi":"^13.5.0","mocha":"^2.5.3","eslint":"^5.3.0","isparta":"^4.0.0","babel-cli":"^6.10.1","babel-core":"^6.10.4","babel-preset-es2015":"^6.9.0","babel-preset-stage-0":"^6.5.0","eslint-config-blogfoster":"^1.11.3"},"_npmOperationalInternal":{"tmp":"tmp/hapi-demo_0.0.5_1626432903174_0.8275175070115963","host":"s3://npm-registry-packages"}}},"time":{"created":"2016-07-08T08:36:00.050Z","modified":"2025-12-03T15:48:11.964Z","0.0.2":"2016-07-08T08:36:00.050Z","0.0.5":"2021-07-16T10:55:03.414Z"},"bugs":{"url":"https://github.com/blogfoster/hapi-demo/issues"},"author":{"name":"blogfoster engineering team"},"license":"ISC","homepage":"https://github.com/blogfoster/hapi-demo#readme","keywords":["hapi","demo","handler","test-handler","hapi-plugin"],"repository":{"url":"git+https://github.com/blogfoster/hapi-demo.git","type":"git"},"description":"hapi plugin to configure demo handlers","maintainers":[{"email":"simon.staib@netzpulsen.com","name":"simon.staib"}],"readme":"# hapi-demo [![Build Status](https://travis-ci.org/blogfoster/hapi-demo.svg?branch=master)](https://travis-ci.org/blogfoster/hapi-demo)\n\nThis Repo is a Hapi plugin, that adds the possibility to define demo handlers.\n\nThe demo handler will be called instead of the original handler, if certain conditions are met.\n\nA possible use-case is to setup routes with demo data, but without adding\nadditional code into the existing code-base.\n\n## install\n\n```bash\nnpm i --save hapi-demo\n```\n\n## usage\n\n### register\n\nSet up a hapi server and register the plugin.\n\n```javascript\nimport Hapi from 'hapi';\nimport HapiDemo from 'hapi-demo'\n\nconst server = new Hapi.Server();\nserver.register(HapiDemo)\n  .then(() => {\n    console.log('plugin has been registered successfully');\n  });\n```\n\n### route setup\n\nWhen setting up routes, configure the demo handler if necessary:\n\n```javascript\nimport Joi from 'joi';\n\nserver.route({\n  method: 'GET',\n  path: '/test',\n  handler(request, reply) {\n    return reply('test handler called');\n  },\n  config: {\n    plugins: {\n      'hapi-demo': {\n        shouldApplyHandler(request) {\n          return request.query.demo;\n        },\n        handler(request, reply) {\n          return reply('demo handler called');\n        }\n      }\n    },\n    validate: {\n      query: Joi.object().keys({\n        demo: Joi.boolean()\n      })\n    }\n  }\n});\n```\n\nNow when calling the `/test` route without any query parameters the normal hander will be called, but when\ncalling it with query parameters like `/test?demo=true`, then the demo handler will be called.\n\n### API\n\n#### plugin options\n\n-\n\n#### route options\n\n- `test`: *{function(request: Hapi.Request) : Boolean}* - test function that returns if the demo-handler should be called\n- `handler`: *{function(reqest: Hapi.Request, reply: Hapi.Reply)}* - demo handler\n","readmeFilename":"README.md"}