{"id":20236257,"url":"https://github.com/micro/micro-js","last_synced_at":"2025-03-03T14:25:09.297Z","repository":{"id":57296438,"uuid":"429214586","full_name":"micro/micro-js","owner":"micro","description":"Micro JS Client","archived":false,"fork":false,"pushed_at":"2021-11-20T14:08:42.000Z","size":128,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-14T08:20:31.432Z","etag":null,"topics":["js","micro"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/micro-js-client","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/micro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-17T22:03:47.000Z","updated_at":"2022-10-25T15:55:39.000Z","dependencies_parsed_at":"2022-09-07T03:21:04.551Z","dependency_job_id":null,"html_url":"https://github.com/micro/micro-js","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micro%2Fmicro-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micro%2Fmicro-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micro%2Fmicro-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micro%2Fmicro-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/micro","download_url":"https://codeload.github.com/micro/micro-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233828150,"owners_count":18736578,"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":["js","micro"],"created_at":"2024-11-14T08:19:43.059Z","updated_at":"2025-01-14T00:47:47.620Z","avatar_url":"https://github.com/micro.png","language":"TypeScript","readme":"# Micro JS Client\n\nThe JS client for the Micro Platform.\n\nView on [NPM](https://www.npmjs.com/package/micro-js-client)\n\n## Usage\n\nInstallation:\n```\nnpm install --save micro-js-client\n```\n\n## Request\n\nMake a standard http request\n\n```js\nconst micro = require('micro-js-client');\n\nnew micro.Client({ token: 'MICRO_API_TOKEN' })\n  .call('helloworld', 'call', {\"name\": \"Alice\"})\n  .then((response) =\u003e {\n    console.log(response);\n  });\n```\n\nThe output will be:\n```\n{ message: 'Hello Alice' }\n```\n\n## Streaming\n\nMake a websocket streaming request\n\n```js\nconst micro = require(\"micro-js-client\")\n\nnew micro.Client({ token: 'MICRO_API_TOKEN' })\n  .stream(\"helloworld\", \"stream\", {\"name\": \"Alice\", \"messages\": 10})\n  .then(stream =\u003e {\n\tstream.recv(msg =\u003e {\n\t\tconsole.log(\"message received: \", msg)\n\t})\n}).catch(e =\u003e {\n\tconsole.log(e)\n})\n\nsetInterval(() =\u003e {}, 5000);\n\n```\n\nAbove example will output:\n\n```\nmessage received:  { message: 'Hello Alice' }\nmessage received:  { message: 'Hello Alice' }\nmessage received:  { message: 'Hello Alice' }\nmessage received:  { message: 'Hello Alice' }\nmessage received:  { message: 'Hello Alice' }\nmessage received:  { message: 'Hello Alice' }\nmessage received:  { message: 'Hello Alice' }\nmessage received:  { message: 'Hello Alice' }\nmessage received:  { message: 'Hello Alice' }\nmessage received:  { message: 'Hello Alice' }\n```\n\n## Format\n\nThe JS client uses the Micro API to make requests. Just pass `service`, `endpoint` and the json `request`.\n\nThe call `/helloworld/call` routes to the service `helloworld` and endpoint `Call`. So just do:\n\n```js\nmicro.Client.call(\"helloworld\", \"call\", {\"name\": \"Alice\"})\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicro%2Fmicro-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicro%2Fmicro-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicro%2Fmicro-js/lists"}