How to use the @creditkarma/thrift-server-core.process function in @creditkarma/thrift-server-core

To help you get started, we’ve selected a few @creditkarma/thrift-server-core 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 alitelabs / tyx / src / core / thrift.ts View on Github external
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;
  }
}
github creditkarma / thrift-server / packages / thrift-server-express / src / main / ThriftServerExpress.ts View on Github external
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)
        }