Skip to content

Instantly share code, notes, and snippets.

@dhendo
Created March 23, 2012 08:47
Show Gist options
  • Save dhendo/2168516 to your computer and use it in GitHub Desktop.
Save dhendo/2168516 to your computer and use it in GitHub Desktop.
webservice.js Test
this.title = "Welcome to your webservice!";
this.name = "demo api module";
this.version = "0.1.0";
this.endpoint = "http://localhost:8556";
exports.echo = function(options, callback){
callback(null, options.msg);
};
exports.echo.description = "this is the echo method, it echos back your msg";
exports.echo.schema = {
msg: {
type: 'string',
optional: false
}
};
exports.ping = function(options, callback){
setTimeout(function(){
callback(null, 'pong');
}, 2000);
}
exports.ping.description = "this is the ping method, it pongs back after a 2 second delay";
var webservice = require('webservice');
var demoModule = require('./demoModule.js');
webservice.createServer(demoModule).listen(8556);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment