You should upgrade! NestJS v10
Вставка
- Опубліковано 5 жов 2024
- Very quickly going over the recent major version release of Nest.js which introduces SWC as an alternative compiler, along with a few other small changes. I'll also show you how to actually upgraded your application in the simplest way possible.
Woah! This is beautiful! As usual the Nest team keep doing a great job.
The team behind it is great!
The adult framework gets an update 🤩 if this would just make it to the hot take twitter crowd
Cool, excited about the next end to end typesafe video
Thanks for the really helpful content. They have been huge inspiration in choosing our stack. Eagerly awaiting grpc video. Please try to include error handling, auto type generation and reflection etc with respect to nestjs integration.
Looking forward to more new content from you!
Thanks for the video, i will now update my nest js projects to use swc, great addition!
Great to check the NestJS 10 updates from you! 👌🏼
BTW, eagerly looking forward to next video. I've been looking for and end-to-end type safety with NestJS since a while
Love your channel, thank you so much!
Have you (or anyone) seen anything about getting SWC to work with NX & Nest? I have already upgraded to Nest v10 and latest NX but haven't had time to try and get swc to work with that setup and haven't really found any good info on it.
Regardless if it’s a monorepo, the swc setting is only for your Nest app. Not sure what that has to do with Nx. But I haven’t used it before to be honest. Shouldn’t it be able to work with whatever compiler each of your apps are using?
Hey, thanks for all your content, i'm enjoying everything about your courses and Nest content.
I wanna ask about an error that i get from swc: Cannot find module '../ormconfig'
although i can solve this issue by just writing the configs in the app module or moving the config file to be within src, i'm curious about the reason of this error.
Not sure what the problem is there sorry
Please make a video about running Nestjs on Bun 🙏🏻🙏🏻🙏🏻
I was actually just thinking about what that integration might look like, I’ll have to spend some time trying it out
what is the advantage of fast building,if you build once in development?
What do you mean? Assuming you’re using watch mode it’s meant to re-compile every time you change the code
@@mariusespejo i got it thank you
Great man thx
Hi Marius, I'm stuck on looking for a right ORM, which ORM should you recommend to use in NestJS? Or you just use database driver in pg? Thank you in advance!
For Nest specifically I think typeorm integrates the best because it is directly supported and has the same style of classes + decorators. I have video on typeorm 0.3.x setup in the channel. Prisma is also popular, I have a first impressions video on that also with nest I think. Finally drizzle orm is worth checking out if you want something lighter weight, think of it like just a thin layer above drivers like pg. Although it’s newer and you might find some features missing. I also have an impressions video on that if you want to check it out
I just updated. its nice and fast really. just does not like src/ imports
Yup!
In the new video can you connect with Sequellize instead TypeORM?
I don’t intend on using any ORMs for it because it’s unrelated. Nest has really good docs on sequelize if you haven’t seen
What vscode theme and file icon do you use here?
Monokai pro, I think it comes with the icons?
Marius, I followed your tutorial usign Datasources for TypeOrm. In that tutorial you created a "db" folder outside of "src". The thing is that swc only builds the content of "src" into the dist folder, therefore the db content is missing there. How can you solve this issue?
I mean you could just move it in or duplicate into src right?
Quickly question, I'm doing some research to build a video calling API with webrtc using nestjs. Any ideas on this ?
Might want to ask in stackoverflow
But swc works bad with commonjs and has no some properties from tsconfig
Well it is optional. Modern libraries also typically will support ESM
After upgrading and trying to compile with swc, I get this in my console: "Error: Cannot find module..." and then the app won't start.
If I switch to relative paths it is working. It turns out swc can no longer compile absolute paths like "import TaskEitherUtil from "src/shared/pure-utils/monad/TaskEitherUtil"" but have to do "import TaskEitherUtil from "../../../src/shared/pure-utils/monad/TaskEitherUtil" to make it work.
Previously I used tsconfig-paths to make it work.
Do you have any idea how to solve this? I've googled for hours but to no avail. Thank you kindly.
I don’t sorry. Although even without swc I suggest always using relative imports for Nest. Because in the dist you may or may not always have an src in there, depends on the project
@@mariusespejo Thanks for replying! My app is huge. Do you know if any tool that automatically can convert from absolute to relative? If not no worries. Thanks!
I don’t, sorry! But you can setup vs code to prefer relative imports, then just delete imports and you can auto import all missing. You’d have to do that manually per file though
I started trying out Nest a few days ago, all was going good but the login route now throws a 500 error and that's all the info i'm getting
All errors you don’t catch will result in 500
@@mariusespejo thanks for the quick response mate, I get that, I worked on a svelte project recently and I was catching all errors but that was frontend only.
The errors I'm getting now are somewhere from within the AuthGuard.
I've tried to label my Exceptions but still getting a bland 500 and this is just from the demo "login" and home routes.
Any suggesstions?
I could share my repo later on if you don't mind giving me an assist
Please create a tutorial of it
❤ Could anyone say if swc compiler supports forwardRef in order to resolve circular dependencies?
That’s the solution typically for circular dependency on nest, but it’s the circular import on the ts files that are a problem for swc so it might not solve it for you.
@@mariusespejo Thank you for your responce! Ok. But as I can see now "For all circular dependency injections in your project, you will also need to use the custom wrapper type". So I wil try...
Yeah it does look like perhaps you need both forwardRef (solve the circular dep for nest) and the wrapper type (solve circular import for swc). But it might only be relevant to typeorm/microorm
@@mariusespejo It works for me! My code: @Inject(forwardRef(() => AuthService))
private readonly authService: WrapperType