{"id":20248851,"url":"https://github.com/webeetle/core-sdk","last_synced_at":"2026-05-11T17:36:07.118Z","repository":{"id":39800737,"uuid":"223555927","full_name":"webeetle/core-sdk","owner":"webeetle","description":"bee sdk","archived":false,"fork":false,"pushed_at":"2023-01-03T01:29:51.000Z","size":1048,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-03T16:13:17.214Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/webeetle.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":"2019-11-23T08:24:02.000Z","updated_at":"2022-08-02T10:40:01.000Z","dependencies_parsed_at":"2023-02-01T04:46:45.337Z","dependency_job_id":null,"html_url":"https://github.com/webeetle/core-sdk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/webeetle/core-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webeetle%2Fcore-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webeetle%2Fcore-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webeetle%2Fcore-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webeetle%2Fcore-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webeetle","download_url":"https://codeload.github.com/webeetle/core-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webeetle%2Fcore-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32906434,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-11T17:09:15.040Z","status":"ssl_error","status_checked_at":"2026-05-11T17:08:45.420Z","response_time":120,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":[],"created_at":"2024-11-14T09:50:02.555Z","updated_at":"2026-05-11T17:36:07.102Z","avatar_url":"https://github.com/webeetle.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Core SDK\n\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://travis-ci.com/webeetle/core-sdk.svg?branch=master)](https://travis-ci.com/webeetle/core-sdk) [![Greenkeeper badge](https://badges.greenkeeper.io/webeetle/core-sdk.svg)](https://greenkeeper.io/)\n\nCore SDK is a small library that help you to build your own SDK in your Javascript Application.\n\n## Create your own SDK\n\nStart to create your SDK is really simple.\n\n```\nimport SDK from '@webeetle/core-sdk'\n\nconst sdk = new SDK()\n```\n\nNow you have an instance of your sdk. Basicly you now have a `sdk.req`. This property defined is an instance of `axios` library. Check out how to use it [here](https://github.com/axios/axios).\n\nIn addition to having the property, you will have a set of functionality such as:\n\n- `decorate`: you can decorate your sdk instance with your functionalities.\n\n- `log`: you have a predefined logger.\n\n- `addClient`: allow you to add `axios` based client configuration.\n\n- `addService`: allow you to add plugin to your instance.\n\n### Options\n\nYou can pass to the `core-sdk` constructor a set of options:\n\n- `name`: the name of your sdk.\n\n- `clients`: a key value object where the key represent the name and the value is an object that represent an `axios` client configuration.\n\n- `logLevel`: one of `info`, `warn`, `error` (predefined), `trace`.\n\n### Example\n\n```\nimport SDK from '@webeetle/core-sdk'\n\nconst mySdk = new SDK({\n  name: 'WeBeetle SDK',\n  clients: {\n    v1: {\n      baseUrl: 'http://api.webeetle.com/v1',\n      headers: {'Authorization': 'Bearer 12333321122222'}\n    },\n    v2: {\n      baseUrl: 'http://api.webeetle.com/v2',\n      headers: {'Authorization': 'Bearer 44443322222222'}\n    }\n  },\n  logLevel: 'info'\n})\n```\n\nPerfect now yoou have your configured sdk instance. If you have the necessity to invoke an endpoint on the `v1` api version you can simply:\n\n```\nmySdk.v1.post('/your/endpoint')\n  .then(response =\u003e {\n    // Do something useful here\n  })\n  .catch(e =\u003e {\n    // Manage the error\n  })\n```\n\nor if you want to use `v2` api in an `async` function: \n\n```\nasync function myUtilityFunction () {\n  try {\n    const response = await mySdk.v2.post('/your/endpoint')\n    // Do something userful here\n  } catch (e) {\n    // Manage your error here\n  }\n}\n```\n\n## Decorate\n\nThe API of your sdk instance allows you to add new properties that you can use everywhere in your application. Here an example:\n\n```\nimport SDK from '@webeetle/core-sdk'\n\nconst mySdk = new SDK()\nmySdk.decorate('sum', (a, b) =\u003e a + b)\n```\n\nand somewhere else in your application you can use it as follow:\n\n```\nconst total = mySdk.sum(5, 30)\n```\n\nWith the decorate API you can store everything you want. For example a configuration object.\n\n## Add service\n\nThe `core-sdk` api expose another method that allow you to expose a service. For example, if you need to expose a set of functionality to manage users (create, update, delete) you can create a service, and decorate the main sdk instance. Below an example:\n\n```\n// file users.js\n\nimport { plugin } from '@webeetle/core-sdk'\n\nexport default plugin((instance, name) =\u003e {\n  instance.decorate(name, {\n    create: async userData =\u003e {\n      // create you user\n    },\n    getUserByUsername: async username =\u003e {\n      // get user by username\n    },\n    update: async userData =\u003e {\n      // update your user\n    },\n    delete: async username =\u003e {\n      // delete your user\n    }\n  })\n})\n```\n\n```\n// file mySdk.js\n\nimport SDK from '@webeetle/core-sdk'\nimport users from '/path/to/users'\n\nconst mySdk = new SDK()\nmySdk,addService('users', users)\n\n// now we can use it\nmySdk.users.create({\n    name: 'Davide',\n    username: 'davide'\n  })\n  .then(response =\u003e {\n    // do something \n  })\n  .catch(e =\u003e {\n    // do something \n  })\n```\n\n## Contributing\n\nIf you feel you can help in any way, be it with examples, extra testing, or new features please open a pull request or open an issue.\n\nThe code follows the Standard code style.\n\n[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)\n\n## Running Tests\n\nSimply run `npm run test` from command line.\n\n## Acknowledgements\n\nThis project is kindly sponsored by [Webeetle s.r.l.](https://www.webeetle.com)\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebeetle%2Fcore-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebeetle%2Fcore-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebeetle%2Fcore-sdk/lists"}