Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
socket.addListener('data', (chunk: Buffer) => {
if (count < 1) {
count += 1
const upgradeResponse: TTwitter.IUpgradeReply = {}
const writer: thrift.TTransport = new thrift.BufferedTransport()
const output: thrift.TProtocol = new thrift.BinaryProtocol(
writer,
)
output.writeMessageBegin(
'add',
thrift.MessageType.CALL,
1,
)
TTwitter.UpgradeReplyCodec.encode(
upgradeResponse,
output,
)
output.writeMessageEnd()
socket.write(frameCodec.encode(writer.flush()))
} else {
const responseHeader = new TTwitter.ResponseHeader(
{},
socket.addListener('data', (chunk: Buffer) => {
const meta: IMetadata = { traceId: 9 }
const writer: thrift.TTransport = new thrift.BufferedTransport()
const output: thrift.TProtocol = new thrift.BinaryProtocol(
writer,
)
output.writeMessageBegin(
'add',
thrift.MessageType.CALL,
1,
)
const result = new Calculator.Add__Result({
success: 89,
})
result.write(output)
output.writeMessageEnd()
const data: Buffer = writer.flush()
thrift
.appendThriftObject(meta, data, MetadataCodec)
output.writeMessageBegin(
'add',
thrift.MessageType.CALL,
1,
)
TTwitter.UpgradeReplyCodec.encode(
upgradeResponse,
output,
)
output.writeMessageEnd()
res.writeHead(200)
res.end(writer.flush())
} else {
const responseHeader: TTwitter.IResponseHeader = {}
const writer: thrift.TTransport = new thrift.BufferedTransport()
const output: thrift.TProtocol = new thrift.BinaryProtocol(
writer,
)
output.writeMessageBegin(
'add',
thrift.MessageType.CALL,
1,
)
const result = new Calculator.Add__Result({
success: 61,
})
result.write(output)
output.writeMessageEnd()
const data: Buffer = writer.flush()
thrift
.appendThriftObject(
(
req: http.IncomingMessage,
res: http.ServerResponse,
): void => {
if (count < 1) {
count += 1
const upgradeResponse: TTwitter.IUpgradeReply = {}
const writer: thrift.TTransport = new thrift.BufferedTransport()
const output: thrift.TProtocol = new thrift.BinaryProtocol(
writer,
)
output.writeMessageBegin(
'add',
thrift.MessageType.CALL,
1,
)
TTwitter.UpgradeReplyCodec.encode(
upgradeResponse,
output,
)
output.writeMessageEnd()
res.writeHead(200)
res.end(writer.flush())
} else {
const responseHeader: TTwitter.IResponseHeader = {}