Wondering what‚Äôs next for npm?Check out our public roadmap! ¬Ľ

    @yuque/sdk

    1.1.1¬†‚Äʬ†Public¬†‚Äʬ†Published

    Node SDK for yuque

    NPM version build status Test coverage David deps Known Vulnerabilities NPM download

    Install

    npm i @yuque/sdk --save

    Usage

    const SDK = require('@yuque/sdk');
    const client = new SDK({
      token: '<YOUR TOKEN>',
      // other options
    });
     
    const result = await client.users.get();
    console.log(result);
     
    // apis
    const { users, groups, repos, docs } = client;

    Options

    /**
     * @param {Object} options - opts
     * @param {String} options.token - yuque token, https://www.yuque.com/settings/tokens
     * @param {String} [options.endpoint] - yuque endpoint
     * @param {String} [options.userAgent] - request user-agent
     * @param {Object} [options.requestOpts] - default request options of [urllib](https://www.npmjs.com/package/urllib)
     * @param {Function} [options.handler] - special how to handler response
     */

    by default, will return response.data.data, you can custom it by handler:

    new SDK({
      handler(res) {
        // should handler error yourself
        if (res.status !== 200) {
          const err = new Error(res.data.message);
          /* istanbul ignore next */
          err.status = res.data.status || res.status;
          err.code = res.data.code;
          err.data = res;
          throw err;
        }
        // return whatever you want
        const { data, abilities } = res.data;
        return data;
      },
    });

    Debug

    $ http_proxy=http://127.0.0.1:8888 TOKEN=<YOUR_TOKEN> npm test

    API

    see Yuque API Docs for more details.

    users

    see the source.

    groups

    see the source.

    repos

    see the source.

    docs

    see the source.

    TODO

    • API docs
    • JSDocs definition for result info
    • add d.ts or refactor to TypeScript

    Keywords

    none

    Install

    npm i @yuque/sdk

    DownloadsWeekly Downloads

    515

    Version

    1.1.1

    License

    MIT

    Unpacked Size

    19.4 kB

    Total Files

    9

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar