@chuxingpay/ts-soa-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

ts-soa-sdk

Fuxun SOA Services SDK By TypeScript

依赖

安装

npm i @chuxingpay/ts-soa-sdk

Examples

调用fuxun-os接口

const { SOARequest, UserDefinition } = require('ts-soa-sdk')

// 使用内置定义
SOARequest.build(UserDefinition)
const userApi = new SOARequest({ name: 'fuxun-os', version: '1.3.2' })

const token = 'this is token'
userApi.setToken(token)

// 使用链式函数调用(需调用 build 函数传入接口定义)
const { body } = await userApi.users('5e05aabbe822584091f4ef55').policies()

// 使用链接调用(无需 build)
const { body } = await userApi.post('/users/5e05aabbe822584091f4ef55/policies')

调用 soa 服务接口

// 手动传入定义
SOARequest.build({
  links: [{
    href: '/reservations/list',
    method: 'POST'
  }]
})

const paymentApi = new SOARequest({ name, version })
paymentApi.setHost('http://soapayment')

// 设置 appKey
const appKey = 'this is appkey'
paymentApi.setAppKey(appKey)

const { body } = await paymentApi.reservations().list().exec({
  headers: {
    'x-pagination-limit': 20,
    'x-pagination-no': 1
  }
})

Dependencies (6)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @chuxingpay/ts-soa-sdk

    Weekly Downloads

    13

    Version

    1.0.6

    License

    ISC

    Unpacked Size

    29.3 kB

    Total Files

    29

    Last publish

    Collaborators

    • canliu
    • jonny.huang
    • qiuxiaoming
    • leeqiang
    • anxing131
    • destec