1import thrift = require("thrift"); 2var program = require('commander'); 3import ThriftTest = require('./gen-nodejs/ThriftTest'); 4import test_handler = require('./test_handler'); 5 6 7program 8 .option('--port <port>', 'Set thrift server port', 9090) 9 .option('--promise', 'test with promise style functions') 10 .option('--protocol', '"Set thrift protocol (binary) [protocol]"') 11 .parse(process.argv); 12 13var port: number = program.port; 14 15var options: thrift.ServerOptions = { 16 transport: thrift.TBufferedTransport, 17 protocol: thrift.TBinaryProtocol 18}; 19 20var server: thrift.Server; 21if (program.promise) { 22 server = thrift.createServer(ThriftTest.Processor, new test_handler.AsyncThriftTestHandler(), options); 23} else { 24 server = thrift.createServer(ThriftTest.Processor, new test_handler.SyncThriftTestHandler(), options); 25} 26server.listen(port); 27