@shayin/express-api

n/a

Usage no npm install needed!

<script type="module">
  import shayinExpressApi from 'https://cdn.skypack.dev/@shayin/express-api';
</script>

README

express-api

这个项目是用来学学写一下 TypeScript 的。

NPM version npm type definitions npm license

What

整合不同的快递查询服务器,并统一输出格式。

Usage

Npm:

$ npm install @shayin/express-api

或者 Yarn:

$ yarn add @shayin/express-api

例子:

import {ExpressApi} from '@shayin/express-api';
import {Baidu} from '@shayin/express-api/baidu';
import {Kuaidi100} from '@shayin/express-api/kuaidi100';

const expressApi = new ExpressApi();
// 添加不同的接口
// 查询的时候会根据加入的顺序调用,如果失败则尝试下一个
expressApi.addApi(new Kuaidi100());
expressApi.addApi(new Baidu());

// 查询
expressApi
  // 这是随便写的单号,不能用来查询
  .query({postId: '293847293412', type: 'shentong'})
  .then(({data, errors}) => {
    // 在这处理 data, errors
  });

License

MIT