-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48646b7
commit 934ee65
Showing
12 changed files
with
193 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './lib/tasks-interface-adapters'; | ||
export * from './lib/tasks.module'; |
14 changes: 14 additions & 0 deletions
14
libs/tasks/interface-adapters/src/lib/dto/create-user-task.dto.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { CreateUserTaskDto } from './create-user-task.dto'; | ||
|
||
describe('CreateUserTaskDto', () => { | ||
it('should create a CreateUserTaskDto instance', () => { | ||
const id = '123'; | ||
const createdAt = new Date(); | ||
|
||
const dto = new CreateUserTaskDto(id, createdAt); | ||
|
||
expect(dto).toBeDefined(); | ||
expect(dto.id).toBe(id); | ||
expect(dto.createdAt).toBe(createdAt); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
libs/tasks/interface-adapters/src/lib/dto/create-user-task.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Field, InputType } from '@nestjs/graphql'; | ||
|
||
@InputType() | ||
export class CreateUserTaskDto { | ||
@Field(() => String) | ||
id: string; | ||
|
||
@Field(() => Date) | ||
createdAt: Date; | ||
|
||
constructor(id: string, createdAt: Date) { | ||
this.id = id; | ||
this.createdAt = createdAt; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
libs/tasks/interface-adapters/src/lib/dto/task.dto.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { TaskDto } from './task.dto'; | ||
|
||
describe('TaskDto', () => { | ||
it('should create a TaskDto instance', () => { | ||
const id = '123'; | ||
const title = 'Test Task'; | ||
const description = 'Test Description'; | ||
const categories = ['category1', 'category2']; | ||
|
||
const dto = new TaskDto(id, title, description, categories); | ||
|
||
expect(dto).toBeDefined(); | ||
expect(dto.id).toBe(id); | ||
expect(dto.title).toBe(title); | ||
expect(dto.description).toBe(description); | ||
expect(dto.categories).toEqual(categories); | ||
}); | ||
|
||
it('should allow null description', () => { | ||
const id = '123'; | ||
const title = 'Test Task'; | ||
const description = null; | ||
const categories = ['category1']; | ||
|
||
const dto = new TaskDto(id, title, description, categories); | ||
|
||
expect(dto.description).toBeNull(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Field, ID, ObjectType } from '@nestjs/graphql'; | ||
import { IsOptional } from 'class-validator'; | ||
|
||
@ObjectType() | ||
export class TaskDto { | ||
@Field(() => ID) | ||
id: string; | ||
|
||
@Field() | ||
title: string; | ||
|
||
@Field(() => String, { nullable: true }) | ||
@IsOptional() | ||
description: string | null; | ||
|
||
@Field(() => [String]) | ||
categories: string[]; | ||
|
||
constructor( | ||
id: string, | ||
title: string, | ||
description: string | null, | ||
categories: string[], | ||
) { | ||
this.id = id; | ||
this.title = title; | ||
this.description = description; | ||
this.categories = categories; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
libs/tasks/interface-adapters/src/lib/dto/update-user-task.dto.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { UpdateUserTaskDto } from './update-user-task.dto'; | ||
|
||
describe('UpdateUserTaskDto', () => { | ||
it('should create an UpdateUserTaskDto instance', () => { | ||
const id = '123'; | ||
const updatedAt = new Date(); | ||
|
||
const dto = new UpdateUserTaskDto(id, updatedAt); | ||
|
||
expect(dto).toBeDefined(); | ||
expect(dto.id).toBe(id); | ||
expect(dto.updatedAt).toBe(updatedAt); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
libs/tasks/interface-adapters/src/lib/dto/update-user-task.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Field, InputType } from '@nestjs/graphql'; | ||
|
||
@InputType() | ||
export class UpdateUserTaskDto { | ||
@Field(() => String) | ||
id: string; | ||
|
||
@Field(() => Date) | ||
updatedAt: Date; | ||
|
||
constructor(id: string, updatedAt: Date) { | ||
this.id = id; | ||
this.updatedAt = updatedAt; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
libs/tasks/interface-adapters/src/lib/resolver/tasks.resolver.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql'; | ||
import { TasksService } from '@tasks/application'; | ||
|
||
import { TaskDto } from '../dto/task.dto'; | ||
import { CreateUserTaskDto } from '../dto/create-user-task.dto'; | ||
import { UpdateUserTaskDto } from '../dto/update-user-task.dto'; | ||
|
||
@Resolver(() => TaskDto) | ||
export class TasksResolver { | ||
constructor(private tasksService: TasksService) {} | ||
|
||
@Query(() => TaskDto, { nullable: true }) | ||
async getTasks(): Promise<TaskDto[]> { | ||
return this.tasksService.findAll(); | ||
} | ||
|
||
@Mutation(() => String) | ||
async createUserTasks( | ||
@Args('userId') userId: string, | ||
@Args('tasks') tasks: CreateUserTaskDto[], | ||
): Promise<string> { | ||
return this.tasksService.createUserTasks(userId, tasks); | ||
} | ||
|
||
@Mutation(() => String) | ||
async updateUserTasks( | ||
@Args('userId') userId: string, | ||
@Args('userTasks') userTasks: UpdateUserTaskDto[], | ||
): Promise<string> { | ||
return this.tasksService.updateUserTasks(userId, userTasks); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
libs/tasks/interface-adapters/src/lib/resolver/tasks.resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql'; | ||
import { TasksService } from '@tasks/application'; | ||
|
||
import { TaskDto } from '../dto/task.dto'; | ||
import { CreateUserTaskDto } from '../dto/create-user-task.dto'; | ||
import { UpdateUserTaskDto } from '../dto/update-user-task.dto'; | ||
|
||
@Resolver(() => TaskDto) | ||
export class TasksResolver { | ||
constructor(private tasksService: TasksService) {} | ||
|
||
@Query(() => TaskDto, { nullable: true }) | ||
async getTasks(): Promise<TaskDto[]> { | ||
return this.tasksService.findAll(); | ||
} | ||
|
||
@Mutation(() => String) | ||
async createUserTasks( | ||
@Args('userId') userId: string, | ||
@Args('tasks') tasks: CreateUserTaskDto[], | ||
): Promise<string> { | ||
return this.tasksService.createUserTasks(userId, tasks); | ||
} | ||
|
||
@Mutation(() => String) | ||
async updateUserTasks( | ||
@Args('userId') userId: string, | ||
@Args('userTasks') userTasks: UpdateUserTaskDto[], | ||
): Promise<string> { | ||
return this.tasksService.updateUserTasks(userId, userTasks); | ||
} | ||
} |
7 changes: 0 additions & 7 deletions
7
libs/tasks/interface-adapters/src/lib/tasks-interface-adapters.spec.ts
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
libs/tasks/interface-adapters/src/lib/tasks-interface-adapters.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TasksService } from '@tasks/application'; | ||
|
||
import { TasksResolver } from './resolver/tasks.resolver'; | ||
|
||
@Module({ | ||
imports: [], | ||
providers: [TasksResolver, TasksService], | ||
exports: [TasksService], | ||
}) | ||
export class TasksModule {} |