Skip to content

Commit

Permalink
refactor: scheduler 서버 backend에서 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
ezcolin2 committed Feb 16, 2025
1 parent 2214daa commit 8c7307f
Show file tree
Hide file tree
Showing 37 changed files with 889 additions and 397 deletions.
9 changes: 4 additions & 5 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
},
"dependencies": {
"@aws-sdk/client-s3": "^3.693.0",
"@huggingface/transformers": "^3.3.3",
"@langchain/community": "^0.3.28",
"@langchain/core": "^0.3.37",
"@langchain/openai": "^0.4.2",
"@langchain/community": "^0.3.30",
"@langchain/core": "^0.3.40",
"@langchain/openai": "^0.4.4",
"@langchain/textsplitters": "^0.1.0",
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.3.0",
Expand Down Expand Up @@ -126,4 +125,4 @@
"@app/exception/(.*)$": "<rootDir>/../../../libs/exception/$1"
}
}
}
}
2 changes: 0 additions & 2 deletions apps/backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { AuthModule } from './auth/auth.module';
import { UserModule } from '@app/user/user.module';
import { WorkspaceModule } from '@app/workspace/workspace.module';
import { RoleModule } from '@app/role/role.module';
import { TasksModule } from './tasks/tasks.module';
import { ScheduleModule } from '@nestjs/schedule';
import { LangchainModule } from './langchain/langchain.module';
import { NodeController } from './node/node.controller';
Expand Down Expand Up @@ -59,7 +58,6 @@ import { TokenService } from '@app/token/token.service';
TokenModule,
WorkspaceModule,
RoleModule,
TasksModule,
LangchainModule,
],
controllers: [
Expand Down
6 changes: 3 additions & 3 deletions apps/backend/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class AuthController {

@Get('naver/callback')
@UseGuards(AuthGuard('naver'))
async naverCallback(@Req() req, @Res() res: Response) {
async naverCallback(@Req() req, @Res() res) {
// 네이버 인증 후 사용자 정보 반환
const user = req.user;

Expand All @@ -66,7 +66,7 @@ export class AuthController {

@Get('kakao/callback')
@UseGuards(AuthGuard('kakao'))
async kakaoCallback(@Req() req, @Res() res: Response) {
async kakaoCallback(@Req() req, @Res() res) {
/// 카카오 인증 후 사용자 정보 반환
const user = req.user;

Expand All @@ -87,7 +87,7 @@ export class AuthController {
@ApiOperation({ summary: '사용자가 로그아웃합니다.' })
@Post('logout')
@UseGuards(JwtAuthGuard) // JWT 인증 검사
logout(@Req() req, @Res() res: Response) {
logout(@Req() req, @Res() res) {
// 쿠키 삭제 (옵션이 일치해야 삭제됨)
this.tokenService.clearCookies(res);
// 현재 자동로그인에 사용되는 refresh Token db에서 삭제
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/auth/guards/jwt-auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class JwtAuthGuard implements CanActivate {

async canActivate(context: ExecutionContext): Promise<boolean> {
const request = context.switchToHttp().getRequest();
const response = context.switchToHttp().getResponse<Response>();
const response = context.switchToHttp().getResponse();

const cookies = request.cookies; // 쿠키에서 가져오기

Expand Down
3 changes: 1 addition & 2 deletions apps/backend/src/langchain/langchain.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Injectable } from '@nestjs/common';
import { ChatOpenAI } from '@langchain/openai';
import { pull } from 'langchain/hub';
import { ChatPromptTemplate } from '@langchain/core/prompts';
import { HuggingFaceTransformersEmbeddings } from '@langchain/community/embeddings/huggingface_transformers';
import { DataSource } from 'typeorm';
import { InjectDataSource } from '@nestjs/typeorm';
Expand All @@ -20,7 +19,7 @@ export class LangchainService {
constructor(@InjectDataSource() private readonly dataSource: DataSource) {}

async query(question: string) {
const promptTemplate = await pull<ChatPromptTemplate>('rlm/rag-prompt');
const promptTemplate = await pull('rlm/rag-prompt');
const queryEmbeddings = await embeddings.embedQuery(question);
// const retrievedDocs = await this.dataSource.query(
// `SELECT content FROM page ORDER BY embedding <=> '[${queryEmbeddings.join(',')}]' LIMIT 1;`,
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/workspace/workspace.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CreateWorkspaceDto } from '@app/workspace/dtos/createWorkspace.dto';
import { WorkspaceResponseMessage } from './workspace.controller';
import { NotWorkspaceOwnerException } from '@app/exception/workspace-auth.exception';
import { UserWorkspaceDto } from '@app/workspace/dtos/userWorkspace.dto';
import { TokenService } from '../auth/token/token.service';
import { TokenService } from '@app/token/token.service';
import { WorkspaceNotFoundException } from '@app/exception/workspace.exception';
import { ForbiddenAccessException } from '@app/exception/access.exception';

Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// vite.config.ts
import { defineConfig, loadEnv } from "file:///app/node_modules/vite/dist/node/index.js";
import react from "file:///app/node_modules/@vitejs/plugin-react/dist/index.mjs";
import tailwindcss from "file:///app/node_modules/tailwindcss/lib/index.js";
import tsconfigPaths from "file:///app/node_modules/vite-tsconfig-paths/dist/index.js";
import { TanStackRouterVite } from "file:///app/node_modules/@tanstack/router-plugin/dist/esm/vite.js";
import removeConsole from "file:///app/node_modules/vite-plugin-remove-console/dist/index.mjs";
function getHostFromUrl(url) {
return url?.replace(/^https?:\/\//, "");
}
var vite_config_default = defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
console.log(`vite_api_url: ${env.VITE_API_URL}`);
return {
plugins: [
TanStackRouterVite({
routesDirectory: "./src/app/routes",
generatedRouteTree: "./src/app/routeTree.gen.ts"
}),
react(),
tsconfigPaths(),
removeConsole()
],
css: {
postcss: {
plugins: [tailwindcss()]
}
},
server: {
host: "0.0.0.0",
port: 5173,
watch: {
usePolling: true,
interval: 1e3
},
hmr: {
protocol: "wss",
clientPort: 443,
path: "hmr/"
},
allowedHosts: [getHostFromUrl(env.VITE_API_URL)]
}
};
});
export {
vite_config_default as default
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiX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1o7QUFBQSxNQUNBLEtBQUs7QUFBQSxRQUNILFVBQVU7QUFBQSxRQUNWLFlBQVk7QUFBQSxRQUNaLE1BQU07QUFBQSxNQUNSO0FBQUEsTUFDQSxjQUFjLENBQUMsZUFBZSxJQUFJLFlBQVksQ0FBQztBQUFBLElBQ2pEO0FBQUEsRUFDRjtBQUNGLENBQUM7IiwKICAibmFtZXMiOiBbXQp9Cg==
25 changes: 25 additions & 0 deletions apps/scheduler/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
56 changes: 56 additions & 0 deletions apps/scheduler/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# compiled output
/dist
/node_modules
/build

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# temp directory
.temp
.tmp

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
4 changes: 4 additions & 0 deletions apps/scheduler/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
99 changes: 99 additions & 0 deletions apps/scheduler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
</p>

[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest

<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->

## Description

[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.

## Project setup

```bash
$ yarn install
```

## Compile and run the project

```bash
# development
$ yarn run start

# watch mode
$ yarn run start:dev

# production mode
$ yarn run start:prod
```

## Run tests

```bash
# unit tests
$ yarn run test

# e2e tests
$ yarn run test:e2e

# test coverage
$ yarn run test:cov
```

## Deployment

When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information.

If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:

```bash
$ yarn install -g mau
$ mau deploy
```

With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.

## Resources

Check out a few resources that may come in handy when working with NestJS:

- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).

## Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).

## Stay in touch

- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)

## License

Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).
9 changes: 9 additions & 0 deletions apps/scheduler/nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
},
"entryFile": "./apps/scheduler/src/main.js"
}
Loading

0 comments on commit 8c7307f

Please sign in to comment.