{"id":17036129,"url":"https://github.com/digaev/chainify-url","last_synced_at":"2026-03-08T06:32:35.690Z","repository":{"id":57685310,"uuid":"482570223","full_name":"digaev/chainify-url","owner":"digaev","description":"Object Oriented URL Builder","archived":false,"fork":false,"pushed_at":"2022-04-19T06:43:38.000Z","size":89,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-07T00:23:30.901Z","etag":null,"topics":["builder","http","javascript","nodejs","object","url"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digaev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-17T16:06:22.000Z","updated_at":"2024-09-04T13:43:02.000Z","dependencies_parsed_at":"2022-09-18T22:51:01.353Z","dependency_job_id":null,"html_url":"https://github.com/digaev/chainify-url","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/digaev/chainify-url","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digaev%2Fchainify-url","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digaev%2Fchainify-url/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digaev%2Fchainify-url/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digaev%2Fchainify-url/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digaev","download_url":"https://codeload.github.com/digaev/chainify-url/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digaev%2Fchainify-url/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30247361,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-08T05:41:50.788Z","status":"ssl_error","status_checked_at":"2026-03-08T05:41:39.075Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["builder","http","javascript","nodejs","object","url"],"created_at":"2024-10-14T08:49:27.282Z","updated_at":"2026-03-08T06:32:35.657Z","avatar_url":"https://github.com/digaev.png","language":"JavaScript","readme":"# Chainify URL\n\n[![CircleCI](https://circleci.com/gh/digaev/chainify-url/tree/master.svg?style=svg)](https://circleci.com/gh/digaev/chainify-url/tree/master)\n[![Coverage Status](https://coveralls.io/repos/github/digaev/chainify-url/badge.svg?branch=master)](https://coveralls.io/github/digaev/chainify-url?branch=master)\n[![npm](https://img.shields.io/npm/v/chainify-url)](https://www.npmjs.com/package/chainify-url)\n\nObject oriented URL builder.\n\n## Installation\n\n```\nnpm install chainify-url\n```\n\n## Usage\n\nSee [sample project](example/src/index.js) and examples below.\n\n## Why?\n\nHave you ever concatenated strings to build a URL? With this library you can do the same (and not only) but in an object oriented way — by chaining properties. Huh? 😳 Watch this:\n\n```js\nimport chainify from 'chainify-url';\n\n// Pass a string or a URL as baseURL\nconst chain = chainify('https://example.com/', {\n  // Define \"chain enders\" - the rightmost properties that end the chain\n  url(url) {\n    // It is not necessarily to return the URL or any other value from enders,\n    // but we are going to read this property\n    return url;\n  },\n\n  // We want this property to be a function\n  build(url) {\n    return () =\u003e url;\n  }\n});\n\n// Build a chain\n\nchain.foo.bar.baz.url.href; // =\u003e 'https://example.com/foo/bar/baz'\n\nchain.foo('bar baz').build().href; // =\u003e 'https://example.com/foo/bar%20baz'\n```\n\nThat's it! 🙂 Yes, it's that simple. Now let's look at another, more realistic example, a Discord client:\n\n```js\nimport axios from 'axios'; // Or any other HTTP client\nimport chainify from 'chainify-url';\n\nconst api = chainify('https://discord.com/api/v9/', {\n  get: (url) =\u003e (config = {}) =\u003e {\n    // What if there are search parameters? 🤔 Pass them in config!\n    if (config.search) {\n      url.search = new URLSearchParams(config.search).toString();\n    }\n\n    return axios.get(url.href, { headers: config.headers })\n  },\n\n  // Let's add a method for POSTing requests\n  post: (url) =\u003e (config = {}) =\u003e {\n    if (config.search) {\n      url.search = new URLSearchParams(config.search).toString();\n    }\n\n    return axios.post(url.href, config.data, { headers: config.headers })\n  },\n});\n\n// GET https://discord.com/api/v9/users/%40me\napi.users('@me').get({\n  headers: {\n    Authorization: 'Bearer \u003cACCESS_TOKEN\u003e',\n  }\n})\n  .then((res) =\u003e {\n    console.log(res.data);\n  })\n  .catch((error) =\u003e {\n    console.log(error.message);\n  });\n\n// Exactly the same URL as above, but built by accessing the property\napi.users['@me'].get({\n  headers: {\n    Authorization: 'Bearer \u003cACCESS_TOKEN\u003e',\n  }\n});\n\n// GET https://discord.com/api/v9/users/%40me/guilds/12345/member\napi.users('@me').guilds(12345).member.get({\n  headers: {\n    Authorization: 'Bearer \u003cACCESS_TOKEN\u003e',\n  }\n});\n\n// POST https://discord.com/api/v9/guilds/12345/channels\napi.guilds(12345).channels.post({\n  data: {\n    name: 'My Channel',\n    type: 0,\n    // ...\n  },\n  headers: {\n    Authorization: 'Bearer \u003cACCESS_TOKEN\u003e',\n  }\n});\n```\nWe just turned our URL builder into an HTTP client that covers every endpoint, even with the deepest nesting, WOAH! 😀 API calls are intuitive and look very similar to the endpoints they use, no additional classes or functions required, simplicity and readability, everything is right here!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigaev%2Fchainify-url","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigaev%2Fchainify-url","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigaev%2Fchainify-url/lists"}