Skip to content

Commit

Permalink
Merge pull request #57 from CE61-KMITL/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
TeetouchQQ authored Apr 6, 2023
2 parents 1ae542d + 14fc79c commit 31bc03b
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ lerna-debug.log*
#mongo
/mongo-data


.scannerwork
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grader-backend",
"version": "0.0.1",
"description": "",
"name": "boostupxi-api",
"version": "1.0.1",
"description": "This is an API for the CE BoostUp XI.",
"author": "",
"private": true,
"license": "UNLICENSED",
Expand Down
3 changes: 1 addition & 2 deletions src/modules/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Injectable } from '@nestjs/common';
import { HttpException, HttpStatus } from '@nestjs/common';
import { Injectable, HttpException, HttpStatus } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
import { InjectModel } from '@nestjs/mongoose';
import { Model } from 'mongoose';
Expand Down
2 changes: 1 addition & 1 deletion src/modules/files/files.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class FilesController {
@UploadedFiles(
new ParseFilePipeBuilder()
.addFileTypeValidator({
fileType: /(jpg|jpeg|png|zip)$/,
fileType: /(jpg|jpeg|png|zip)/,
})
.addMaxSizeValidator({
maxSize: 1024 * 1024 * 5,
Expand Down
5 changes: 3 additions & 2 deletions src/modules/tasks/dto/create-task.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
IsNumber,
IsArray,
IsNotEmpty,
IsOptional,
} from 'class-validator';
import { IFile } from 'src/shared/interfaces/file.interface';
import { ITestCase } from 'src/shared/interfaces/testcase.interface';
Expand Down Expand Up @@ -50,7 +51,7 @@ export class CreateTaskDto {
description: 'Hint of the task',
})
@IsString()
@IsNotEmpty()
@IsOptional()
hint: string;

@ApiProperty({
Expand Down Expand Up @@ -85,6 +86,6 @@ export class CreateTaskDto {
description: 'Files of the task',
})
@IsArray()
@IsNotEmpty()
@IsOptional()
files: IFile[];
}
11 changes: 2 additions & 9 deletions src/modules/tasks/tasks.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class TasksController {
}

@Get()
@Roles(Role.Auditor, Role.Staff, Role.User)
@Roles(Role.Auditor, Role.Staff)
@UseGuards(JwtGuard, RolesGuard)
async getTasks(
@Query(
Expand All @@ -67,19 +67,12 @@ export class TasksController {
}

@Get('/:id')
@Roles(Role.Auditor, Role.Staff, Role.User)
@Roles(Role.Auditor, Role.Staff)
@UseGuards(JwtGuard, RolesGuard)
async getTaskById(@Param('id') id: string): Promise<TaskI> {
return await this.tasksService.getTaskById(id);
}

@Get('/user/:id')
@Roles(Role.Auditor, Role.Staff, Role.User)
@UseGuards(JwtGuard, RolesGuard)
async getTasksByUser(@Param('id') id: string): Promise<TaskI[]> {
return await this.tasksService.getTasksByUser(id);
}

@Patch('/:id')
@Roles(Role.Auditor, Role.Staff)
@UseGuards(JwtGuard, RolesGuard)
Expand Down
7 changes: 0 additions & 7 deletions src/modules/tasks/tasks.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ export class TasksService {
return task;
}

async getTasksByUser(id: string): Promise<TaskI[]> {
const tasks = await this.taskModel.find({
'author.id': id,
});
return tasks;
}

async updateTask(id: string, updateTaskDto: UpdateTaskDto) {
const task = await this.taskModel.findById(id);

Expand Down

0 comments on commit 31bc03b

Please sign in to comment.