{"id":18282843,"url":"https://github.com/intjelic/byteplug-endpoints","last_synced_at":"2026-05-19T03:33:12.414Z","repository":{"id":57744906,"uuid":"517571590","full_name":"intjelic/byteplug-endpoints","owner":"intjelic","description":"A HTTP client for Node.js to work with Byteplug endpoints easily.","archived":false,"fork":false,"pushed_at":"2022-09-21T19:58:32.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T12:51:37.326Z","etag":null,"topics":["byteplug","endpoints","http-client","javascript","nodejs"],"latest_commit_sha":null,"homepage":"https://www.intjelic.me/projects/byteplug-endpoints","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/intjelic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-25T07:59:59.000Z","updated_at":"2023-04-11T15:51:35.000Z","dependencies_parsed_at":"2022-08-30T11:32:20.439Z","dependency_job_id":null,"html_url":"https://github.com/intjelic/byteplug-endpoints","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intjelic%2Fbyteplug-endpoints","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intjelic%2Fbyteplug-endpoints/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intjelic%2Fbyteplug-endpoints/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intjelic%2Fbyteplug-endpoints/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/intjelic","download_url":"https://codeload.github.com/intjelic/byteplug-endpoints/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247983498,"owners_count":21028303,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["byteplug","endpoints","http-client","javascript","nodejs"],"created_at":"2024-11-05T13:06:24.055Z","updated_at":"2026-05-19T03:33:07.389Z","avatar_url":"https://github.com/intjelic.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Byteplug Endpoints (WIP!)\n\nThis is a HTTP client for Node.js to interact with HTTP APIs implementing the\nEndpoints standard from Byteplug. It's essentially a wrapper around **axios**\nto expose an easier-to-work-with interface. Therefore, this library works (in\ntheory) on both the browser and node.\n\n```bash\nnpm install byteplug-endpoints\n```\n\n```javascript\nimport Endpoints from 'byteplug-endpoints'\n\nvar endpoints = new Endpoints(\"http://api.my-company.com\")\n\nvar endpoint = endpoints.endpoint(\"foo\")\nendpoint.response = function(document) {\n    // Do something with response and its document.\n}\n\nconst document = {\n    foo: \"bar\",\n    bar: \"foo\"\n}\nendpoint.request(document)\n```\n\nThis project is a **work-in-progress** and its API is subject to change\ndrastically (it's mostly for internal use so far).\n\n## How to use\n\nThere is no documentation at the moment and this section is the only source of\ninformation.\n\nYou must first create a global `Endpoints` object with the base URL. Note that\non a Vue.js app, this is typically shared across all components as a global\nproperty.\n\n```javascript\nvar endpoints = new Endpoints(\"https://api.my-company.com\")\n```\n\nTo interact with an endpoint, you must first create an endpoint object with\neither `endpoint()` or `collectionEndpoint()`.\n\n```javascript\nvar nonCollectionEndpoint = endpoints.endpoint(\"my-path\")\nvar collectionEndpoint = endpoints.collectionEndpoint(\"my-collection\", \"my-path\", false)\nvar itemCollectionEndpoint = endpoints.collectionEndpoint(\"my-collection\", \"my-path\", true)\n```\n\nThen you attach the response and error handlers to this endpoint object. It\nalso supports `clientError` and `serverError`.\n\n```javascript\nmyEndpoint.response = (document) =\u003e {\n    //\n}\nmyEndpoint.errors['foo'] = (document) -=\u003e {\n    // Deal when 'foo' error is returned.\n}\nmyEndpoint.errors['bar'] = () -=\u003e {\n    // Deal when 'bar error is returned'\n}\n```\n\nAt this point, no HTTP request has been made yet, you must call the `request()`\nmethod with the document, if any, and a token.\n\n```javascript\nmyEndpoint.request(document/*, token*/)\n```\n\nIf the endpoint requires authentication, pass the token after the document. If\nthe endpoint operates on an item of a collection, you must pass the item ID as\nwell. For instance:\n\n```javascript\nitem = \"42\"\nmyCollectionEndpoint.request(item, document, token)\n```\n\nThe `request()` method returns a promise, and therefore you can wait for the\nHTTP request to actually be completed and wait until all callbacks are\nfully run.\n\n## Additional notes\n\nThis HTTP client expects a compliant behavior from the server. When it finds\noddities, the promise returned by `request()` will fail with an explicit\nmessage error.\n\nIt also implements very basic unit tests (it's far from being complete).\n\n```\nnpm run test\n```\n```\n\u003e byteplug-endpoints@0.0.1 test\n\u003e ava\n\n\n  ✔ client-side-error\n  ✔ server-side-error\n  ✔ non-collection-endpoint\n  ✔ collection-endpoint-without-item\n  ✔ authorization-token\n  ✔ collection-endpoint-with-item\n  ✔ non-compliant-endpoints\n  ✔ timeout-error (209ms)\n  ─\n\n  8 tests passed\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintjelic%2Fbyteplug-endpoints","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintjelic%2Fbyteplug-endpoints","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintjelic%2Fbyteplug-endpoints/lists"}