Skip to content

Commit

Permalink
Add grace period, fix cover photo endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dellisd committed Jan 31, 2021
1 parent e6508a6 commit 7f91d62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/controllers/dashboardController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { promises as fs } from 'fs';

let ENDTIME: Date = new Date('2021-01-31T12:00:00.000Z');
let STARTTIME = new Date('2021-01-30T12:00:00.000Z');
let GRACE_PERIOD = process.env.GRACE_PERIOD ? parseInt(process.env.GRACE_PERIOD) : 30;
const CONFIG_FILE = process.env.CONFIG_FILE;

export const updateStartEndTime = async (): Promise<boolean> => {
Expand Down Expand Up @@ -91,6 +92,7 @@ export const getDashboardInfo = async (req: Request, res: Response): Promise<voi
schedule: events,
startTime: STARTTIME,
endTime: ENDTIME,
graceTime: GRACE_PERIOD,
firstName: user.application.firstName,
lastName: user.application.lastName,
teamMembers: teamMembers
Expand Down
7 changes: 4 additions & 3 deletions src/controllers/submissionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const git = simpleGit(SUBMISSION_ROOT);

const CONFIG_FILE = process.env.CONFIG_FILE;
let ENDTIME: Date = new Date('2020-01-31T12:30:00.000Z');
let GRACE_PERIOD = process.env.GRACE_PERIOD ? parseInt(process.env.GRACE_PERIOD) : 30;
const GRACE_PERIOD = process.env.GRACE_PERIOD ? parseInt(process.env.GRACE_PERIOD) : 30;

// Result of a git-related action
export type GitResult = 'no-repo' | 'no-readme' | 'success' | 'error';
Expand Down Expand Up @@ -277,7 +277,7 @@ export const getSubmission = async (
res.status(200).send({
submission: restOfSubmission,
team: teamData,
cover: `/submission/${req.params.repo}/cover`
cover: `/api/submission/${encodeURIComponent(repo)}/cover`
});
} else {
res.sendStatus(404);
Expand All @@ -293,6 +293,7 @@ export const getSubmissionImage = async (req: Request, res: Response) => {
const coverMimeType = submission.coverMimeType ?? 'image/png';
const buffer = submission.imageCover;

res.set('content-length', `${buffer?.length ?? 0}`)
res.set('content-type', coverMimeType);
res.status(200).end(buffer, 'binary');
} else {
Expand All @@ -314,7 +315,7 @@ export const getSubmissionPreviews = async (
name: submission.projectName,
repo: submission.repo,
team: submission.team?.name,
cover: submission.imageCover ? `/submission/${encodeURIComponent(submission.repo)}/cover` : undefined
cover: submission.imageCover ? `/api/submission/${encodeURIComponent(submission.repo)}/cover` : undefined
});
}

Expand Down

0 comments on commit 7f91d62

Please sign in to comment.