Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.
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
830 changes: 1 addition & 829 deletions apps/server/openapi.json

Large diffs are not rendered by default.

142 changes: 76 additions & 66 deletions apps/server/src/answer/answer.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
HttpStatus,
UseGuards,
Req,
Param,
Patch,
} from '@nestjs/common';
import { AnswerService } from './answer.service';
import { AuthGuard } from 'src/auth/auth.guard';
Expand All @@ -21,6 +23,14 @@ import {
AnswerRegisResponseDto,
} from './dto/answer-response.dto';
import { UsersService } from 'src/users/users.service';
import {
CreateAnswerAcademicDto,
CreateAnswerRegisDto,
} from 'src/answer/dto/create-answer.dto';
import {
UpdateAnswerAcademicDto,
UpdateAnswerRegisDto,
} from 'src/answer/dto/update-answer.dto';

@Controller('answer')
@UseGuards(AuthGuard)
Expand All @@ -39,19 +49,19 @@ export class AnswerController {
}

//Regis
// @Post('regis')
// async createRegis(@Body() createAnswerDto: CreateAnswerRegisDto) {
// const answerRegis = await this.answerService.createRegis(createAnswerDto);
// if (!answerRegis) {
// throw new HttpException('Not found', HttpStatus.NOT_FOUND);
// }
// return answerRegis;
// }
@Post('regis')
async createRegis(@Body() createAnswerDto: CreateAnswerRegisDto) {
const answerRegis = await this.answerService.createRegis(createAnswerDto);
if (!answerRegis) {
throw new HttpException('Not found', HttpStatus.NOT_FOUND);
}
return answerRegis;
}

// @Get('regis')
// findAllRegis() {
// return this.answerService.findAllRegis();
// }
@Get('regis')
findAllRegis() {
return this.answerService.findAllRegis();
}

@Get('user-regis')
@ApiResponse({ status: 200, type: AnswerRegisResponseDto })
Expand All @@ -62,26 +72,26 @@ export class AnswerController {
return this.answerService.findOneRegisWithUser(req['user_id']);
}

// @Get('regis/:id')
// async findOneRegis(@Param('id') id: string) {
// const answerRegis = await this.answerService.findOneRegis(id);
// if (!answerRegis) {
// throw new HttpException('Not found', HttpStatus.NOT_FOUND);
// }
// return answerRegis;
// }
@Get('regis/:id')
async findOneRegis(@Param('id') id: string) {
const answerRegis = await this.answerService.findOneRegis(id);
if (!answerRegis) {
throw new HttpException('Not found', HttpStatus.NOT_FOUND);
}
return answerRegis;
}

// @Patch('regis/:id')
// updateRegis(
// @Param('id') id: string,
// @Body() updateAnswerDto: UpdateAnswerRegisDto,
// ) {
// const answerRegis = this.answerService.updateRegis(id, updateAnswerDto);
// if (!answerRegis) {
// throw new HttpException('Not found', HttpStatus.NOT_FOUND);
// }
// return answerRegis;
// }
@Patch('regis/:id')
updateRegis(
@Param('id') id: string,
@Body() updateAnswerDto: UpdateAnswerRegisDto,
) {
const answerRegis = this.answerService.updateRegis(id, updateAnswerDto);
if (!answerRegis) {
throw new HttpException('Not found', HttpStatus.NOT_FOUND);
}
return answerRegis;
}

@Post('user-regis')
@ApiResponse({ status: 200, type: AnswerRegisResponseDto })
Expand All @@ -104,29 +114,29 @@ export class AnswerController {
}

//Academic
// @Post('academic')
// async createAcademic(@Body() createAnswerDto: CreateAnswerAcademicDto) {
// const answerAcademic =
// await this.answerService.createAcademic(createAnswerDto);
// if (!answerAcademic) {
// throw new HttpException('Not found', HttpStatus.NOT_FOUND);
// }
// return answerAcademic;
// }
@Post('academic')
async createAcademic(@Body() createAnswerDto: CreateAnswerAcademicDto) {
const answerAcademic =
await this.answerService.createAcademic(createAnswerDto);
if (!answerAcademic) {
throw new HttpException('Not found', HttpStatus.NOT_FOUND);
}
return answerAcademic;
}

// @Get('academic')
// findAllAcademic() {
// return this.answerService.findAllAcademic();
// }
@Get('academic')
findAllAcademic() {
return this.answerService.findAllAcademic();
}

