Skip to content

Commit f7936f8

Browse files
committed
move s3client to another file
1 parent aacf1db commit f7936f8

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

src/server/routes/rag/ragIndex.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { type NextFunction, type Request, type Response, Router } from 'express'
22
import multer from 'multer'
33
import z from 'zod/v4'
4-
import { S3Client } from '@aws-sdk/client-s3'
54
import multerS3 from 'multer-s3'
65
import { shouldRenderAsText } from '../../../shared/utils'
76
import { ChatInstance, RagFile, RagIndex, Responsibility } from '../../db/models'
@@ -12,17 +11,8 @@ import { ingestRagFiles } from '../../services/rag/ingestion'
1211
import { search } from '../../services/rag/search'
1312
import { getRedisVectorStore } from '../../services/rag/vectorStore'
1413
import { SearchSchema } from '../../../shared/rag'
15-
import { S3_ACCESS_KEY, S3_BUCKET, S3_HOST, S3_SECRET_ACCESS_KEY } from '../../util/config'
16-
17-
export const s3Client = new S3Client({
18-
region: 'us-east-1',
19-
endpoint: S3_HOST,
20-
forcePathStyle: true,
21-
credentials: {
22-
accessKeyId: S3_ACCESS_KEY,
23-
secretAccessKey: S3_SECRET_ACCESS_KEY,
24-
},
25-
})
14+
import { S3_BUCKET } from '../../util/config'
15+
import { s3Client } from '../../util/s3client'
2616

2717
const ragIndexRouter = Router()
2818

src/server/services/rag/fileStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { RagFile, RagIndex } from '../../db/models'
1010
import { ApplicationError } from '../../util/ApplicationError'
1111
import { pdfToText, pdfToTextWithVLM } from '../../util/pdfToText'
1212
import { S3_BUCKET } from '../../util/config'
13-
import { s3Client } from '../../routes/rag/ragIndex'
13+
import { s3Client } from '../../util/s3client'
1414

1515
const isPdf = (filePath: string) => filePath.endsWith('.pdf')
1616
const getPdfTextKey = (s3Key: string) => `${s3Key}.txt`

src/server/util/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ export const REDIS_HOST = getEnv('REDIS_HOST', 'redis')
2626

2727
export const REDIS_PORT = 6379
2828

29-
export const BMQ_REDIS_HOST = getEnv('BMQ_REDIS_HOST', 'placeholder')
29+
export const BMQ_REDIS_HOST = getEnv('BMQ_REDIS_HOST', REDIS_HOST)
3030

31-
export const BMQ_REDIS_PORT = getEnv('BMQ_REDIS_PORT', 'placeholder')
31+
export const BMQ_REDIS_PORT = getEnv('BMQ_REDIS_PORT', String(REDIS_PORT))
3232

3333
export const BMQ_REDIS_CA = getEnv('BMQ_REDIS_CA', 'none')
3434

src/server/util/s3client.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { S3Client } from '@aws-sdk/client-s3'
2+
import { S3_ACCESS_KEY, S3_HOST, S3_SECRET_ACCESS_KEY } from './config'
3+
4+
export const s3Client = new S3Client({
5+
region: 'us-east-1',
6+
endpoint: S3_HOST,
7+
forcePathStyle: true,
8+
credentials: {
9+
accessKeyId: S3_ACCESS_KEY,
10+
secretAccessKey: S3_SECRET_ACCESS_KEY,
11+
},
12+
})

0 commit comments

Comments
 (0)