wilfrem | 2c69b5a | 2015-04-20 19:24:50 +0900 | [diff] [blame] | 1 | import thrift = require("thrift"); |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame] | 2 | var program = require("commander"); |
| 3 | import ThriftTest = require("./gen-nodejs/ThriftTest"); |
| 4 | import test_handler = require("./test_handler"); |
wilfrem | 2c69b5a | 2015-04-20 19:24:50 +0900 | [diff] [blame] | 5 | |
| 6 | program |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame] | 7 | .option("--port <port>", "Set thrift server port", 9090) |
| 8 | .option("--promise", "test with promise style functions") |
| 9 | .option("--protocol", '"Set thrift protocol (binary) [protocol]"') |
wilfrem | 2c69b5a | 2015-04-20 19:24:50 +0900 | [diff] [blame] | 10 | .parse(process.argv); |
| 11 | |
| 12 | var port: number = program.port; |
| 13 | |
| 14 | var options: thrift.ServerOptions = { |
| 15 | transport: thrift.TBufferedTransport, |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame] | 16 | protocol: thrift.TBinaryProtocol, |
wilfrem | 2c69b5a | 2015-04-20 19:24:50 +0900 | [diff] [blame] | 17 | }; |
| 18 | |
| 19 | var server: thrift.Server; |
| 20 | if (program.promise) { |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame] | 21 | server = thrift.createServer( |
| 22 | ThriftTest.Processor, |
| 23 | new test_handler.AsyncThriftTestHandler(), |
| 24 | options, |
| 25 | ); |
wilfrem | 2c69b5a | 2015-04-20 19:24:50 +0900 | [diff] [blame] | 26 | } else { |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame] | 27 | server = thrift.createServer( |
| 28 | ThriftTest.Processor, |
| 29 | new test_handler.SyncThriftTestHandler(), |
| 30 | options, |
| 31 | ); |
wilfrem | 2c69b5a | 2015-04-20 19:24:50 +0900 | [diff] [blame] | 32 | } |
| 33 | server.listen(port); |