// @Get('academic/:id')
// async findAcademic(@Param('id') id: string) {
// const answerAcademic = await this.answerService.findOneAcademic(id);
// if (!answerAcademic) {
// throw new HttpException('Not found', HttpStatus.NOT_FOUND);
// }
// return answerAcademic;
// }
@Get('academic/:id')
async findAcademic(@Param('id') id: string) {
const answerAcademic = await this.answerService.findOneAcademic(id);
if (!answerAcademic) {
throw new HttpException('Not found', HttpStatus.NOT_FOUND);
}
return answerAcademic;
}

@Get('user-academic')
@ApiResponse({ status: 200, type: AnswerAcademicResponseDto })
Expand Down Expand Up @@ -156,18 +166,18 @@ export class AnswerController {
);
}

// @Patch('academic/:id')
// async updateAcademic(
// @Param('id') id: string,
// @Body() updateAnswerDto: UpdateAnswerAcademicDto,
// ) {
// const answerAcademic = await this.answerService.updateAcademic(
// id,
// updateAnswerDto,
// );
// if (!answerAcademic) {
// throw new HttpException('Not found', HttpStatus.NOT_FOUND);
// }
// return answerAcademic;
// }
@Patch('academic/:id')
async updateAcademic(
@Param('id') id: string,
@Body() updateAnswerDto: UpdateAnswerAcademicDto,
) {
const answerAcademic = await this.answerService.updateAcademic(
id,
updateAnswerDto,
);
if (!answerAcademic) {
throw new HttpException('Not found', HttpStatus.NOT_FOUND);
}
return answerAcademic;
}
}
37 changes: 21 additions & 16 deletions apps/server/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,32 @@ export class AuthController {
process.env.NODE_ENV === 'production' ? '.comcamp.io' : 'localhost',
});
return res.redirect(process.env.CLIENT_REDIRECT_AUTH_URL);
}
//Not exists
else {
// const newUser = await this.userService.create({
// email: profile.email,
// google_id: profile.googleID,
// });
// const session = await this.sessionService.create(newUser.id);
// res.cookie('sid', session.sid, {
// maxAge: 1000 * 60 * 60 * 24 * 7, // 1 days
// sameSite: 'lax',
// secure: process.env.NODE_ENV === 'production' ? true : false,
// httpOnly: true,
// domain:
// process.env.NODE_ENV === 'production' ? '.comcamp.io' : 'localhost',
// });
} else {
await this.registerNewUser(profile, res);
return res.redirect(process.env.CLIENT_REDIRECT_AUTH_URL);
}
}
}

private async registerNewUser(
profile: { email: string; googleID: string },
res: Response<any, Record<string, any>>,
) {
const newUser = await this.userService.create({
email: profile.email,
google_id: profile.googleID,
});
const session = await this.sessionService.create(newUser.id);
res.cookie('sid', session.sid, {
maxAge: 1000 * 60 * 60 * 24 * 7, // 1 days
sameSite: 'lax',
secure: process.env.NODE_ENV === 'production' ? true : false,
httpOnly: true,
domain:
process.env.NODE_ENV === 'production' ? '.comcamp.io' : 'localhost',
});
}

@Post('logout')
@UseGuards(AuthGuard)
async logout(@Req() req: Request, @Res() res: Response) {
Expand Down
21 changes: 11 additions & 10 deletions apps/server/src/files/files.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { UsersService } from 'src/users/users.service';
import { GetReceiptFileDto } from './dto/get-receipt-file.dto';
import { UploadReceiptResponseDto } from './dto/upload-receipt-response.dto';
import { ReceiptFileResponseDto } from './dto/receipt-file-response.dto';
import { GetUrlFileInputDto } from 'src/files/dto/geturl-file-input.dto';

@Controller('files')
@UseGuards(AuthGuard)
Expand Down Expand Up @@ -109,17 +110,17 @@ export class FilesController {
return this.filesService.uploadReceipt(file, req['user_id']);
}

// @Post('getblobs')
// @ApiResponse({ status: 200, type: UserFilesResponseDto })
// getBlobs(@Body() urls: GetUrlFileInputDto) {
// return this.filesService.getBlobs(urls);
// }
@Post('getblobs')
@ApiResponse({ status: 200, type: UserFilesResponseDto })
getBlobs(@Body() urls: GetUrlFileInputDto) {
return this.filesService.getBlobs(urls);
}

// @Post('geturl')
// @ApiResponse({ status: 200, type: UserFilesResponseDto })
// getFiles(@Body() urls: GetUrlFileInputDto) {
// return this.filesService.getFile(urls);
// }
@Post('geturl')
@ApiResponse({ status: 200, type: UserFilesResponseDto })
getFiles(@Body() urls: GetUrlFileInputDto) {
return this.filesService.getFile(urls);
}

@Get('user-files')
@ApiResponse({ status: 200, type: UserFilesResponseDto })
Expand Down
Loading
Loading