Skip to content

Commit

Permalink
feat: add time out check
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Hsueh committed Jul 4, 2023
1 parent 0f3a4bc commit 071c850
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/controllers/applications.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { UserInterviewAnswersService } from "src/modules/user-interview-answers/
import { UserSurveyAnswersService } from "src/modules/user-survey-answers/user-survey-answers.service";
import { UpdateApplicationPayload } from "src/modules/applications/dtos/update-application-payload.dto";
import { isNil } from "lodash";
import moment from "moment";
import { END_TIME, START_TIME } from "src/modules/users/consts/const";

@ApiTags("applications")
@Controller("applications")
Expand Down Expand Up @@ -60,8 +62,20 @@ export class ApplicationsController {
@Put("me")
async update(
@User() user: UserEntity,
@Body() dto: UpdateApplicationPayload
@Body() dto: UpdateApplicationPayload,
@Res() response: Response
) {
const startDate = moment(START_TIME);
const endDate = moment(END_TIME);
const now = moment();

if (!now.isBetween(startDate, endDate)) {
response.status(HttpStatus.BAD_REQUEST).json({
error: {
message: "報名時間截止",
},
});
}
const userId = user.id;

const { info, survey, answer, files } = dto?.data;
Expand Down

0 comments on commit 071c850

Please sign in to comment.