Dingle NodeJS
Dingle Generator for NodeJS
Installation
$ npm install --save dingle-nodejs
Dependancies
You will need the following module in your project:
npm install --save request
Usage
Simply require the dingle generator module and specify the directory to build into:
var dingle = http_listen: '0.0.0.0' https_listen: '0.0.0.0' tcp_listen: '0.0.0.0' udp_listen: '0.0.0.0'; var generator = ;generator;
Then simply drop the files generated into your node project and use like so:
var myapi = ; myapi;
Hostnames
When the code is generated your hostnames are automatically taken from the dingle config but you can change it like so:
var myapi = ; myapihttp = "localhost:7691";myapihttps = "localhost:7692";myapitcp = "localhost:7693";myapiudp = "localhost:7694"; myapi;
File Uploads
To upload a file simply specify a read stream as a parameter as shown below:
var fs = ;var myapi = ; myapi;
File Downloads
When downloading a file you must specify a stream to write to and once the download is complete the stream will be returned in the output variable callback:
var fs = ;var myapi = ; myapi;
Choosing Method
By default dingle will auto choose each method depending on the order of which they are specified in the function but we can override this like so:
var myapi = ; myapi;
Methods
The following methods are supported:
- TCP
- UDP
- POST
- GET
- PUT
- DELETE
- OPTIONS
- HEAD
- PATCH
- TRACE
- CONNECT