blob: 79457ce99aa23255ce8aac2c1c96c3ab8040634b [file] [log] [blame]
wilfrem2c69b5a2015-04-20 19:24:50 +09001import thrift = require("thrift");
Cameron Martincaef0ed2025-01-15 11:58:39 +01002var program = require("commander");
3import ThriftTest = require("./gen-nodejs/ThriftTest");
4import test_handler = require("./test_handler");
wilfrem2c69b5a2015-04-20 19:24:50 +09005
6program
Cameron Martincaef0ed2025-01-15 11:58:39 +01007 .option("--port <port>", "Set thrift server port", 9090)
8 .option("--promise", "test with promise style functions")
9 .option("--protocol", '"Set thrift protocol (binary) [protocol]"')
wilfrem2c69b5a2015-04-20 19:24:50 +090010 .parse(process.argv);
11
12var port: number = program.port;
13
14var options: thrift.ServerOptions = {
15 transport: thrift.TBufferedTransport,
Cameron Martincaef0ed2025-01-15 11:58:39 +010016 protocol: thrift.TBinaryProtocol,
wilfrem2c69b5a2015-04-20 19:24:50 +090017};
18
19var server: thrift.Server;
20if (program.promise) {
Cameron Martincaef0ed2025-01-15 11:58:39 +010021 server = thrift.createServer(
22 ThriftTest.Processor,
23 new test_handler.AsyncThriftTestHandler(),
24 options,
25 );
wilfrem2c69b5a2015-04-20 19:24:50 +090026} else {
Cameron Martincaef0ed2025-01-15 11:58:39 +010027 server = thrift.createServer(
28 ThriftTest.Processor,
29 new test_handler.SyncThriftTestHandler(),
30 options,
31 );
wilfrem2c69b5a2015-04-20 19:24:50 +090032}
33server.listen(port);