Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions config/tsoa.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"schema": {
"type": "object",
"properties": {
"base64_image": {
"image": {
"type": "string",
"format": "binary",
"description": "OCR 처리를 위한 이미지 업로드"
Expand All @@ -70,7 +70,7 @@
"schema": {
"type": "object",
"properties": {
"base64_image": {
"image": {
"type": "string",
"format": "binary",
"description": "OCR 처리를 위한 이미지 업로드"
Expand All @@ -81,6 +81,27 @@
}
}
}
},
"/tags/ai": {
"post": {
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"required": ["image"],
"type": "object",
"properties": {
"image": {
"type": "string",
"format": "binary",
"description": "태그라벨 자동생성을 위한 이미지 업로드"
}
}
}
}
}
}
}
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/ai/ai-upload.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const uploadMiddleware = (
res: Response,
next: NextFunction,
) => {
upload.single('base64_image')(req, res, err => {
upload.single('image')(req, res, err => {
if (err) {
next(err);
} else {
Expand Down
15 changes: 1 addition & 14 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,10 @@ import {BaseError} from './errors.js';
import {sessionAuthMiddleware} from './auth.config.js';
import cookieParser from 'cookie-parser';
import {ValidateError} from 'tsoa';
import {labelDetectionController} from './controllers/tags-ai.controller.js';

// routers
import {RegisterRoutes} from './routers/tsoaRoutes.js';
import {authRouter} from './routers/auth.routers.js';
import {userRouter} from './routers/user.router.js';
import {tagRouter} from './routers/tag.router.js';
import {myPageRouter} from './routers/mypage.routers.js';
import {trustRouter} from './routers/trust.router.js';
import upload from './ai/ai-upload.js';

dotenv.config();

Expand Down Expand Up @@ -110,13 +104,6 @@ app.use('/oauth2', authRouter);
app.use(sessionAuthMiddleware);

// 로그인 후
app.use('/onboarding', userRouter);
//app.use('/challenge', challengeRouter);
app.use('/user/mypage', myPageRouter);
app.use('/tag', tagRouter);
app.use('/trust', trustRouter);
app.post('/image/ai', upload.single('base64_image'), labelDetectionController);

RegisterRoutes(app);

app.get('/', (req: Request, res: Response) => {
Expand Down Expand Up @@ -147,7 +134,7 @@ const errorHandler: ErrorRequestHandler = (err, req, res, next) => {
resultType: 'FAIL',
error: {
errorCode: 'VAL-001',
reason: 'Validation Error',
reason: err.message,
data: err.fields,
},
success: null,
Expand Down
Loading