diff --git a/src/app.controller.spec.ts b/src/app.controller.spec.ts deleted file mode 100644 index d22f389..0000000 --- a/src/app.controller.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; - -describe('AppController', () => { - let appController: AppController; - - beforeEach(async () => { - const app: TestingModule = await Test.createTestingModule({ - controllers: [AppController], - providers: [AppService], - }).compile(); - - appController = app.get(AppController); - }); - - describe('root', () => { - it('should return "Hello World!"', () => { - expect(appController.getHello()).toBe('Hello World!'); - }); - }); -}); diff --git a/src/app.controller.ts b/src/app.controller.ts deleted file mode 100644 index 9ceff7c..0000000 --- a/src/app.controller.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Controller, Post, Get, Body } from '@nestjs/common'; -import { AppService } from './app.service'; -import { BaseResponse, UpdateInfoRequest } from './interfaces'; - -@Controller() -export class AppController { - constructor(private readonly appService: AppService) {} - - @Get() - getHello(): string { - return this.appService.getHello(); - } - - @Post('/validate-info') - getConfig(@Body() bodyRequest: UpdateInfoRequest): Promise { - return this.appService.validateInfo(bodyRequest); - } -} diff --git a/src/app.module.ts b/src/app.module.ts index 8662803..68033dd 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,10 +1,9 @@ import { Module } from '@nestjs/common'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; +import { InfoModule } from './info/info.module'; @Module({ - imports: [], - controllers: [AppController], - providers: [AppService], + imports: [InfoModule], + controllers: [], + providers: [], }) export class AppModule {} diff --git a/src/info/info.controller.ts b/src/info/info.controller.ts new file mode 100644 index 0000000..f5be68c --- /dev/null +++ b/src/info/info.controller.ts @@ -0,0 +1,14 @@ +import { Controller, Post, Body } from '@nestjs/common'; +import { InfoService } from './info.service'; +import { UpdateInfoRequest } from './interfaces'; +import { BaseResponse } from '../interfaces'; + +@Controller('info') +export class InfoController { + constructor(private readonly infoService: InfoService) {} + + @Post('/validate') + getConfig(@Body() bodyRequest: UpdateInfoRequest): Promise { + return this.infoService.validateInfo(bodyRequest); + } +} diff --git a/src/info/info.module.ts b/src/info/info.module.ts new file mode 100644 index 0000000..7cedf96 --- /dev/null +++ b/src/info/info.module.ts @@ -0,0 +1,10 @@ +import { Module } from '@nestjs/common'; +import { InfoController } from './info.controller'; +import { InfoService } from './info.service'; + +@Module({ + imports: [], + controllers: [InfoController], + providers: [InfoService], +}) +export class InfoModule {} diff --git a/src/app.service.ts b/src/info/info.service.ts similarity index 76% rename from src/app.service.ts rename to src/info/info.service.ts index 4686a93..7453a5a 100644 --- a/src/app.service.ts +++ b/src/info/info.service.ts @@ -1,18 +1,12 @@ import { Injectable } from '@nestjs/common'; import { plainToClass } from 'class-transformer'; import { validate } from 'class-validator'; -import { - BaseResponse, - UpdateInfoRequest as UpdateInfoRequestInterface, -} from './interfaces'; +import { UpdateInfoRequest as UpdateInfoRequestInterface } from './interfaces'; +import { BaseResponse } from '../interfaces'; import { UpdateInfoRequest } from './models'; @Injectable() -export class AppService { - getHello(): string { - return 'Hello World!'; - } - +export class InfoService { async validateInfo( rawData: UpdateInfoRequestInterface, ): Promise { diff --git a/src/info/interfaces/index.ts b/src/info/interfaces/index.ts new file mode 100644 index 0000000..0045845 --- /dev/null +++ b/src/info/interfaces/index.ts @@ -0,0 +1,3 @@ +export interface UpdateInfoRequest { + name: string; +} diff --git a/src/models/index.ts b/src/info/models/index.ts similarity index 100% rename from src/models/index.ts rename to src/info/models/index.ts diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts index 25e3e54..6ed0686 100644 --- a/src/interfaces/index.ts +++ b/src/interfaces/index.ts @@ -1,9 +1,5 @@ import { ValidationError } from 'class-validator'; -export interface UpdateInfoRequest { - name: string; -} - interface BaseResponseInteface { success: boolean; data?: any;