Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async execute(req: HttpRequest, ctx: ThriftContext): Promise {
const buffer: Buffer = Buffer.from(req.buffer); // await rawBody(context.req);
const method: string = readThriftMethod(buffer, this.transport, this.protocol);
ctx.thrift = {
requestMethod: method,
processor: this.pluginOptions.handler,
transport: this.pluginOptions.transport || 'buffered',
protocol: this.pluginOptions.protocol || 'binary',
};
const result = await process({
processor: this.pluginOptions.handler,
buffer,
Transport: this.transport,
Protocol: this.protocol,
context: ctx
});
return result;
}
}
const Protocol: IProtocolConstructor = getProtocol(
pluginOptions.protocol,
)
const buffer: Buffer = request.body
const method: string = readThriftMethod(buffer, Transport, Protocol)
request.thrift = {
requestMethod: method,
processor: pluginOptions.handler,
transport: pluginOptions.transport || 'buffered',
protocol: pluginOptions.protocol || 'binary',
}
try {
process({
processor: pluginOptions.handler,
buffer,
Transport,
Protocol,
context: request,
}).then(
(result: any) => {
response.status(200).end(result)
},
(err: any) => {
next(err)
},
)
} catch (err) {
next(err)
}