{"id":13780758,"url":"https://github.com/xixilive/feathers-client-weapp","last_synced_at":"2026-04-03T14:03:02.895Z","repository":{"id":42873866,"uuid":"257554941","full_name":"xixilive/feathers-client-weapp","owner":"xixilive","description":"Adapts the feathers rest client for wechat mini-program","archived":false,"fork":false,"pushed_at":"2023-01-06T03:55:35.000Z","size":1037,"stargazers_count":0,"open_issues_count":13,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-04T16:33:02.302Z","etag":null,"topics":["feathers","wechat-mini-program"],"latest_commit_sha":null,"homepage":"","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/xixilive.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":"2020-04-21T10:08:48.000Z","updated_at":"2020-06-19T01:47:30.000Z","dependencies_parsed_at":"2023-02-05T06:32:10.146Z","dependency_job_id":null,"html_url":"https://github.com/xixilive/feathers-client-weapp","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/xixilive/feathers-client-weapp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xixilive%2Ffeathers-client-weapp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xixilive%2Ffeathers-client-weapp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xixilive%2Ffeathers-client-weapp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xixilive%2Ffeathers-client-weapp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xixilive","download_url":"https://codeload.github.com/xixilive/feathers-client-weapp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xixilive%2Ffeathers-client-weapp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31355719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T08:03:20.796Z","status":"ssl_error","status_checked_at":"2026-04-03T08:00:37.834Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["feathers","wechat-mini-program"],"created_at":"2024-08-03T18:01:19.412Z","updated_at":"2026-04-03T14:03:02.876Z","avatar_url":"https://github.com/xixilive.png","language":"JavaScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Social media"],"readme":"## To adapts feathers rest client for wechat mini-program 微信小程序\n\n[![Travis.org](https://img.shields.io/travis/xixilive/feathers-client-weapp/master)](https://travis-ci.org/github/xixilive/feathers-client-weapp)\n[![npm bundle size](https://img.shields.io/bundlephobia/min/@feathers-weapp/client)](https://www.npmjs.com/package/@feathers-weapp/client)\n[![npm version](https://img.shields.io/npm/v/@feathers-weapp/client)](https://www.npmjs.com/package/@feathers-weapp/client)\n[![Known Vulnerabilities](https://snyk.io/test/github/xixilive/feathers-client-weapp/badge.svg)](https://snyk.io/test/github/xixilive/feathers-client-weapp)\n[![NPM license](https://img.shields.io/npm/l/@feathers-weapp/client)](https://www.npmjs.com/package/@feathers-weapp/client)\n\n## Installation\n\n```sh\n# 小程序开发者工具构建npm包时仅处理production依赖,因此要加`--save-prod`\nnpm i @feathers-weapp/client --save-prod\n\n# or\nyarn add @feathers-weapp/client --save\n```\n\n## Usage\n\n### use feathers services only\n\n```js\nimport {feathers} from '@feathers-weapp/client'\n\nconst app = feathers('https://api.endpoint')\n\napp.authenticate({strategy: 'weapp', code: 'logincode', ...})\n  .then(res =\u003e console.log('authenticated', res))\n\napp.service('something').once('created', data =\u003e console.log('created', data))\napp.service('something').create(data).then(res =\u003e console.log('created', res))\n```\n\n### bind feathers app with wx App and Page\n\n\u003e **NOTE**: bind API makes `code pollution` in `App` and `Page`\n\n```js\n// in App.js\nimport {feathers, bindApps, setup} from '@feathers-weapp/client'\nconst app = feathers('https://endpoint.api')\n\n// bind\nconst initApp = bindApps(App, Page, app)\ninitApp({\n  onLaunch(opts){\n    // ...\n  },\n\n  reAuthOnLaunch: true // will cause automatic JWT authentication on app launch.\n})\n\n// or use shortcut\nsetup('https://endpoint.api', {\n  onLaunch(opts){\n    // ...\n  }\n})\n```\n\nOnce bind with `App` and `Page`, you can use:\n\n- `App.feathers` to get the feathers app instance.\n- `App.emitter` to get an event emitter API, which delegated to the feathersjs's emitter.\n- `App.authentication` to get the current authentication state.\n- `Page.bindAuthentication` to bind authentication state with current page, bind `this.data.authentication`. \n\n```js\n/* emitter example */\nconst unsubscribe = App.emitter.on('event', () =\u003e {}) // subscribe\nunsubscribe() //unsubscribe, be careful\n\nApp.emitter.once('event', () =\u003e {})\nApp.emitter.emit('event', 'event data')\n\n/* bindAuthentication example */\nPage({\n  onLoad(){\n    Page.bindAuthentication(this)\n  },\n\n  onTapAction() {\n    if(!this.data.authentication.authenticated) {\n      console.log('oops')\n    }\n  }\n})\n```\n\n### A simple storage wrapper\n\nwindow.localStorage compatiable API of wx storage functions, see `storage interface` in document.\n\n```js\nimport {storage: createStorage} from '@feather-weapp/client'\n\nconst storage = createStorage(wx)\nstorage.getItem('key') // =\u003e value of key\nstorage.getItemAsync('key').then(value =\u003e console.log(value))\n```\n\n## Build Tips\n\nThis package was prebuilt as es module to `dist` folder, and all of source code not be transpiled to ES5 version.\nIf you use this package's default build, you should turn on the `ES6 to ES5` option in devtools.\nIf you want a custom build, please clone this repo.\n\n\n## API\n\n```js\n// package's exports\nimport {feathers, bindApps, setup, storage} from '@feather-weapp/client'\n\n// additional exports from @xixilive/weapp-fetch\nimport {fetch, http, Logger } from '@feather-weapp/client'\n```\n\n### feathers function\n\n```ts\nfunction feathers(options: string | feathersOptions): FeathersApplication;\n```\n#### feathersOptions\n\n```ts\ninterface feathersOptions {\n  endpoint: string;\n  headers?: RequestHeader;\n  tokenStorageKey?: string;\n}\n```\n\n### bindApps function\n\n```ts\nfunction bindApps(app: WxApp, page: WxPage, fapp: FeathersApplication): InitApp;\n```\n\n#### InitApp function\n\n```ts\nfunction InitApp(wxAppOptions: object): void;\n```\n\n### setup function\n\n```ts\nfunction setup(feathersOptions: string | feathersOptions, wxAppOptions: object): bool;\n```\n\n### http/fetch/Logger functions\n\nsee [@xixilive/weapp-fetch](https://github.com/xixilive/weapp-fetch)\n\n### storage interface\n\n```ts\ninterface storage {\n  getItem(key: string): any;\n  setItem(key: string, value: any): void;\n  removeItem(key: string): void;\n  clear(): void;\n\n  getItemAsync(key: string): Promise\u003cany\u003e;\n  setItemAsync(key: string, value: any): Promise\u003cany\u003e;\n  removeItemAsync(key: string): Promise\u003cany\u003e;\n  clearAsync(): Promise\u003cany\u003e;\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxixilive%2Ffeathers-client-weapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxixilive%2Ffeathers-client-weapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxixilive%2Ffeathers-client-weapp/lists"}