npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@feathers-weapp/client

v0.1.5

Published

adapts feathers rest client for wechat mini-program

Downloads

8

Readme

To adapts feathers rest client for wechat mini-program 微信小程序

Travis (.org) branch npm bundle size npm version Known Vulnerabilities NPM license

Installation

# 小程序开发者工具构建npm包时仅处理production依赖,因此要加`--save-prod`
npm i @feathers-weapp/client --save-prod

# or
yarn add @feathers-weapp/client --save

Usage

use feathers services only

import {feathers} from '@feathers-weapp/client'

const app = feathers('https://api.endpoint')

app.authenticate({strategy: 'weapp', code: 'logincode', ...})
  .then(res => console.log('authenticated', res))

app.service('something').once('created', data => console.log('created', data))
app.service('something').create(data).then(res => console.log('created', res))

bind feathers app with wx App and Page

NOTE: bind API makes code pollution in App and Page

// in App.js
import {feathers, bindApps, setup} from '@feathers-weapp/client'
const app = feathers('https://endpoint.api')

// bind
const initApp = bindApps(App, Page, app)
initApp({
  onLaunch(opts){
    // ...
  },

  reAuthOnLaunch: true // will cause automatic JWT authentication on app launch.
})

// or use shortcut
setup('https://endpoint.api', {
  onLaunch(opts){
    // ...
  }
})

Once bind with App and Page, you can use:

  • App.feathers to get the feathers app instance.
  • App.emitter to get an event emitter API, which delegated to the feathersjs's emitter.
  • App.authentication to get the current authentication state.
  • Page.bindAuthentication to bind authentication state with current page, bind this.data.authentication.
/* emitter example */
const unsubscribe = App.emitter.on('event', () => {}) // subscribe
unsubscribe() //unsubscribe, be careful

App.emitter.once('event', () => {})
App.emitter.emit('event', 'event data')

/* bindAuthentication example */
Page({
  onLoad(){
    Page.bindAuthentication(this)
  },

  onTapAction() {
    if(!this.data.authentication.authenticated) {
      console.log('oops')
    }
  }
})

Build Tips

This package was prebuilt as es module to dist folder, and all of source code not be transpiled to ES5 version. If you use this package's default build, you should turn on the ES6 to ES5 option in devtools. If you want a custom build, please clone this repo.

API

// package's exports
import {feathers, bindApps, setup, storage} from '@feather-weapp/client'

// additional exports from @xixilive/weapp-fetch
import {fetch, http, Logger } from '@feather-weapp/client'

feathers function

function feathers(options: string | feathersOptions): FeathersApplication;

feathersOptions

interface feathersOptions {
  endpoint: string;
  headers?: RequestHeader;
  tokenStorageKey?: string;
}

bindApps function

function bindApps(app: WxApp, page: WxPage, fapp: FeathersApplication): InitApp;

InitApp function

function InitApp(wxAppOptions: object): void;

setup function

function setup(feathersOptions: string | feathersOptions, wxAppOptions: object): bool;

http/fetch/Logger functions

see @xixilive/weapp-fetch

storage interface

interface storage {
  getItem(key: string): any;
  setItem(key: string, value: any): void;
  removeItem(key: string): void;
  clear(): void;

  getItemAsync(key: string): Promise<any>;
  setItemAsync(key: string, value: any): Promise<any>;
  removeItemAsync(key: string): Promise<any>;
  clearAsync(): Promise<any>;
}