diff --git a/apps/gateway/src/gateway.controller.spec.ts b/apps/gateway/src/gateway.controller.spec.ts deleted file mode 100644 index 4eb6472..0000000 --- a/apps/gateway/src/gateway.controller.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { GatewayController } from './gateway.controller'; -import { GatewayService } from './gateway.service'; - -describe('GatewayController', () => { - let gatewayController: GatewayController; - - beforeEach(async () => { - const app: TestingModule = await Test.createTestingModule({ - controllers: [GatewayController], - providers: [GatewayService], - }).compile(); - - gatewayController = app.get(GatewayController); - }); - - describe('root', () => { - it('should return "Hello World!"', () => { - expect(gatewayController.getHello()).toBe('Hello World!'); - }); - }); -}); diff --git a/apps/gateway/src/gateway.controller.ts b/apps/gateway/src/gateway.controller.ts deleted file mode 100644 index 2b8f6d7..0000000 --- a/apps/gateway/src/gateway.controller.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Controller, Get } from '@nestjs/common'; -import { GatewayService } from './gateway.service'; - -@Controller() -export class GatewayController { - constructor(private readonly gatewayService: GatewayService) {} - - @Get() - getHello(): string { - return this.gatewayService.getHello(); - } -} diff --git a/apps/gateway/src/gateway.module.ts b/apps/gateway/src/gateway.module.ts index 74c7c63..31d81d1 100644 --- a/apps/gateway/src/gateway.module.ts +++ b/apps/gateway/src/gateway.module.ts @@ -1,10 +1,51 @@ import { Module } from '@nestjs/common'; -import { GatewayController } from './gateway.controller'; -import { GatewayService } from './gateway.service'; +import { ClientsModule, Transport } from '@nestjs/microservices'; +import { PrometheusModule } from '@willsoto/nestjs-prometheus'; +import { ConfigModule } from '@nestjs/config'; +import { WinstonModule } from 'nest-winston'; +import * as winston from 'winston'; +import { AuthController } from './rest/auth.controller'; +import { UserController } from './rest/user.controller'; +import { DriversController } from './rest/driver.controller'; +import { UserService } from './services/user-service'; +import { DriverService } from './services/driver-service'; @Module({ - imports: [], - controllers: [GatewayController], - providers: [GatewayService], + imports: [ + PrometheusModule.register({ + path: '/metrics', + }), + ConfigModule.forRoot(), + ClientsModule.register([ + { + name: 'USER_SERVICE', + transport: Transport.TCP, + options: { + host: 'localhost', + port: 3001, // port of user-service + }, + }, + { + name: 'DRIVER_SERVICE', + transport: Transport.TCP, + options: { + host: 'localhost', + port: 3002, // port of user-service + }, + }, + ]), + WinstonModule.forRoot({ + transports: [ + new winston.transports.Console({ + format: winston.format.combine( + winston.format.timestamp(), + winston.format.simple(), + ), + }) + ], + }), + ], + controllers: [AuthController, UserController, DriversController], + providers: [UserService, DriverService] }) export class GatewayModule {} diff --git a/apps/gateway/src/gateway.service.ts b/apps/gateway/src/gateway.service.ts deleted file mode 100644 index 37b71c8..0000000 --- a/apps/gateway/src/gateway.service.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Injectable } from '@nestjs/common'; - -@Injectable() -export class GatewayService { - getHello(): string { - return 'Hello World!'; - } -}