{"_id":"@dualizm/descend","_rev":"1-6c93250dcde951711635fd84756dc507","name":"@dualizm/descend","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@dualizm/descend","version":"1.0.0","keywords":["descend","description","endpoints","declarative","api","http","https","web","restful","rest","json","jsonapi","json-schema","request"],"author":{"name":"dualizm","email":"https://github.com/dualizm"},"license":"Apache-2.0","_id":"@dualizm/descend@1.0.0","homepage":"https://github.com/dualizm/dereq#readme","bugs":{"url":"https://github.com/dualizm/dereq/issues"},"dist":{"shasum":"5364add01382e021de640d4028ca8cf82454c552","tarball":"https://registry.npmjs.org/@dualizm/descend/-/descend-1.0.0.tgz","fileCount":7,"integrity":"sha512-6dDOd4ctW0pwa59c4tl5NCGzgd0TA7/ErI50zClWfuFl5o2fZtns3VqrtnzQsa9H+yeWZvo8b5x66K4LF6WXHQ==","signatures":[{"sig":"MEYCIQD+Gcdk7wR7O+Ik9Q0fqnZuZtfcKu4epUu7JNdXlqMw/wIhANeQfnpC8Aq6DJ97bDoiTzt6p81WTm6BmFDMplQJ0ovN","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":26160},"main":"dist/cjs/index.js","type":"module","module":"dist/esm/index.js","gitHead":"1e43288371c00c9936240c8edf43e0a23b70e5c6","scripts":{"test":"jest","rollup":"rollup -c"},"_npmUser":{"name":"dualizm","email":"laiker35@yandex.ru"},"prepublish":"npm test && npm rollup","repository":{"url":"git+https://github.com/dualizm/dereq.git","type":"git"},"_npmVersion":"10.8.0","description":"🏂 A library to make the description of endpoints easier.","directories":{},"_nodeVersion":"21.7.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","rollup":"^4.18.0","@babel/core":"^7.24.7","@babel/preset-env":"^7.24.7","@rollup/plugin-babel":"^6.0.4","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-commonjs":"^26.0.1","@rollup/plugin-node-resolve":"^15.2.3"},"_npmOperationalInternal":{"tmp":"tmp/descend_1.0.0_1719139545409_0.5923461188978763","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@dualizm/descend","version":"1.0.1","description":"🏂 A library to make the description of endpoints easier.","prepublish":"npm test && npm rollup","scripts":{"rollup":"rollup -c","test":"jest"},"author":{"name":"dualizm","email":"https://github.com/dualizm"},"license":"Apache-2.0","keywords":["descend","description","endpoints","declarative","api","http","https","web","restful","rest","json","jsonapi","json-schema","request"],"repository":{"type":"git","url":"git+https://github.com/dualizm/descend.git"},"main":"dist/cjs/index.js","module":"dist/esm/index.js","devDependencies":{"@babel/core":"^7.24.7","@babel/preset-env":"^7.24.7","@rollup/plugin-babel":"^6.0.4","@rollup/plugin-commonjs":"^26.0.1","@rollup/plugin-node-resolve":"^15.2.3","@rollup/plugin-terser":"^0.4.4","jest":"^29.7.0","rollup":"^4.18.0"},"type":"module","_id":"@dualizm/descend@1.0.1","gitHead":"8eaa58a1658ac20d61ca66444eaa718eb8851989","bugs":{"url":"https://github.com/dualizm/descend/issues"},"homepage":"https://github.com/dualizm/descend#readme","_nodeVersion":"20.16.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-2/4FpG9kLiuAFsYWjIB3TiyFLL9/Qiv1j34D/p/hsiy0vYjQ7X1O+y0OZj7x2M8M9kOAVDQyWw/XIegwl2uhow==","shasum":"b543279fc074b3e57bf706609e1c657ceb25545d","tarball":"https://registry.npmjs.org/@dualizm/descend/-/descend-1.0.1.tgz","fileCount":7,"unpackedSize":27863,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID/Y/vJYPEmhf5lVGq5S/40xkgTEIHRc8JuseAHpP1oCAiEApwlHW/2eH40qvw7q4j9atSXZEvL70O/rkgxZrI3Wah0="}]},"_npmUser":{"name":"dualizm","email":"laiker35@yandex.ru"},"directories":{},"maintainers":[{"name":"dualizm","email":"laiker35@yandex.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/descend_1.0.1_1724139256155_0.22446688813653504"},"_hasShrinkwrap":false}},"time":{"created":"2024-06-23T10:45:45.313Z","modified":"2024-08-20T07:34:16.485Z","1.0.0":"2024-06-23T10:45:45.607Z","1.0.1":"2024-08-20T07:34:16.297Z"},"bugs":{"url":"https://github.com/dualizm/descend/issues"},"author":{"name":"dualizm","email":"https://github.com/dualizm"},"license":"Apache-2.0","homepage":"https://github.com/dualizm/descend#readme","keywords":["descend","description","endpoints","declarative","api","http","https","web","restful","rest","json","jsonapi","json-schema","request"],"repository":{"type":"git","url":"git+https://github.com/dualizm/descend.git"},"description":"🏂 A library to make the description of endpoints easier.","maintainers":[{"name":"dualizm","email":"laiker35@yandex.ru"}],"readme":"# Descend\r\n🏂 A library to make the description of endpoints easier.\r\n\r\n## Install\r\n\r\nnpm:\r\n```sh\r\nnpm install @dualizm/descend\r\n```\r\n\r\nyarn:\r\n```sh\r\nyarn add @dualizm/descend\r\n```\r\n\r\n## Usage\r\n\r\nDescribe your endpoints\r\n\r\n```js\r\nimport { descend, group } from '@dualizm/descend'\r\n\r\nconst ip = '127.0.0.1'\r\nconst port = 9001\r\n\r\nexport const endpoints = {\r\n    cats: {\r\n        [group]: true,\r\n        get: {\r\n            all: 'all-cats', // https://127.0.0.1:9001/cats/all-cats\r\n        },\r\n        post: {\r\n            save: 'save-cat',\r\n            create: 'new-cat'\r\n        }\r\n    },\r\n    dogs: {\r\n        get: {\r\n            all: 'all-dogs', // https://127.0.0.1:9001/all-dogs\r\n        }\r\n    }\r\n}\r\n\r\ndescend({\r\n    ip,\r\n    port,\r\n    procotol: 'https'\r\n}, endpoints);\r\n\r\n```\r\n\r\nand use it\r\n\r\n```js\r\nimport { endpoints } from 'endpoints'\r\n\r\nconst showCats = async () => {\r\n    try {\r\n        const response = await fetch(endpoints.cats.get.all)\r\n        const answer = await response.json()\r\n        console.log(answer)\r\n    } catch (error) {\r\n        console.error(error)\r\n    }\r\n}\r\n```\r\n\r\n```js\r\nimport { endpoints } from 'endpoints'\r\nimport axios from 'axios'\r\n\r\nconst showLists = async () => {\r\n    try {\r\n        const response = await axios.get(endpoints.dogs.get.all)\r\n        console.log(response.data)\r\n    } catch (error) {\r\n        console.error(error)\r\n    }\r\n}\r\n```\r\n\r\n## Docs\r\n\r\n```js\r\n/**\r\n * Symbol representing the 'group' identifier.\r\n * Add the group symbol to the object so that the top key is included in the path\r\n * @type {Symbol}\r\n */\r\nconst group;\r\n\r\n/**\r\n * Takes the host, port, and protocol and returns the formatted URL.\r\n *\r\n * @param {string} host - the host name or IP address\r\n * @param {number | string} port - the port number (optional)\r\n * @param {string} protocol - the URL protocol (e.g. http, https)\r\n * @return {string} the formatted URL\r\n */\r\nfunction formatURL(host, port, protocol);\r\n\r\n/**\r\n * A function that descends through endpoints to update their values with formatted URL.\r\n *\r\n * @param {Object} ip - the IP address to construct the URL\r\n * @param {number | string} port - the port number for the URL (optional)\r\n * @param {string} procotol - the protocol for the URL (default: 'http')\r\n * @param {Object} endpoints - the object containing the endpoints to update\r\n * @param {Object} opts - the options for formatting the URL\r\n * @return {void}\r\n */\r\nfunction descend ({ip, port, procotol = 'http'}, endpoints, opts);\r\n```\r\n\r\n## License\r\n\r\n[Apache-2.0](LICENSE)\r\n","readmeFilename":"README.md"}