blob: a2ef5c698ca4aa48592d6aa4375e1b39f9972378 [file] [log] [blame]
wilfrem2c69b5a2015-04-20 19:24:50 +09001import thrift = require("thrift");
Cameron Martinfdaca5e2025-01-07 15:25:15 +00002import { program } from 'commander';
3import ThriftTest = require('./gen-nodejs/ThriftTest');
4import test_handler = require('./test_handler');
5
wilfrem2c69b5a2015-04-20 19:24:50 +09006
7program
CJCombrinkdfeab8d2026-03-06 07:03:56 +01008 .option('--port <port>', 'Set thrift server port', (v) => parseInt(v, 10), 9090)
Cameron Martinfdaca5e2025-01-07 15:25:15 +00009 .option('--promise', 'test with promise style functions')
CJCombrinkdfeab8d2026-03-06 07:03:56 +010010 .option('--protocol <protocol>', '"Set thrift protocol (binary) [protocol]"')
11 .option('--transport <transport>', '"Set thrift transport (buffered) [transport]"')
wilfrem2c69b5a2015-04-20 19:24:50 +090012 .parse(process.argv);
13
Cameron Martinfdaca5e2025-01-07 15:25:15 +000014var opts = program.opts();
15var port: number = opts.port;
wilfrem2c69b5a2015-04-20 19:24:50 +090016
17var options: thrift.ServerOptions = {
18 transport: thrift.TBufferedTransport,
Cameron Martincaef0ed2025-01-15 11:58:39 +010019 protocol: thrift.TBinaryProtocol,
wilfrem2c69b5a2015-04-20 19:24:50 +090020};
21
22var server: thrift.Server;
Cameron Martinfdaca5e2025-01-07 15:25:15 +000023if (opts.promise) {
24 server = thrift.createServer(ThriftTest.Processor, new test_handler.AsyncThriftTestHandler(), options);
wilfrem2c69b5a2015-04-20 19:24:50 +090025} else {
Cameron Martincaef0ed2025-01-15 11:58:39 +010026 server = thrift.createServer(
27 ThriftTest.Processor,
28 new test_handler.SyncThriftTestHandler(),
29 options,
30 );
wilfrem2c69b5a2015-04-20 19:24:50 +090031}
32server.listen(port);