How to use the thrift.createWebServer function in thrift

To help you get started, we’ve selected a few thrift examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github creditkarma / Mimic / packages / mimic-thrift / src / provider.ts View on Github external
public create = (params: IThriftServiceJson): Server => {
    const { id, transport, protocol, service, useHttp, url } = params;
    const api = buildServiceAPI(this.thrift[id]);
    const handler = this.handler(params);
    let server: Server;
    if (useHttp) {
      // HTTP Server
      const options = {
        processor: api[service], handler,
        transport: ThriftProvider.transports[transport],
        protocol: ThriftProvider.protocols[protocol],
        headers: {Server: `mimic: ${process.env.MIMIC_VERSION}`},
      };
      server = createWebServer({ services: { [url || "/"]: options } });
      server.on("request", (request: IncomingMessage, response: ServerResponse) => {
        this.headers[id] = request.headers;
      });
    } else {
      // TCP Server
      server = createServer(api[service], handler, {
        transport: ThriftProvider.transports[transport],
        protocol: ThriftProvider.protocols[protocol],
      });
    }
    this.clients[id] = this.createClient(params, api);
    return server;
  }
github RandyAbernethy / ThriftBook / part3 / js / helloExc.js View on Github external
}
}

var helloErrorOpt = {
    transport: thrift.TBufferedTransport,
    protocol: thrift.TJSONProtocol,
    processor: helloError,
    handler: helloHandler
};

var serverOpt = {
    files: ".",
    services: { "/hello": helloErrorOpt }
}

var server = thrift.createWebServer(serverOpt);
var port = 9099;
server.listen(port);
console.log("Http/Thrift Server running on port: " + port);
console.log("Serving files from: " + __dirname);
github RandyAbernethy / ThriftBook / part3 / js / hello.js View on Github external
processor: helloSvc,                         	
    protocol: thrift.TJSONProtocol,                 
    transport: thrift.TBufferedTransport 		
};                                  

//ServerOptions: Define server features
var serverOpt = {                          	
    files: ".",                        
    services: {                         
        "/hello": helloSvcOpt                 
    }                               
}                                   

//Create and start the web server 
var port = 9090;                            		
thrift.createWebServer(serverOpt).listen(port);                        		
console.log("Http/Thrift Server running on port: " + port);
github apache / thrift / lib / nodejs / examples / hello.js View on Github external
var dblService = {
	transport: thrift.TBufferedTransport,
	protocol: thrift.TJSONProtocol,
	processor: TimesTwoSvc,
	handler: timesTwoHandler
};

var ServerOptions = {
	files: ".",
	services: {
		"/hello": helloService,
		"/dbl": dblService,
	}
}

var server = thrift.createWebServer(ServerOptions);
var port = 8585;
server.listen(port);
console.log("Http/Thrift Server running on port: " + port);
github RandyAbernethy / ThriftBook / part3 / js / csp.js View on Github external
protocol: thrift.TJSONProtocol,                     
    transport: thrift.TBufferedTransport            
};                                  

//ServerOptions: Define server features
var serverOpt = {                               
    files: ".",                        
    services: {"/hello": helloSvcOpt},
    cors: {"http://localhost:9098": true},
    headers: {"Content-Security-Policy": 
                 "default-src 'self'; connect-src http://localhost:9099"}
}                                   

//Create and start the web server
var port = process.argv[2];
thrift.createWebServer(serverOpt).listen(port);                                 
console.log("Http/Thrift Server running on port: " + port);
console.log("Serving files from: " + __dirname);
github RandyAbernethy / ThriftBook / part3 / js / cors.js View on Github external
handler: helloHandler,                              
    processor: helloSvc,                                
    protocol: thrift.TJSONProtocol,                     
    transport: thrift.TBufferedTransport            
};                                  

//ServerOptions: Define server features
var serverOpt = {                               
    files: ".",                        
    services: {"/hello": helloSvcOpt},
    cors: {"http://localhost:9098": true}			
}                                   

//Create and start the web server
var port = process.argv[2];					
thrift.createWebServer(serverOpt).listen(port);		                     
console.log("Http/Thrift Server running on port: " + port);
console.log("Serving files from: " + __dirname);
github claritylab / lucida / lucida / commandcenter / filetransfer_svc.js View on Github external
var ftService = {
	transport: thrift.TBufferedTransport,
	protocol: thrift.TJSONProtocol,
	processor: FileTransferSvc,
	handler: ftsHandler
};

var ServerOptions = {
	files: ".",
	services: {
		"/fts": ftService,
	}
}

var server = thrift.createWebServer(ServerOptions);
var port = process.argv[2]; //8585
var cmdcenterport = process.argv[3]; //8081
server.listen(port);
console.log("Http/Thrift Server running on port: " + port);
github RandyAbernethy / ThriftBook / part3 / js / hello.Tls.js View on Github external
handler: helloHandler
};

var serverOpt = {
    files: ".",
    tls: {						
      key: fs.readFileSync("key.pem"),		
      cert: fs.readFileSync("cert.pem")		
    },						
    services: {
        "/hello": helloSvcOpt
    }
}

var port = 9099;
thrift.createWebServer(serverOpt).listen(port);
console.log("Https/Thrift Server running on port: " + port);