Skip to content

Commit

Permalink
Feat/gpt 나쁜말 고르는 로직 썼다. gpt 써ㅅ서 (#27)
Browse files Browse the repository at this point in the history
* Feat: Add gpt key in env

* Feat: Add method checking if the word user provide is bad word or not through gpt

* Chore: Remove useless

* Feat: Add try catch in gpt service

* Feat: Add return type
  • Loading branch information
Ho-s authored Jun 29, 2024
1 parent 865656a commit b110b01
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 0 deletions.
1 change: 1 addition & 0 deletions .example.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ KAKAO_CLIENT_ID=
KAKAO_REDIRECT_URL=
KAKAO_REST_API_KEY=
CLIENT_URL=
GPT_KEY=

PORT=8000

Expand Down
1 change: 1 addition & 0 deletions additional.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ declare namespace NodeJS {
KAKAO_REDIRECT_URL: string;
KAKAO_REST_API_KEY: string;
CLIENT_URL: string;
GPT_KEY: string;

// for test
TEST_USER_ID?: number;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"cookie-parser": "^1.4.6",
"joi": "^17.13.3",
"moment-timezone": "^0.5.45",
"openai": "^4.52.2",
"passport-custom": "^1.1.1",
"passport-jwt": "^4.0.1",
"passport-kakao": "^1.0.1",
Expand Down
132 changes: 132 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { AppService } from './app.service';
import { AuthModule } from './auth/auth.module';
import { getNodeEnv, isIgnoreEnvFile } from './common/helper/env.helper';
import { envValidation } from './common/helper/env.validation';
import { GptModule } from './gpt/gpt.module';
import { MapModule } from './map/map.module';
import { SearchModule } from './search/search.module';
import { UserMapModule } from './user-map/user-map.module';
Expand All @@ -29,6 +30,7 @@ import { UserModule } from './user/user.module';
UserModule,
MapModule,
UserMapModule,
GptModule,
SearchModule,
],
controllers: [AppController],
Expand Down
3 changes: 3 additions & 0 deletions src/common/helper/env.validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export class EnvironmentVariables {

@IsString()
CLIENT_URL: string;

@IsString()
GPT_KEY: string;
}

export function envValidation(config: Record<string, unknown>) {
Expand Down
19 changes: 19 additions & 0 deletions src/gpt/gpt.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Controller, Get, Injectable, Param } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';

import { UseAuthGuard } from 'src/common/decorators/auth-guard.decorator';

import { GptService } from './gpt.service';

@Injectable()
@ApiTags('gpt')
@Controller('gpt')
export class GptController {
constructor(private readonly gptService: GptService) {}

@Get(':word')
@UseAuthGuard(['ADMIN'])
checkIfIsBadWordx(@Param('word') word: string) {
return this.gptService.checkIfIsBadwordWithGpt(word);
}
}
12 changes: 12 additions & 0 deletions src/gpt/gpt.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Module } from '@nestjs/common';

import { GptController } from './gpt.controller';
import { GptService } from './gpt.service';

@Module({
imports: [],
controllers: [GptController],
providers: [GptService],
exports: [GptService],
})
export class GptModule {}
Loading

0 comments on commit b110b01

Please sign in to comment.