{"_id":"z-api","_rev":"5-1a016048d927328e6105fb44f7aaec6f","name":"z-api","description":"Create an API/Server without having to create the actual server yourself, all you have to worry about is the routes. ## Install ```sh npm i --save z-api ``` ## Usage ```js const Zapi = require('z-api'),   api = new Zapi() ```","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"z-api","version":"1.0.0","description":"```sh","main":"index.js","scripts":{"test":"mocha test","deps":"dependency-check package.json --entry index.js --missing --unused --no-dev","update":"ncu -u"},"author":{"name":"Zac McChesney"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/imzacm/Zapi.git"},"devDependencies":{"chai":"^4.1.2","dependency-check":"^2.9.1","mocha":"^4.0.1","npm-check-updates":"^2.13.0"},"gitHead":"24e3b6117444b1fe470a72b7184fb345781e4a4e","bugs":{"url":"https://github.com/imzacm/Zapi/issues"},"homepage":"https://github.com/imzacm/Zapi#readme","_id":"z-api@1.0.0","_npmVersion":"5.4.2","_nodeVersion":"8.7.0","_npmUser":{"name":"imzacm","email":"zac@zacmcchesney.com"},"dist":{"integrity":"sha512-k1MVt1NJJB9z4asQU/sVBjzXZaBVdLnnzwppCdP+rPSZz1G03Y93977MqSSQ19EacyACizPlIQBSY+kJ7frSuQ==","shasum":"88d95f42bf09d8abec881d6f78a4cc571a840d23","tarball":"https://registry.npmjs.org/z-api/-/z-api-1.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAoWv8YBpFH/sq0hbJHdvUN3a7+v9XGD2cKStglwIESmAiB/9JyYjNILu6e3fswdU/YAXP6wyVSXzCOFH+Hb6f+LlA=="}]},"maintainers":[{"name":"imzacm","email":"zac@zacmcchesney.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/z-api-1.0.0.tgz_1509062595263_0.3464314811863005"}},"1.0.1":{"name":"z-api","version":"1.0.1","description":"```sh npm i --save z-api ``` ## Usage ```js const Zapi = require('z-api'),   api = new Zapi() ```","main":"index.js","scripts":{"test":"mocha test","deps":"dependency-check package.json --entry index.js --missing --unused --no-dev","update":"ncu -u"},"author":{"name":"Zac McChesney"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/imzacm/Zapi.git"},"devDependencies":{"chai":"^4.1.2","dependency-check":"^2.9.1","mocha":"^4.0.1","npm-check-updates":"^2.13.0"},"gitHead":"0c794faf669622f0f2ef6449e3720253ca7824af","bugs":{"url":"https://github.com/imzacm/Zapi/issues"},"homepage":"https://github.com/imzacm/Zapi#readme","_id":"z-api@1.0.1","_npmVersion":"5.4.2","_nodeVersion":"8.7.0","_npmUser":{"name":"imzacm","email":"zac@zacmcchesney.com"},"dist":{"integrity":"sha512-aJb7yFL9X0g7aIp8OMu+KbPLhRq9RgE5q/MF3P2IQzI9jwAhSIo7ea93FZrli4TzZDbw0MTCjx1RvrFpa/onUA==","shasum":"6429ef97f48bcc6b4f9b73f56b87d8f5686fe8fb","tarball":"https://registry.npmjs.org/z-api/-/z-api-1.0.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF4LpmnQhs5jKFBRTFPsjk8Wc6yTum1+He1gy+dA6W8sAiAd5GWz3cGH0+ZEaH3qBhcVN9f/TvvSD5bVZTMfdNmAMw=="}]},"maintainers":[{"name":"imzacm","email":"zac@zacmcchesney.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/z-api-1.0.1.tgz_1509062668137_0.9794681938365102"}},"1.0.2":{"name":"z-api","version":"1.0.2","description":"Create an API/Server without having to create the actual server yourself, all you have to worry about is the routes. ## Install ```sh npm i --save z-api ``` ## Usage ```js const Zapi = require('z-api'),   api = new Zapi() ```","main":"index.js","scripts":{"test":"mocha test","deps":"dependency-check package.json --entry src/api/server.js --missing --unused --no-dev","update":"ncu -u","precommit":"npm run deps","prepush":"npm run test"},"author":{"name":"Zac McChesney"},"license":"MIT","keywords":["api","server","http","low-level"],"repository":{"type":"git","url":"git+https://github.com/imzacm/Zapi.git"},"devDependencies":{"chai":"^4.1.2","dependency-check":"^2.9.1","husky":"^0.14.3","mocha":"^4.0.1","npm-check-updates":"^2.13.0"},"gitHead":"a934b99d7859991eb438ada24cebef211897637b","bugs":{"url":"https://github.com/imzacm/Zapi/issues"},"homepage":"https://github.com/imzacm/Zapi#readme","_id":"z-api@1.0.2","_npmVersion":"5.4.2","_nodeVersion":"8.7.0","_npmUser":{"name":"imzacm","email":"zac@zacmcchesney.com"},"dist":{"integrity":"sha512-cK0+3rHi5qoM9MAPTp1ItIic3pwsBRyNIMeMlqbAFuNv0/Mw6UEouwSkRJ09hD0HvYgUQ7eImmDZRO514OhN2w==","shasum":"0cf57690f4d76a23bfe8427991122ef0868c670e","tarball":"https://registry.npmjs.org/z-api/-/z-api-1.0.2.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDCxHmrJYSML9Ws3lmJSA8KXJbVlbfux+5qRoxb05c2IgIgBXNKG2M4vu0AWLIJ1sUYI9t++0/SiYZKG1sWu1ZSHxw="}]},"maintainers":[{"name":"imzacm","email":"zac@zacmcchesney.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/z-api-1.0.2.tgz_1509063088313_0.2680366928689182"}},"1.0.3":{"name":"z-api","version":"1.0.3","description":"Create an API/Server without having to create the actual server yourself, all you have to worry about is the routes. ## Install ```sh npm i --save z-api ``` ## Usage ```js const Zapi = require('z-api'),   api = new Zapi() ```","main":"src/api/server.js","scripts":{"test":"mocha test","deps":"dependency-check package.json --entry src/api/server.js --missing --unused --no-dev","update":"ncu -u","precommit":"npm run deps","prepush":"npm run test"},"author":{"name":"Zac McChesney"},"license":"MIT","keywords":["api","server","http","low-level"],"repository":{"type":"git","url":"git+https://github.com/imzacm/Zapi.git"},"devDependencies":{"chai":"^4.1.2","dependency-check":"^2.9.1","husky":"^0.14.3","mocha":"^4.0.1","npm-check-updates":"^2.13.0"},"gitHead":"2072c9a0fd0dc462f314f00e5b0ca3cbcee39b37","bugs":{"url":"https://github.com/imzacm/Zapi/issues"},"homepage":"https://github.com/imzacm/Zapi#readme","_id":"z-api@1.0.3","_npmVersion":"5.4.2","_nodeVersion":"8.7.0","_npmUser":{"name":"imzacm","email":"zac@zacmcchesney.com"},"dist":{"integrity":"sha512-OOA5ye6YA14aVakc/5+R6mvPRGcqgMQ7iRgz04B6w+uARnFuNg1yY19smcNBowPXql3xkGydRLOxu2h0qX2JFw==","shasum":"a56407146cc74d4329054de8f9b93e91c2829859","tarball":"https://registry.npmjs.org/z-api/-/z-api-1.0.3.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCWIP7BsUosaXOMGtIT1Q/ljOSbW3w2d6tWzsqhowggMAIgGQcdYL/HXbUlMSr7jX5Aeugiyv5ilDIVWayBn4QRa3w="}]},"maintainers":[{"name":"imzacm","email":"zac@zacmcchesney.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/z-api-1.0.3.tgz_1509063166238_0.505919907707721"}},"1.0.4":{"name":"z-api","version":"1.0.4","description":"Create an API/Server without having to create the actual server yourself, all you have to worry about is the routes. ## Install ```sh npm i --save z-api ``` ## Usage ```js const Zapi = require('z-api'),   api = new Zapi() ```","main":"src/server.js","scripts":{"test":"mocha test -t 10000","deps":"dependency-check package.json --entry src/server.js --missing --unused --no-dev","update":"ncu -u","doc":"jsdoc src/server.js","precommit":"npm run deps && npm run doc","prepush":"npm run test"},"author":{"name":"Zac McChesney"},"license":"MIT","keywords":["api","server","http","low-level"],"repository":{"type":"git","url":"git+https://github.com/imzacm/Zapi.git"},"devDependencies":{"chai":"^4.1.2","dependency-check":"^2.9.1","husky":"^0.14.3","jsdoc":"^3.5.5","mocha":"^4.0.1","npm-check-updates":"^2.13.0"},"gitHead":"755d85bab21a37f50f6940303fb5ec098e7fb709","bugs":{"url":"https://github.com/imzacm/Zapi/issues"},"homepage":"https://github.com/imzacm/Zapi#readme","_id":"z-api@1.0.4","_npmVersion":"5.4.2","_nodeVersion":"8.7.0","_npmUser":{"name":"imzacm","email":"zac@zacmcchesney.com"},"dist":{"integrity":"sha512-o9IwOWu8q/Cy3Ul3D5/U35dhoQTi47gWH5ogpPpfmPPZWJAztBmpuLxTCJFUlEcNsVPgVFevh62ClmAQ40EOjQ==","shasum":"8bd6c7f8294f48b15cb2669ec4e07e7f824f99f6","tarball":"https://registry.npmjs.org/z-api/-/z-api-1.0.4.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC4NeXl6GTPDlznDvo48ksv8kgdu16aAzDXf1CvDTRf+QIhAN0zVvEIgKWYh8+CvIVyelRdeofMcwoOgdFCiPU3kgbt"}]},"maintainers":[{"name":"imzacm","email":"zac@zacmcchesney.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/z-api-1.0.4.tgz_1509132595060_0.9085265840403736"}}},"readme":"# Zapi\nCreate an API/Server without having to create the actual server yourself, all you have to worry about is the routes.\n## Install\n```sh\nnpm i --save z-api\n```\n## Usage\n```js\nconst Zapi = require('z-api'),\n  api = new Zapi()\n```\n\n### Add route\n```js\nconst route = {\n  method: 'GET', //Default is GET if not specified, Must be in caps\n  path: '/', //Default is '/' if not specified,\n  handler: (req, res) => {\n    /*\n    req and res are the standard http objects\n    A good guide on how to use them here\n    https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/\n    */\n    res.end('The api works)\n  }\n}\n\napi.addRoute(route)\n```\n\n### Remove route\n```js\napi.removeRoute('GET', '/') //Method and path\n```\n\n### Options\nOptions can be passed set when initialising the class, or they can be set later on.\n### On initialisation\n```js\napi = new Zapi({\n  port: 80\n})\n```\n### After initialisation\n```js\napi.config.port = 80\n```\n\n### Used options\nThe following are config options that are currently used, more may be added in the future.\n\n#### port\nThe port to run the server on, the default is 3002.\n```js\nport: 3002\n```\n\n#### defaultRoute\nThe default route options to use if that option is not specified.\nThe default method is GET.\nThe default path is '/'.\nThe default handler sends a response saying 'Default route'.\n```js\ndefaultRoute: {\n  method: 'GET',\n  path: '/',\n  handler: (req, res) => {\n    res.send('Default route')\n  }\n}\n```\n### Middleware\nMiddleware is run in parallel for the best performance.\nTo add middleware use the addMiddleware function.\n```js\napi.addMiddleware((req, res, next) => {\n  console.dir(req)\n  next()\n})\n```","maintainers":[{"name":"imzacm","email":"zac@zacmcchesney.com"}],"time":{"modified":"2022-05-25T10:03:29.272Z","created":"2017-10-27T00:03:16.183Z","1.0.0":"2017-10-27T00:03:16.183Z","1.0.1":"2017-10-27T00:04:29.061Z","1.0.2":"2017-10-27T00:11:29.207Z","1.0.3":"2017-10-27T00:12:47.181Z","1.0.4":"2017-10-27T19:29:56.542Z"},"homepage":"https://github.com/imzacm/Zapi#readme","repository":{"type":"git","url":"git+https://github.com/imzacm/Zapi.git"},"author":{"name":"Zac McChesney"},"bugs":{"url":"https://github.com/imzacm/Zapi/issues"},"license":"MIT","readmeFilename":"README.md","keywords":["api","server","http","low-level"]}