1.0.0 • Published 8 years ago

sword-connect v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

sword-connect NPM version Build Status

connect middleware for sword group

Installation

$ npm install --save sword-connect

Usage

var koa = require('koa')
var swordConnect = require('sword-connect');

var app = koa()
app.use(swordConnect(opts))

app.use(function *() {
    var rst1 = yield this.connect.get('YOUR-API-URL', {}, opts)  
    var rst2 = yield this.connect.post('YOUR-API-URL', {}, opts)  
})

Methods

  • get
  • post

specify example/test.js to get more usage.

Configuration

opts default value as follows,

{
    hostname: '', // host here will be ip or domain
    port: '80',
    timeoutLimit: 5e3,
    enableLogger: false
}
  • hostname, ip or domain, required
  • port, default is 80
  • timeoutLimit, request timeout, default is 5000ms
  • enableLogger, use sword-logger to log request and response, and more thing to be done. default is false

License

MIT © gejiawen