thrift-server.ts 803 Bytes
Newer Older
1

2
3
// import { GameService } from '../codegen/common/';
import { PlayerService } from '../codegen/common/';
4
5
6
7
8
9
10
11
12
import { ClientServiceHandler } from '../handler/client-service-handler';
import * as express from 'express';
import { createThriftServer } from '@creditkarma/thrift-server-express';

const handler: ClientServiceHandler<express.Request> = new ClientServiceHandler<express.Request>();


export class ThriftServer {
  private app: express.Application;
13
  constructor(port: number) {
14
15
16
17
    this.app = createThriftServer({
      path: '/thrift',
      thriftOptions: {
        serviceName: 'calculator-service',
18
        handler: new PlayerService.Processor(handler),
19
20
      },
    });
21
22
    this.app.listen(port, () => {
      console.log(`Thrift Express server listening on port: ${port}`);
23
24
25
26
    });
  }
}