Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}
}
}
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);
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);
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);
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);
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);
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);
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);