Skip to content
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
c5e90ee
Initial commit
jjiinaaa Dec 23, 2024
74d3768
Update README.md
jjiinaaa Dec 23, 2024
37c686a
[SWEP-1] Jira Test
jjiinaaa Dec 23, 2024
e89ad9f
[SWEP-6] Jira Autumation Test
jjiinaaa Dec 24, 2024
818f37f
[SWEP-6] Jira Autumation Test
jjiinaaa Dec 24, 2024
0654054
[SWEP-17] Server PR Template
jjiinaaa Dec 30, 2024
edf482d
Update README.md
jjiinaaa Dec 30, 2024
30a498e
[SWEP-19] Issue Template
jjiinaaa Dec 30, 2024
7a4143e
[SWEP-17] PR Template
jjiinaaa Dec 31, 2024
5e749fb
[SWEP-19] Issue Template
jjiinaaa Dec 31, 2024
8c01216
Update: issue 템플릿 수정 (#6)
jjiinaaa Jan 4, 2025
7e6ba09
[SWEP-12] 초기 설정 및 Readme 파일 구성 (#10)
jjiinaaa Jan 4, 2025
42bb522
[SWEP-22] CI/CD 파이프라인 구축 (#13)
asjasj3964 Jan 7, 2025
39883ef
[SWEP-28] GTS 적용 및 코드 컨벤션 문서 정리 (#18)
jjiinaaa Jan 9, 2025
c3d8b73
[SWEP-35] Swagger 초기 설정 (#23)
jjiinaaa Jan 9, 2025
04f768f
[SWEP-35] 빌드 시 스웨거 문서 미복사 문제 해결 (#27) (#28)
jjiinaaa Jan 11, 2025
f352ca0
[SWEP-43] AWS S3 클라이언트 설정 및 파일 관리 함수 구현 (#36)
asjasj3964 Jan 15, 2025
18e85a5
[SWEP-36] schema.prisma 작성완료
GodUser1005 Jan 15, 2025
01fafa0
Merge branch 'feat/db-schema' into develop
GodUser1005 Jan 15, 2025
3c0409d
[SWEP-36] migration 파일 일부 수정
GodUser1005 Jan 15, 2025
75fbe25
[SWEP-36] ./src/models/user.model.ts 에서 UserModel 수정
GodUser1005 Jan 15, 2025
d5110da
Merge pull request #39 from GodUser1005/develop
GodUser1005 Jan 15, 2025
6f93856
Merge pull request #40 from Sweepic/feature/SWEP-36
GodUser1005 Jan 16, 2025
833a63f
[SWEP-42] 메모장 POST API 구현 (#46)
asjasj3964 Jan 20, 2025
dbffe8f
[SWEP-37] 위치 기반 챌린지 API
codie0226 Jan 21, 2025
430b84b
[SWEP-51] Session 테이블 수정 및 마이그레이션 추가
GodUser1005 Jan 21, 2025
42d7c85
Merge pull request #56 from GodUser1005/develop
GodUser1005 Jan 21, 2025
c20859e
[SWEP-37] swagger 적용, 피드백 반영 및 코드 수정
codie0226 Jan 21, 2025
fac01c8
Merge pull request #57 from Sweepic/fix/SWEP-51
GodUser1005 Jan 21, 2025
bdae5d4
Merge pull request #52 from Sweepic/feature/SWEP-37
codie0226 Jan 21, 2025
228246f
tsconfig.json update(enable tsoa decorator)
GodUser1005 Jan 22, 2025
6fb3189
[SWEP-50] 메모장 조회 API 구현 (#59)
asjasj3964 Jan 23, 2025
ac82c5f
[SWEP-40] 소셜 로그인 구현 (#62)
Socializedistp Jan 23, 2025
b79cd35
날짜별 태그보기 API 구현
GodUser1005 Jan 23, 2025
faa0b9d
Merge branch 'develop' of github.com:GodUser1005/sweepic-Server into …
GodUser1005 Jan 23, 2025
d5095f2
feat: 태그 검색기능 구현
GodUser1005 Jan 23, 2025
da4df67
chore: tsoa 설정파일 tsoa.json 설정
GodUser1005 Jan 23, 2025
dfe67d3
chore: tsconfig.json node 버전 높은버전사용
GodUser1005 Jan 23, 2025
fa85890
chore: swagger 폴더 생성 및 정적파일 생성
GodUser1005 Jan 23, 2025
b9cd2ae
gitignore update
GodUser1005 Jan 23, 2025
3ea7102
resolve conflict
GodUser1005 Jan 23, 2025
b07d091
Merge pull request #84 from GodUser1005/develop
GodUser1005 Jan 23, 2025
af1f192
resolve conflict app.ts
GodUser1005 Jan 26, 2025
87c9238
resolve conflict app.ts, tsconfig.json
GodUser1005 Jan 26, 2025
50d7316
[SWEP-60] 스웨거 문서 두개로 나눠 출력, git workflow tsoa 스웨거문서 생성 추가
GodUser1005 Jan 27, 2025
418a5f2
Merge branch 'develop' of github.com:GodUser1005/sweepic-Server into …
GodUser1005 Jan 27, 2025
5c93237
[SWEP-60] Image관련 파일명 -> tsoaImage로 변환
GodUser1005 Jan 27, 2025
51c24e6
[SWEP-60] tsoaRoutes.ts 수정
GodUser1005 Jan 27, 2025
5dac6fe
[SWEP-60] build.ts console.log 삭제
GodUser1005 Jan 27, 2025
3459b1b
resolve conflict error response
GodUser1005 Jan 27, 2025
1190a17
memo-ocr 경로관련 코드 수정
GodUser1005 Jan 27, 2025
f3b39f8
[SWEP-60] tsoaResponse 클래스 생성
GodUser1005 Jan 27, 2025
6f8a651
[SWEP-60] tag error 응답 통일
GodUser1005 Jan 27, 2025
16c237c
[SWEP-60] 태그기반 이미지 검색 응답통일
GodUser1005 Jan 27, 2025
cfde138
[SWEP-60] 깃허브 액션 워크플로우 ai-key 전달 추가
GodUser1005 Jan 27, 2025
33dcb61
Merge pull request #114 from GodUser1005/develop
GodUser1005 Jan 27, 2025
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
24 changes: 24 additions & 0 deletions config/tsoa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"noImplicitAdditionalProperties": "throw-on-extras",
"entryFile": "src/app.ts",
"controllerPathGlobs": ["src/controllers/*.controller.ts"],
"spec": {
"outputDirectory": "./swagger",
"host": "localhost:3000",
"specVersion": 3,
"spec": {
"servers": [
{
"url": "http://localhost:3000",
"description": "Sweepic server"
}
]
}
},
"routes": {
"routesDir": "./src/routers",
"middleware": "express",
"routesFileName": "tsoaRoutes.ts",
"esm": true
}
}
10 changes: 9 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import express, {Request, Response, Express, NextFunction} from 'express';
import swaggerAutogen from 'swagger-autogen';
import swaggerUiExpress from 'swagger-ui-express';
import {memoFolderRouter} from './routers/memo.router.js';
import {RegisterRoutes} from './routers/tsoaRoutes.js';
import {challengeRouter} from './routers/challenge.router.js';
import {authRouter} from './routers/auth.routers.js';
import passport from 'passport';
import session from 'express-session';
import {PrismaSessionStore} from '@quixo3/prisma-session-store';
import {prisma} from './db.config.js';
import swaggerDocument from '../swagger/swagger.json' assert {type: 'json'};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분이 문제이군요. 남겨두겠습니다 ~


dotenv.config();

Expand All @@ -25,6 +27,12 @@ app.get('/', (req: Request, res: Response) => {
res.send('Sweepic');
});

// app.use(
// '/docs',
// swaggerUiExpress.serve,
// swaggerUiExpress.setup(swaggerDocument),
// );

app.use(
'/docs',
swaggerUiExpress.serve,
Expand Down Expand Up @@ -80,7 +88,7 @@ app.use((req: Request, res: Response, next: NextFunction) => {
});

app.use('/memo', memoFolderRouter);

RegisterRoutes(app);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거는 뭔가요?

app.use('/challenge', challengeRouter);

app.use(
Expand Down
36 changes: 36 additions & 0 deletions src/controllers/image.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {
Body,
Controller,
Get,
Path,
Post,
Query,
Res,
Route,
SuccessResponse,
Tags,
TsoaResponse,
} from 'tsoa';
import {RequestTagSearch} from '../dtos/image.dto.js';
import {findImagesFromTag} from '../services/image.service.js';
import {StatusCodes} from 'http-status-codes';

@Route('images')
export class ImagesController extends Controller {
@Get('/users/{userId}')
@Tags('Image')
@SuccessResponse('200', 'OK')
public async getImageListFromTag(
@Path() userId: string,
@Query() tag: string,
): Promise<{id: string; mediaId: string}[]> {
const dto = new RequestTagSearch(tag, userId);
console.log(dto);
const images = await findImagesFromTag(dto).catch(err => {
err.statusCode = StatusCodes.NOT_FOUND;
throw err;
});

return images;
}
}
40 changes: 40 additions & 0 deletions src/controllers/tsoaTag.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {
Body,
Controller,
Get,
Path,
Post,
Query,
Res,
Route,
SuccessResponse,
TsoaResponse,
Tags,
} from 'tsoa';
import {findTagsByDate} from '../services/tsoaTag.service.js';
import {DateToTags} from '../dtos/tsoaTag.dto.js';
import {StatusCodes} from 'http-status-codes';

@Route('tags')
export class TagsController extends Controller {
@Get('/users/{userId}')
@Tags('Tag')
@SuccessResponse('200', 'OK')
public async getTagListWithDate(
@Path() userId: string,
@Query() year: number,
@Query() month: number,
@Query() date?: number,
): Promise<{tags: string[]}> {
const dto = new DateToTags(userId, year, month, date);
const tags = await findTagsByDate(dto)
.then(result => {
return {tags: result};
})
.catch(err => {
err.statusCode = StatusCodes.NOT_FOUND;
throw err;
});
return tags;
}
}
9 changes: 9 additions & 0 deletions src/dtos/image.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export class RequestTagSearch {
tag: string;
userId: bigint;

constructor(tag: string, userId: string) {
this.tag = tag;
this.userId = BigInt(userId);
}
}
15 changes: 15 additions & 0 deletions src/dtos/tsoaTag.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export class DateToTags {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 tag 부분의 dto를 간단하게 썼는데 class 사용해서 만드셨네요. 혹시 이유가 있을까요?

createdAt: Date;
userId: bigint;
dateExisted: boolean = true;

constructor(userId: string, year: number, month: number, date?: number) {
if (!date) {
date = 1;
this.dateExisted = false;
}
this.createdAt = new Date(year, month - 1, date);
this.createdAt.setHours(this.createdAt.getHours() + 9);
this.userId = BigInt(userId);
}
}
3 changes: 3 additions & 0 deletions src/models/tsoaTag.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface ResponseFromTags {
tags: string[];
}
31 changes: 31 additions & 0 deletions src/repositories/image.repository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {Image} from '@prisma/client';
import {prisma} from '../db.config.js';

export const selectImagesFromTag = async (
tag: string,
userId: bigint,
): Promise<Pick<Image, 'id' | 'mediaId'>[]> => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 타입은 뭔가요??

const images = await prisma.image.findMany({
where: {
AND: [
{
tags: {
some: {
tag: {
content: tag,
},
},
},
},
{
userId: userId,
},
],
},
select: {
id: true,
mediaId: true,
},
});
return images;
};
46 changes: 46 additions & 0 deletions src/repositories/tsoaTag.repository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {Tag} from '@prisma/client';
import {DateToTags} from '../dtos/tsoaTag.dto.js';
import {prisma} from '../db.config.js';

export const selectTagsByDate = async (
dto: DateToTags,
endDate: Date,
): Promise<Pick<Tag, 'content'>[]> => {
const tags = await prisma.tag
.findMany({
where: {
images: {
some: {
AND: [
{
image: {
createdAt: {
gte: dto.createdAt,
lt: endDate,
},
},
},
{
image: {
userId: dto.userId,
},
},
],
},
},
},
select: {
content: true,
},
orderBy: {
content: 'asc',
},
})
.catch(() => {
throw new Error('DB 에러');
});

console.log(dto.createdAt);
console.log(endDate);
return tags;
};
131 changes: 131 additions & 0 deletions src/routers/tsoaRoutes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/* tslint:disable */
/* eslint-disable */
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
import type {TsoaRoute} from '@tsoa/runtime';
import {fetchMiddlewares, ExpressTemplateService} from '@tsoa/runtime';
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
import {TagsController} from './../controllers/tsoaTag.controller.js';
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
import {ImagesController} from './../controllers/image.controller.js';
import type {
Request as ExRequest,
Response as ExResponse,
RequestHandler,
Router,
} from 'express';

// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa

const models: TsoaRoute.Models = {};
const templateService = new ExpressTemplateService(models, {
noImplicitAdditionalProperties: 'throw-on-extras',
bodyCoercion: true,
});

// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa

export function RegisterRoutes(app: Router) {
// ###########################################################################################################
// NOTE: If you do not see routes for all of your controllers in this file, then you might not have informed tsoa of where to look
// Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/lukeautry/tsoa
// ###########################################################################################################

const argsTagsController_getTagListWithDate: Record<
string,
TsoaRoute.ParameterSchema
> = {
userId: {in: 'path', name: 'userId', required: true, dataType: 'string'},
year: {in: 'query', name: 'year', required: true, dataType: 'double'},
month: {in: 'query', name: 'month', required: true, dataType: 'double'},
date: {in: 'query', name: 'date', dataType: 'double'},
};
app.get(
'/tags/users/:userId',
...fetchMiddlewares<RequestHandler>(TagsController),
...fetchMiddlewares<RequestHandler>(
TagsController.prototype.getTagListWithDate,
),

async function TagsController_getTagListWithDate(
request: ExRequest,
response: ExResponse,
next: any,
) {
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa

let validatedArgs: any[] = [];
try {
validatedArgs = templateService.getValidatedArgs({
args: argsTagsController_getTagListWithDate,
request,
response,
});

const controller = new TagsController();

await templateService.apiHandler({
methodName: 'getTagListWithDate',
controller,
response,
next,
validatedArgs,
successStatus: 200,
});
} catch (err) {
return next(err);
}
},
);
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
const argsImagesController_getImageListFromTag: Record<
string,
TsoaRoute.ParameterSchema
> = {
userId: {in: 'path', name: 'userId', required: true, dataType: 'string'},
tag: {in: 'query', name: 'tag', required: true, dataType: 'string'},
};
app.get(
'/images/users/:userId',
...fetchMiddlewares<RequestHandler>(ImagesController),
...fetchMiddlewares<RequestHandler>(
ImagesController.prototype.getImageListFromTag,
),

async function ImagesController_getImageListFromTag(
request: ExRequest,
response: ExResponse,
next: any,
) {
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa

let validatedArgs: any[] = [];
try {
validatedArgs = templateService.getValidatedArgs({
args: argsImagesController_getImageListFromTag,
request,
response,
});

const controller = new ImagesController();

await templateService.apiHandler({
methodName: 'getImageListFromTag',
controller,
response,
next,
validatedArgs,
successStatus: 200,
});
} catch (err) {
return next(err);
}
},
);
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa

// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa

// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
}

// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
Loading
Loading