-
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.
feat: Categories Create and Delete (#34)
# Description * Deletion of categories * Creation of new categories ## Checklist - [x] This PR can be reviewed in under 30 minutes - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] I have assigned reviewers to this PR.
- Loading branch information
Showing
4 changed files
with
47 additions
and
0 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
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
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,17 @@ | ||
import { Injectable, PipeTransform } from '@nestjs/common'; | ||
import { DampLabServicePipe } from '../services/damplab-services.pipe'; | ||
import { CreateCategory } from './dtos/create.dto'; | ||
|
||
@Injectable() | ||
export class CreateCategoryPipe implements PipeTransform<CreateCategory, Promise<CreateCategory>> { | ||
constructor(private readonly damplabServicePipe: DampLabServicePipe) {} | ||
|
||
async transform(value: CreateCategory): Promise<CreateCategory> { | ||
// Ensure the services are valid | ||
for (const service of value.services) { | ||
await this.damplabServicePipe.transform(service); | ||
} | ||
|
||
return value; | ||
} | ||
} |
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,8 @@ | ||
import { ID, InputType, OmitType, Field } from '@nestjs/graphql'; | ||
import { Category } from '../category.model'; | ||
|
||
@InputType() | ||
export class CreateCategory extends OmitType(Category, ['_id', 'services'] as const, InputType) { | ||
@Field(() => [ID]) | ||
services: string[]; | ||
} |