How to use the @creditkarma/thrift-client.HttpConnection function in @creditkarma/thrift-client

To help you get started, we’ve selected a few @creditkarma/thrift-client 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 / thrift-server / packages / thrift-integration / src / client / connections / HttpConnection.spec.ts View on Github external
it('should reject when middleware does not add auth token', async () => {
            const connection: HttpConnection = new HttpConnection({
                serviceName: 'Calculator',
                hostName: HAPI_CALC_SERVER_CONFIG.hostName,
                port: HAPI_CALC_SERVER_CONFIG.port,
                path: HAPI_CALC_SERVER_CONFIG.path,
            })
            const client = new Calculator.Client(connection)

            return client.addWithContext(5, 7).then(
                (response: number) => {
                    throw new Error(
                        `Mehtods should fail when middleware rejects`,
                    )
                },
                (err: any) => {
                    expect(err.message).to.equal('Unauthorized')
                },
github creditkarma / thrift-server / packages / thrift-integration / src / client / connections / HttpConnection.spec.ts View on Github external
it('should reject for a 400 server response', async () => {
            const badConnection: HttpConnection = new HttpConnection({
                serviceName: 'Calculator',
                hostName: HAPI_CALC_SERVER_CONFIG.hostName,
                port: HAPI_CALC_SERVER_CONFIG.port,
                path: '/return400',
            })
            const badClient: Calculator.Client<
                IRequest
            > = new Calculator.Client(badConnection)

            return badClient.add(5, 7).then(
                (response: number) => {
                    throw new Error('Should reject with status 400')
                },
                (err: any) => {
                    expect(err.statusCode).to.equal(400)
                },
github creditkarma / thrift-server / packages / thrift-integration / src / client / connections / HttpConnection.spec.ts View on Github external
it('should resolve when middleware passes method filter', async () => {
            const connection: HttpConnection = new HttpConnection({
                serviceName: 'Calculator',
                hostName: HAPI_CALC_SERVER_CONFIG.hostName,
                port: HAPI_CALC_SERVER_CONFIG.port,
                path: HAPI_CALC_SERVER_CONFIG.path,
            })
            const client = new Calculator.Client(connection)

            connection.register({
                methods: ['add'],
                handler(
                    req: IThriftRequest,
                    next: NextFunction,
                ): Promise {
                    if (thrift.readThriftMethod(req.data) === 'add') {
                        return next()
                    } else {
github creditkarma / thrift-server / packages / thrift-integration / src / client / connections / HttpConnection.spec.ts View on Github external
before(async () => {
            connection = new HttpConnection({
                serviceName: 'Calculator',
                hostName: 'localhost',
                port: PORT,
            })

            connection.register(
                ThriftClientTTwitterFilter({
                    localServiceName: 'http-calculator-client',
                    remoteServiceName: 'calculator-service',
                    tracerConfig: {
                        endpoint: 'http://localhost:9411/api/v1/spans',
                        sampleRate: 1,
                        httpInterval: 0,
                    },
                }),
            )
github creditkarma / thrift-server / packages / thrift-integration / src / client / connections / HttpConnection.spec.ts View on Github external
before(async () => {
            connection = new HttpConnection({
                serviceName: 'Calculator',
                hostName: HAPI_CALC_SERVER_CONFIG.hostName,
                port: HAPI_CALC_SERVER_CONFIG.port,
                path: HAPI_CALC_SERVER_CONFIG.path,
            })
            client = new Calculator.Client(connection)
        })