-
Notifications
You must be signed in to change notification settings - Fork 2.1k
refactor(examples): enhance with-nestjs (#8131)
#10964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+4,975
−3,867
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,4 +1,4 @@ | ||
| import config from "@repo/eslint-config/prettier-base"; | ||
| import config from '@repo/eslint-config/prettier-base'; | ||
|
|
||
| /** @type {import("prettier").Config} */ | ||
| export default config; |
This file contains hidden or 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 hidden or 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,4 +1,9 @@ | ||
| import { nestJsConfig } from "@repo/eslint-config/nest-js"; | ||
| import { nestJsConfig } from '@repo/eslint-config/nest-js'; | ||
|
|
||
| /** @type {import("eslint").Linter.Config} */ | ||
| export default nestJsConfig; | ||
| export default [ | ||
| ...nestJsConfig, | ||
| { | ||
| ignores: ['.prettierrc.mjs', 'eslint.config.mjs'], | ||
| }, | ||
| ]; |
This file contains hidden or 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 hidden or 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,59 +1,48 @@ | ||
| import { Injectable } from '@nestjs/common'; | ||
|
|
||
| import { Link } from '@repo/api/links/entities/link.entity'; | ||
|
|
||
| import { CreateLinkDto } from '@repo/api/links/dto/create-link.dto'; | ||
| import { UpdateLinkDto } from '@repo/api/links/dto/update-link.dto'; | ||
| import { Link, CreateLinkDto, UpdateLinkDto } from '@repo/api'; | ||
|
|
||
| @Injectable() | ||
| export class LinksService { | ||
| private readonly _links: Link[] = [ | ||
| { | ||
| id: 0, | ||
| title: 'Docs', | ||
| url: 'https://turborepo.com/docs', | ||
| description: | ||
| 'Find in-depth information about Turborepo features and API.', | ||
| title: 'Installation', | ||
| url: 'https://turborepo.com/docs/getting-started/installation', | ||
| description: 'Get started with Turborepo in a few moments using', | ||
| }, | ||
| { | ||
| id: 1, | ||
| title: 'Learn', | ||
| url: 'https://turborepo.com/docs/handbook', | ||
| description: 'Learn more about monorepos with our handbook.', | ||
| title: 'Crafting', | ||
| url: 'https://turborepo.com/docs/crafting-your-repository', | ||
| description: 'Architecting a monorepo is a careful process.', | ||
| }, | ||
| { | ||
| id: 2, | ||
| title: 'Templates', | ||
| url: 'https://turborepo.com/docs/getting-started/from-example', | ||
| description: | ||
| 'Choose from over 15 examples and deploy with a single click.', | ||
| }, | ||
| { | ||
| id: 3, | ||
| title: 'Deploy', | ||
| url: 'https://vercel.com/new', | ||
| title: 'Add Repositories', | ||
| url: 'https://turborepo.com/docs/getting-started/add-to-existing-repository', | ||
| description: | ||
| 'Instantly deploy your Turborepo to a shareable URL with Vercel.', | ||
| 'Turborepo can be incrementally adopted in any repository, single or multi-package, to speed up the developer and CI workflows of the repository.', | ||
| }, | ||
| ]; | ||
|
|
||
| create(createLinkDto: CreateLinkDto) { | ||
| return `This action adds a new link ${createLinkDto}`; | ||
| return `TODO: This action should add a new link '${createLinkDto.title}'`; | ||
| } | ||
|
|
||
| findAll() { | ||
| return this._links; | ||
| } | ||
|
|
||
| findOne(id: number) { | ||
| return `This action returns a #${id} link`; | ||
| return `TODO: This action should return a Link with id #${id}`; | ||
| } | ||
|
|
||
| update(id: number, updateLinkDto: UpdateLinkDto) { | ||
| return `This action updates a #${id} link ${updateLinkDto}`; | ||
| return `TODO: This action should update a #${id} link ${updateLinkDto.title}`; | ||
| } | ||
|
|
||
| remove(id: number) { | ||
| return `This action removes a #${id} link`; | ||
| return `TODO: This action should remove a #${id} link`; | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,4 +1,6 @@ | ||
| /** @type {import('next').NextConfig} */ | ||
| const nextConfig = {}; | ||
| const nextConfig = { | ||
| allowedDevOrigins: ['http://localhost:3000'], | ||
| }; | ||
|
|
||
| export default nextConfig; |
This file contains hidden or 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 hidden or 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 hidden or 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,3 @@ | ||
| export { Link } from './links/entities/link.entity'; | ||
| export { CreateLinkDto } from './links/dto/create-link.dto'; | ||
| export { UpdateLinkDto } from './links/dto/update-link.dto'; |
This file was deleted.
Oops, something went wrong.
6 changes: 5 additions & 1 deletion
6
examples/with-nestjs/packages/api/src/links/dto/create-link.dto.ts
This file contains hidden or 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,5 @@ | ||
| export class CreateLinkDto {} | ||
| export class CreateLinkDto { | ||
| title: string; | ||
| url: string; | ||
| description: string; | ||
| } |
This file contains hidden or 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
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
updatemethod accessesupdateLinkDto.titledirectly, butUpdateLinkDtoextendsPartialType(CreateLinkDto)making all properties optional, which will result in "undefined" appearing in the returned string whentitleis not provided.View Details
Analysis
Template string displays "undefined" when optional title not provided in LinksService.update()
What fails:
LinksService.update()at line 42 inexamples/with-nestjs/apps/api/src/links/links.service.tsaccessesupdateLinkDto.titlein template string, butUpdateLinkDtoextendsPartialType(CreateLinkDto)making all properties optionalHow to reproduce:
Result: Returns string containing literal text "undefined" when PATCH request omits title field
Expected: Should return clean message without "undefined" text when optional properties are omitted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just demonstration purposes. Don't worry about it.