1#!/usr/bin/env node 2 3/* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * 'License'); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22const thrift = require("../../lib/thrift"); 23const program = require("commander"); 24 25program 26 .option("--port <port>", "Set the thrift server port", 9090) 27 .parse(process.argv); 28 29const Service = require("./gen-2/second-episode/gen-nodejs/Service"); 30const Types = require("types-package/first-episode/Types_types"); 31 32const port = program.port; 33 34const options = { 35 transport: thrift.TBufferedTransport, 36 protocol: thrift.TJSONProtocol 37}; 38 39const ServiceHandler = { 40 testEpisode: function(receivedType1Object) { 41 const type1Object = new Types.Type1(); 42 type1Object.number = receivedType1Object.number + 1; 43 type1Object.message = 44 receivedType1Object.message + " [Hello from the server]"; 45 return type1Object; 46 } 47}; 48 49const server = thrift.createServer(Service, ServiceHandler, options); 50server.listen(port); 51