- 109
- 1 372 625
Sakura Dev
United Kingdom
Приєднався 7 кві 2011
Hey, my name is Vahid Nejad and I am a Ph.D. Student on Software Engineering. In this channel, I will create videos about web development, JavaScript and Node.js.
By the way, Sakura is Japanese cherry flower and I like them.
Open to get involve in your web development projects.
By the way, Sakura is Japanese cherry flower and I like them.
Open to get involve in your web development projects.
GraphQL Authentication & Authorization in NestJS
Unlock the full potential of GraphQL in NestJS with this deep dive into Authentication and Role-Based Authorization! 🚀
In this video, we'll explore:
Setting up GraphQL in a NestJS project with a focus on security.
Implementing JWT Authentication for secure access.
Building a robust Role-Based Authorization system to manage user permissions effectively.
Real-world examples and best practices to keep your application secure.
Whether you're a beginner or an experienced developer, this step-by-step tutorial will guide you through securing your API like a pro.
Don't forget to like, subscribe, and hit the bell icon for more tutorials on NestJS, Next.js, and full-stack development!
#NestJS #GraphQL #Authentication #Authorization #RoleBasedAuthorization
In this video, we'll explore:
Setting up GraphQL in a NestJS project with a focus on security.
Implementing JWT Authentication for secure access.
Building a robust Role-Based Authorization system to manage user permissions effectively.
Real-world examples and best practices to keep your application secure.
Whether you're a beginner or an experienced developer, this step-by-step tutorial will guide you through securing your API like a pro.
Don't forget to like, subscribe, and hit the bell icon for more tutorials on NestJS, Next.js, and full-stack development!
#NestJS #GraphQL #Authentication #Authorization #RoleBasedAuthorization
Переглядів: 828
Відео
NestJS GraphQL Course
Переглядів 1,1 тис.Місяць тому
Welcome to the channel! In this video, we’re exploring how to use GraphQL with NestJS. Learn the basics of GraphQL, how it works, and how to set it up in a NestJS application. Whether you're new to GraphQL or NestJS, this video will help you understand the concepts and build your own APIs effectively. Chapters: 0:00 :00 Intro 00:01:54 What is the GraphQL? 00:02:22 How Does GraphQL Differ From R...
Is It Really Useful? JS Currying Real Use Cases in React & Next.js
Переглядів 784Місяць тому
In this video, we’ll demystify currying and explore its practical applications in React and Next.js. Learn how currying can help you write cleaner, more reusable code for managing state, handling events, and building dynamic higher-order components. Whether you're new to currying or looking to see it in action, this video has you covered with real-world examples and easy-to-follow explanations....
What Do These Signs Means in Node.JS Packages?
Переглядів 395Місяць тому
Confused about the caret (^) and tilde (~) symbols in your package.json file? 🤔 In this video, I'll explain what these symbols mean, how they affect your dependency updates, and when to use each one. Whether you're a beginner or looking for a quick refresher, this guide will help you master package.json versioning in under a minute! 🚀 📌 Topics Covered: What does ^ mean in package.json? What doe...
Secure Forms in Next.js: Honey Pot Technique
Переглядів 1,2 тис.2 місяці тому
Secure Your Forms in Next.js with the Honey Pot Technique! Tired of spam bots flooding your web forms? In this tutorial, I’ll show you how to use the honey pot technique to secure your Next.js forms effectively-no frustrating CAPTCHAs required!
All in One NextJS And NestJS Full Authentication Monorepo Project
Переглядів 21 тис.3 місяці тому
Hey everyone, welcome back to Sakura dev channel! In today's video, we're diving into full stack authentication using Next.js and Nest.js with Turborepo. I'll walk you through setting up a powerful and scalable authentication system step-by-step. You will learn everything you need to know about authentication in a monorepo of Nextjs and NestJS projetcs. We’ll handle most of the authentication o...
Build a NestJS & NextJS Monorepo with Turborepo - Step by Step Tutorial
Переглядів 9 тис.5 місяців тому
Build a NestJS & NextJS Monorepo with Turborepo - Step by Step Tutorial
Drizzle ORM in NestJS: Step By Step Crash Course
Переглядів 6 тис.5 місяців тому
Drizzle ORM in NestJS: Step By Step Crash Course
A Trick For Enabling Global Auth In NestJS
Переглядів 1,3 тис.5 місяців тому
A Trick For Enabling Global Auth In NestJS
Mastering Role Based Access Control in NestJS
Переглядів 6 тис.5 місяців тому
Mastering Role Based Access Control in NestJS
How To Revoke JWT Tokens In NestJS : Easy Step-by-Step Guide
Переглядів 3,1 тис.6 місяців тому
How To Revoke JWT Tokens In NestJS : Easy Step-by-Step Guide
NestJS Refresh Token: Step By Step Guide With Passport.JS
Переглядів 4,6 тис.6 місяців тому
NestJS Refresh Token: Step By Step Guide With Passport.JS
NestJS Authentication With JWT Strategy
Переглядів 4 тис.6 місяців тому
NestJS Authentication With JWT Strategy
NestJS Authentication With Local Strategy
Переглядів 2,9 тис.6 місяців тому
NestJS Authentication With Local Strategy
NestJS Config Module: Using environment variables
Переглядів 4,7 тис.6 місяців тому
NestJS Config Module: Using environment variables
NestJs Full Course -11: Pagination
Переглядів 2,9 тис.6 місяців тому
NestJs Full Course -11: Pagination
NestJs Full Course -10: TypeORM Seeding
Переглядів 3,6 тис.6 місяців тому
NestJs Full Course -10: TypeORM Seeding
NestJs Full Course -9: Many To Many Relationships with Type ORM
Переглядів 2,7 тис.6 місяців тому
NestJs Full Course -9: Many To Many Relationships with Type ORM
NestJs Full Course -8: One To Many Relationship in Type ORM
Переглядів 2 тис.6 місяців тому
NestJs Full Course -8: One To Many Relationship in Type ORM
NestJs Full Course -7: One To One Relations
Переглядів 1,8 тис.6 місяців тому
NestJs Full Course -7: One To One Relations
NestJS Full Course 2024 -5: TypeORM
Переглядів 4 тис.6 місяців тому
NestJS Full Course 2024 -5: TypeORM
NestJS Full Course -4: Dependency Injection
Переглядів 3,1 тис.7 місяців тому
NestJS Full Course -4: Dependency Injection
NestJs Full Course -3: Headers Access and Validation
Переглядів 3,3 тис.7 місяців тому
NestJs Full Course -3: Headers Access and Validation
NestJs Full Course 2024 -2: Validation In NestJs (ZOD Included)
Переглядів 9 тис.7 місяців тому
NestJs Full Course 2024 -2: Validation In NestJs (ZOD Included)
Stripe Online Payments In Next JS 14 - Full Guide
Переглядів 3,9 тис.8 місяців тому
Stripe Online Payments In Next JS 14 - Full Guide
Search Bar With useDebounce - Next.JS 14 Full Stack Real Project - Part 9
Переглядів 3,2 тис.8 місяців тому
Search Bar With useDebounce - Next.JS 14 Full Stack Real Project - Part 9
This only works when you make calls from within your component. How about external axios calls from Redux Tool Kit, for instance. We can't use hooks like const {update} = useSession() outside nextjs components!
Great 👍🏻
Thanks! Glad you liked it 👍
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from Tech books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
@@SakuraDev I subscribed it 👍🏻
Great tutorial! 🔥 I really enjoyed how thoroughly you explained the authentication process in a Next.js and Nest.js monorepo with Turborepo. Everything is clear and to the point, without any unnecessary fluff. Thanks for such high-quality content-keep up the amazing work! 💪🚀
Thanks so much! I'm glad you enjoyed the tutorial, and I appreciate your kind words! 💪
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from Tech books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
Thanks Sakura for amazing tutorial
I'm a little confused why you split the work of session Management between servers. All nextjs session functions you wrote in nextjs app using cookie function could just call our backend (nestjs) as well right? Like instead of doing cookies in nextjs server actions, these actions could just call our nestjs server? You probably did the splitting due to distribution of load but I think it was a little confusing. If there's any other reason please let me know.
Great observation! 😊 Yes, you’re absolutely right that session management can be fully handled in NestJS. The reason I split it between Next.js and NestJS was mainly for performance optimization and reducing backend calls. By handling cookies in Next.js server actions: ✔️ We reduce unnecessary API requests to NestJS, improving response times. ✔️ It allows better integration with Next.js middleware for SSR/SSG workflows. ✔️ In some cases, it simplifies authentication flows (e.g., checking session validity before making a request to NestJS). That said, centralizing everything in NestJS is also a valid approach, especially if you want strict backend control. Hope that clears it up! Let me know if you’d like a deeper dive into either approach. 🙌
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from Tech books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
@@SakuraDev oh yea this makes sense. Thnx for clarification. Also amazing content
Thanks for making these videos. On this one I think you might be missing the .unique() constraint on userId. You have implemented the one-to-one in Drizzle 'relations' but your database schema looks like a one-to-many rather than a one-to-one. I was expecting the below: userId: integer("user_id").notNull().unique().references(() => users.id) Without the unique constraint it seems that many profiles could reference the same user, making it a many-to-one. Let me know if I have missed something, and thanks again.
Great catch! 🎯 You’re absolutely right that without the .unique() constraint, the database schema allows multiple profiles to reference the same user, effectively making it a one-to-many relationship instead of one-to-one. I’ll double-check the implementation and update it if needed. Thanks for the keen eye and for supporting the channel! 🚀
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from Tech books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
Great! Now you have saved me some future confusion 😆
Glad to hear it! 👍
fake filler settings can ignore hidden inputs
Awesome tutorials +++++++++++++++++
Thanks for watching and I'm glad you found it helpful!
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from Tech books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
Hi Thanks for the walkthrough I have faced one issue when having API and front-end (nextjs) in different domains, and after hours, I had solved it by opening the API endpoint related to getting the google oauth url in a NEW TAB so it will be in the same origin -- this cause CORS error I was getting to gone and successfully logging in I hope this may help someone later having similar situation as it is common having FE and API in different domians.
im facing this problem , thanks for you comment
Hey! 👋 Thanks for sharing your solution! This will definitely help others facing the same issue! 🚀 Appreciate you taking the time to share your experience. 🙌
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from Tech books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
Thanks for the explanation sir. May I ask why you don't directly include the role in the jwt payload?
Great question! 🎯 Keeping roles in the DB ensures real-time accuracy-if a role changes, it's immediately reflected. Storing it in the JWT means users need to re-login to get updated roles. Both approaches have trade-offs! 🚀
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from Tech books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
Very nice video! Thanks for your effort, I've learned some great concepts
You're welcome! I'm glad it was helpful.
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from popular tech books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
You should do a full guide with all of these resources in udemy. I would definitely buy it and I have a few people who would be interested in buying it too. Very good stuff and well explained. Some other topics to cover: - Caching with reds (using nestjs cache-manager) - Queues (nestjs-bullmq) - File uploading/streaming files - Websockets - Interceptors?
Thank you for the kind words! 🙌 I’m glad you find the content helpful. I’ll definitely consider covering those topics in future tutorials. Stay tuned for more! 🚀
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from Tech books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
Hi brother, but shouldn't the jwt useguard decorator be put first and then the role useguard decorator? Otherwise how is the user id obtained to find the user in the DB and then insert it in the request, if the jwt token is not decoded first? I would have written it like this: @Roles (Role. EDITOR) @UseGuards (JwtAuthGuard) @UseGuards (RolesGuard) @Delete(':id')
Hi, great question!. The guard that is closer to the function is run first. Because the function is passed as callback to the closet guard and then it returns a new function. The new function is passed to the next closest guard and so on
@@SakuraDev OK thanks. I thought the first decorator was performed at the top until it went down to the last one that is the closest to the function
thanks so much bro, this is not a common video like only javascript for example, this is more specific and so useful!
You're welcome! It's always great to help others with more specialized topics like GraphQL and NestJS.
Absolute Genius. Thank you so much for sharing this. My env handling just got 100% easier 🙏 Keep up the great work!
Happy to help! 🙏
As always excellent content! I look forward to the release of your new videos on the use of GraphQL in NestJS!
I’m glad you find the content helpful, and I’m excited to share more about GraphQL with you soon!
Excellent and easy to understandable content...💖💖💖
Thanks so much for the love! ❤️
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from CS books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
Hello, Vahid! It's Great tutorial! Please write a lesson about testing in NestJS using the JWT Strategy example.
I'm glad you found it helpful! Testing in NestJS is a crucial topic, and I'll definitely consider adding a video about it in the future.
At 10:45 I got an ts error in the super(): Expected 0 arguments, but got 1 I have same code as you, same imports and problem (probably) with PassportStrategy(Strategy), got something changed recently in this library?
I have a question. Why are we using Promise.all here? Can't we just use prisma transaction?
Incredible course! Thank you very much!
You're very welcome!
Tell me, please! Is it permissible to register a service of another module as a module provider? Or is it better to import another module to the current module, the service of which we want to use in the current module? At the same time, of course, the module that owns the service must export it in order to make the opportunity to use this service in the modules that import it.
Hi @AGM140580! Great question! 😊 In NestJS, it’s better to import the module that exports the service rather than re-registering it as a provider. This ensures the service remains a singleton (if provided in the root) and follows NestJS's modular architecture. Just make sure the owning module exports the service in its exports array. Thanks for engaging!
great tutorial
I'm glad you found it helpful!
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from popular programming books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
<3
Thank you so much 🙏. Hope it was helpful for you.
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from CS books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
<3
Thanks
Thank you
Thanks for your feedback. Hope it was helpful for you!
Thanks 👍
You're welcome! Hope you found it helpful.
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from CS books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
a Great tutorial for those who wants to get a solid grip about the implementing the jwt authentication in nest Good Job, Vahid
Thank you, Ahmed! I’m glad you found the tutorial helpful. JWT authentication is such an important topic in NestJS, and I’m thrilled it provided you with value.
Please explain! Is it necessary to use Nextjs api route to set cookies in the browser? Isn't it better to do this using Nestjs? Will this help eliminate unnecessary redirects and the need to pass sensitive information to searchParams?
Yes, you’re absolutely right! Using NestJS to handle cookies directly is often a better approach, as it centralizes logic and avoids unnecessary redirects or exposing sensitive information in searchParams. It’s a cleaner solution, especially in production-level applications. Let me know if you’d like more details or examples!
@@SakuraDev Thank you very much for the answer! You are the best teacher. Please write down a lesson on how to properly process cookies in Nestjs. He really needs him!
Your training video covers the topic of authentication perfectly! I haven’t seen anything better even in paid courses! I like the way you explain the material: repeating important aspects whenever possible. This way the information is absorbed better and everything becomes clear.
Wow, thank you so much for such amazing feedback! 😊 I’m truly honored to hear that you found the video so helpful, even compared to paid courses.
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from CS books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
@@SakuraDev Signed! Serious topics. Great content. I will study. I recommend everyone.
very nice video, thanks from brazil!! you helping very very much
Thanks for watching! I'm happy to hear you found it useful. 👍
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from CS books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
man we are thankful for this course for real thank you
Thank you so much! 🙏 Hearing that means the world to me.
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from CS books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
Query params are strings when they arrive to the controller. In case of number validation error, modify the PaginationDTO properties with this decorator: @Type(() => Number) This will transforms the incoming string param to number. (class-transformer lib)
Nice tip 💯. Thanks for your feedback
A dense, yet fruitful video didn't know .env and config can do all fo that Thank You Vahid
Thanks for watching, I'm glad you found it helpful!
I got a question, by just passing the 'local' parameter to the AuthGuard, how did nest knew you meant the LocalStrategy? in 13:46 Thank you in advance for your efforts : )
Great question, Ahmed! 😊 Nest knows to use the LocalStrategy when you pass 'local' to the AuthGuard because the name 'local' is set in the LocalStrategy class using the @Injectable() decorator, typically through the super({}) call in the constructor of PassportStrategy. This name acts as an identifier, allowing the AuthGuard to link the strategy with the parameter you pass. Thank you for your thoughtful question, and I’m happy to explain further if needed! 🙌
Well wow, this was kinda alot, thus I recommend watching this video either as sections, or at least one more time completely I appreciate your effort to simplify such a complicated topic actually
Thanks for the feedback! I'm glad you found the explanation helpful. Thank you so much for support 💖
I come from another language/framework. Some solutions you apply seem strange to me: 1. It seems hard to believe that such a basic feature as .env file support requires so much setup in NestJS. Is this the general way to do it, or is this applicable for your specific use case in your specific project? What is the basis that is generally enough for production level NestJS applications? 2. Why don't you use ConfigService? Your approach without ConfigService leads to manual type conversion, which does not seem to be a good practice. 3. Why would you disable TypeORM synchronize in prod, but enable it in dev? Won't this hide incorrect migrations and lead to bugs in stage/prod?
Thank you for your detailed questions! 😊 Let me address each point:
1- .env Setup in NestJS: Great observation! While .env support can feel more straightforward in some frameworks, NestJS intentionally separates concerns to align with its modular architecture. Using the @nestjs/config package for .env management is considered the standard way in NestJS, providing flexibility and scalability for larger applications. While it may seem like more setup initially, this approach ensures you can easily manage configurations across modules, which is particularly helpful for production-grade applications.
2- ConfigService Usage: You’re absolutely right about the benefits of ConfigService-it abstracts away manual parsing and type conversion, making configuration handling cleaner and more robust. In this project, I chose a more direct approach to show how the system works at a lower level, but I agree that using ConfigService is a better practice for production. I'll make a note to cover this in future videos to highlight the advantages!
3- TypeORM Synchronize: Enabling synchronize in development is helpful because it simplifies schema updates during active development. However, in production, it’s best to disable this and rely on proper migrations to ensure controlled and predictable database changes. You're correct that failing to test migrations thoroughly in a staging environment can lead to bugs in production. Best practice is to rigorously test migrations in a staging environment before deployment.
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from CS books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
Very nice, thanks, Will you post this project on github?
Thanks for watching, I hope you enjoyed it! Here is the github Link github.com/vahid-nejad/nestjs-graphql-course
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from CS books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html
@ of course
Thank you for the video bro, but you have a conceptual error about modules because you don't inject the classes, you don't export the services, nor do you import the modules between them. The idea is to import modules and with them comes everything that is exported in "exports"
Thanks for your feedback. Actually, I didn't understand your point. Could you please clarify that?
When you create a module you must make sure that what you create in it only works within it. If you need to use things from module A in module B you must export in "exports" the functionalities or services that you want to provide to other modules; and in "providers" are the services that you provide in your own module. This is called module dependency, when module A depends on module B to work, therefore, module A should only contain in "imports:[ModuleB]" and would have access to all the functionalities of B (obviously when you use the services they will appear to come from the path where they are created, but internally the creation of the classes will be handled by the Dependency Injection Container). //Module A @Module({ imports:[PrismaModule, JwtModule, UserModule], controllers: [AuthController], providers: [AuthService], }) export class AuthModule {} //Module B @Module({ imports:[PrismaModule, JwtModule], controllers: [UserController], providers: [UserService, ], exports:[UserService], }) export class UserModule {}
great tutorial
Thanks for the feedback! 👍
By the way, if you enjoy learning and want to dive deeper into computer science topics made simple, I run another channel where I summarize key concepts from CS books. I would be very glad if you subscribe to my new channel: ua-cam.com/channels/ZYhXrFwhFUOXuSQNgfk-Sw.html