Fastest Way to Create APIs? | NestJS Tutorial

Поділитися
Вставка
  • Опубліковано 3 січ 2025

КОМЕНТАРІ • 119

  • @martinmtandi335
    @martinmtandi335 3 роки тому +4

    Aint I glad I bumped into your video. You are the first person to teach me Nestjs in a way I actually understood. Thank you so much

  • @mariusespejo
    @mariusespejo  3 роки тому +13

    I spend quite a bit of time explaining things through this video however you'll notice that the total amount of code written is not a lot at all. This means that once you know how to do this, it will probably only take you 10-15 minutes to do! If you want jump ahead to the implementation you can go to 17:00 or use the other timestamps below. If you have any feedback let me know!
    00:00​ - Intro
    00:15​ - What we'll be building
    04:28​ - Nestjs installation
    05:52​ - Generated initial code overview
    06:44​ - Generating Users Module
    08:44​ - Adding Swagger
    11:26​ - TypeORM / Database sqlite config
    13:31​ - Create User entity
    16:10​ - CRUD Generator?
    17:00​ - nestjsx/crud
    18:16​ - Users Controller
    20:07​ - Users Service
    23:20​ - Implementation Complete! Demo
    25:45​ - Conclusion
    26:06​ - How to customize further
    26:53​ - Outro

  • @SameerG2387
    @SameerG2387 2 роки тому

    Loved this framework CRUD. I was doing something similar as a side project 2 years back and just realized it's already there in market. Thanks for the video.

  • @Electricity0
    @Electricity0 3 роки тому +2

    Thanks for this intro, very helpful.

    • @mariusespejo
      @mariusespejo  3 роки тому

      thanks for the feedback! glad it’s helpful

  • @EstebanHelgueroCardiff
    @EstebanHelgueroCardiff Рік тому

    Great tutorial! Thanks for sharing it!

  • @glnse6907
    @glnse6907 3 роки тому

    It really nice that nestjs already have CRUD and plus a auto generated documentation by Swagger!!! I used to create custom file in express. Thanks for this!

    • @mariusespejo
      @mariusespejo  3 роки тому

      same, I had to go through the pain of writing specs manually with express haha never again

  • @DavidWoodMusic
    @DavidWoodMusic 2 роки тому

    Great video brother.

  • @Squest
    @Squest Рік тому

    This tutorial is great! Thank u so much!

  • @ryangolash6310
    @ryangolash6310 3 роки тому +1

    Great piece of work, mate! This certainly going to inspire me to learn more about NestJS. Quite a powerful and helpful framework for an experienced node API developer!

    • @mariusespejo
      @mariusespejo  3 роки тому

      thanks glad to hear! If you’re already doing some node work I definitely highly recommend giving Nest a shot!

  • @sanse4409
    @sanse4409 Рік тому

    Thank you for this amazing tutorial! SUBED!

  • @ethanliu4012
    @ethanliu4012 3 роки тому +1

    I am the 250 subscriber!

  • @Not256O0
    @Not256O0 3 роки тому

    Thank you for saving me some hours of work man

  • @kazejohns
    @kazejohns 3 роки тому

    Really cool bro!

  • @alice7613
    @alice7613 2 роки тому

    Thank you so much for your wonderful work. It is very helpful. I enjoy watching your video and really like the way you explain things - simple, clear and relaxed.

    • @mariusespejo
      @mariusespejo  2 роки тому

      Thanks for stopping by to comment 🙂

  • @markgerado2070
    @markgerado2070 3 роки тому

    Damn 🔥 Quality content. Keep it up man

  • @choicechoices
    @choicechoices Рік тому

    very helpful!

  • @nonenone8709
    @nonenone8709 3 роки тому

    Thank you for your great work! Your videos are really useful.

  • @oussamasethoum1665
    @oussamasethoum1665 3 роки тому

    Thank you so much, this is very useful

  • @ErrorSolution
    @ErrorSolution 3 роки тому

    my hero of the day
    real boss

  • @AfifAlfiano
    @AfifAlfiano 3 роки тому

    Nice content. Thanks

  • @samislam2746
    @samislam2746 27 днів тому

    Can we learn Nestia, the popular package for nestjs? there are no tutorials out there about it

  • @sadekhossain9566
    @sadekhossain9566 3 роки тому +1

    what is the microphone you are using? name please? Also how do you capture yourself?
    And many thanks for this nice little tutorial

    • @mariusespejo
      @mariusespejo  3 роки тому

      if you’re interested in doing similar recordings I would suggest starting with a usb mic like the blue yeti, which I use in my older videos. There are various ways you can record the screen as well as yourself, on Macs there is quicktime (free) and screenflow for example. On windows there is the game bar that can also record, and camtasia I believe is a popular paid one. Lots of different options. Hope that helps!

  • @koljacheesch
    @koljacheesch 3 роки тому

    You didnt say about load balancing. At this time, I have nest js app like this and when many clients requests api, a lot database queries awaits created. It stacks node js and server stops responding.

    • @mariusespejo
      @mariusespejo  3 роки тому

      That doesn’t sound like a load balancing problem, do you have multiple instances of your server? Anyways there are other solutions for load balancing, it’s outside the scope of this video

  • @shabbirhusain6634
    @shabbirhusain6634 Рік тому

    Hey! can you tell how you add that cool effect in terminal, I am talking about fade particles effect, Thank you.
    You are one of the best instructor.

    • @mariusespejo
      @mariusespejo  Рік тому

      I was using the hyper terminal here, it’s just one of the default plugins you can install

    • @shabbirhusain6634
      @shabbirhusain6634 Рік тому

      @@mariusespejo Thank you mate. Love the way you taught😃

  • @BasuraRatnayake
    @BasuraRatnayake 2 роки тому

    Thanks, really helpful. Also could you do one with Microservices?

  • @aravindpvk
    @aravindpvk 3 роки тому

    Thank for the content.... Your NestJS videos are really helping me. I am curious to know how you are getting that NPM Scripts tag at the left bottom using which you are running npm scripts.

    • @mariusespejo
      @mariusespejo  3 роки тому +1

      thanks! That npm window is built-in to VS code im pretty sure.
      Maybe add this to your settings if you’re not seeing it:
      “npm.enableScriptExplorer”: true

    • @aravindpvk
      @aravindpvk 3 роки тому

      @@mariusespejo Figured it out in the meanwhile. Thank you again.

  • @scottgasparick3753
    @scottgasparick3753 3 роки тому

    All of the filtering, search, sort, etc... did you have to manually set any of that up?

    • @mariusespejo
      @mariusespejo  3 роки тому +1

      No, did you watch the entire video? Pretty I sure I show exactly what minimal setup I had to do

  • @matrixantas
    @matrixantas 3 роки тому

    Thank you Marius for great Video, maybe you can tell the best way to group Response data with nestjsx/crud ?

  • @BrendanTheDude88
    @BrendanTheDude88 3 роки тому

    Do you have a tutorial on creating seed data for NestJS? I am trying to find a way to do it, that it is not specifically tied to TypeOrm.

    • @mariusespejo
      @mariusespejo  3 роки тому

      I do have a video on typeorm which covers migrations which can also be used to seed data. Other ORMs have an actual seeding feature

  • @pankaj-sharma3
    @pankaj-sharma3 3 роки тому +1

    Thanks for the amazing tutorial. Do you plan to make more content? If so, then can you please please create a series or big video on CRUD Operations and User Authentication using MEAN Stack but with NestJS instead of Express. Angular, Mongo, Nest and Nodejs, CRUD's with user authentication. Thanks again for the amazing video.

    • @mariusespejo
      @mariusespejo  3 роки тому +2

      definitely making more fullstack content! thanks for the suggestion!

    • @pankaj-sharma3
      @pankaj-sharma3 3 роки тому +1

      @@mariusespejo Thanks and ur most welcome, looking forward to it.

    • @martinmtandi335
      @martinmtandi335 3 роки тому +1

      they is too much content on Mongo, do one with TypeORM like you did here but like a proper API with authentication and stuff

    • @mariusespejo
      @mariusespejo  3 роки тому

      definitely!

    • @mariusespejo
      @mariusespejo  3 роки тому

      just added a deeper dive on TypeORM if you're interested! ua-cam.com/video/sNosL578ECo/v-deo.html

  • @smren
    @smren 2 роки тому

    Hey bro, I'm getting error on the typeorm installation, do you know if this is a conflict with the M1 macs or something like that? I just cant do that, sadly

    • @smren
      @smren 2 роки тому

      nvm, I just tried using mysql2 and it worked for some reason ._.

    • @mariusespejo
      @mariusespejo  2 роки тому

      @@smren glad you got it working! There is also an incompatibility at the moment between @nest/typeorm, typeorm 0.3.x, they're still working to support that new release. So I'd use typeorm 0.2.x for now

  • @KavehSaket
    @KavehSaket 3 роки тому

    Thanks for the video. Can we use the nest/crud package for Mongo? or do you know any alternative package for the Mongo. Thanks, heaps.

    • @mariusespejo
      @mariusespejo  3 роки тому

      At the moment, it doesn't seem like it. Sounded like they had intentions to do it, but never made the implementation. See: github.com/nestjsx/crud/issues/152

    • @KavehSaket
      @KavehSaket 3 роки тому

      @@mariusespejo I see. Thank you.

  • @tanzimibthesam5861
    @tanzimibthesam5861 3 роки тому

    Would you recommend using it as a SPA with any React Vue or Angular or use it with a template thanks.

    • @mariusespejo
      @mariusespejo  3 роки тому +1

      Nest uses Express under the hood by default, so technically anything you can do with Express you can do with Nest. That includes template rendering with handlebars, pug, etc. And yes you can have it “serve” up SPAs with react/angular/vue. However it’s core purpose as a framework revolves more around developing microservices. If you just need a basic static file server, probably better to use Express or others.

  • @iqbal045
    @iqbal045 3 роки тому

    This video was awesome! Can you please tell me what theme you use in vscode?

    • @mariusespejo
      @mariusespejo  3 роки тому

      thank you! In this video I believe I was using night owl because the contrast looks good for recordings, but typically I would use One Monokai

  • @Imsurethishasnotbeentaken
    @Imsurethishasnotbeentaken 11 місяців тому

    nestjsx/crud has been without any update for years. It doesn't even work fine with typerom > 0.3. Any alternatives?

    • @mariusespejo
      @mariusespejo  11 місяців тому

      Good to know thanks! I’m not aware of anything similar, but honestly you can just use the nest cli to auto generate all the CRUD boilerplate for you, you’d just need to add the db queries

    • @Imsurethishasnotbeentaken
      @Imsurethishasnotbeentaken 11 місяців тому

      @@mariusespejo well, that package did that automatically and also provided a client to interact with it (with filtering and pagination)

    • @mariusespejo
      @mariusespejo  11 місяців тому

      Yes, so if you’re heavily invested in using it your best bet is to not upgrade typeorm (or downgrade). Personally I think whatever is auto generated for you is not a ton of work to do yourself. It does save you some boilerplate, but in the long run I’ve found it to just get in the way once you need more customization. If having a client is the most important aspect, personally I’d rather use ts-rest and create a type-safe client which is auto generated from a contract that your API adheres to (I made a video about that if you’re interested)

    • @Imsurethishasnotbeentaken
      @Imsurethishasnotbeentaken 11 місяців тому

      @@mariusespejo thanks for the replies. I’m not really interested in ts-rest. I mean, if I typed everything in the entities and dtos , I just prefer to consume the swagger and autogenerate from that. The APIs I develop are for my apps and also for the clients that use my apps, so they can’t integrate however they want with their current apps. There’s a fork from crudx but it’s not as maintained as the original one. Right know in playing with api platform (which is built on top of Symfony), which right know I think is the fastest way to have a rest api up and running

  • @blacktipe9922
    @blacktipe9922 3 роки тому

    is there any Part 2 or something or is this "done"?

    • @mariusespejo
      @mariusespejo  3 роки тому

      It’s not a series, just an intro to the package. Was there something specific you were looking for? The docs for that package are quite good

    • @blacktipe9922
      @blacktipe9922 3 роки тому

      @@mariusespejo well some web scraping api like cat api that will generate random pics would be insne

    • @mariusespejo
      @mariusespejo  3 роки тому

      Practically speaking I would just use something like the unsplash api for that lol I don’t know much about web scraping tbh, maybe I’ll give it a try sometime. You should go for it though, if you’re looking for a side project

  • @OrbitTurner
    @OrbitTurner 3 роки тому +1

    🔥🔥🔥 Man You are underRated 😫😫 You saved me so much time...❤❤ I'll share your vidéo to all of my communities cause you deserve it !🙌🏿🙌🏿
    💨 Thinking about it 🤔:
    Did you think about creating a Discord Server for your youtube community ?

    • @mariusespejo
      @mariusespejo  3 роки тому +1

      I don’t think I have enough subscribers to build a community hahaha I do plan to make content consistently so maybe if one day it grows quite a bit more. Anyways I appreciate you sharing the video!

    • @OrbitTurner
      @OrbitTurner 3 роки тому +1

      @@mariusespejo Okay 😂 I will be waiting For That Man Hope it will be sooon 👍👍

  • @LeeXtremist
    @LeeXtremist 9 місяців тому

    This import completion is problematic, it's difficult to instatiate. Which extensions are you using for this?

    • @mariusespejo
      @mariusespejo  9 місяців тому

      Import intellisense is generally just typescript, it doesn’t require extensions

  • @nishattasnimmithila9397
    @nishattasnimmithila9397 3 роки тому

    what's the theme you are using?

  • @holidayabovesky8922
    @holidayabovesky8922 2 роки тому

    hello I can't run users module and controller, maybe anyone can help me?

  • @productive1185
    @productive1185 3 роки тому

    When you are typing in your terminal, you get a cool effect. How do you did that? :D

    • @mariusespejo
      @mariusespejo  3 роки тому +1

      people ask that often! haha I'm using hyper as my terminal for that, the effect is just one of the plugins. Take a look: hyper.is/

    • @productive1185
      @productive1185 3 роки тому

      @@mariusespejo Thank you very much for the quick answer! :D

  • @sameeraperera7912
    @sameeraperera7912 3 роки тому

    Thanks

  • @bombrman1994
    @bombrman1994 Рік тому

    its strange I followed everything step by step and on the swagger I get 500 response

    • @mariusespejo
      @mariusespejo  Рік тому

      Always check most recent docs, things change quickly

    • @bombrman1994
      @bombrman1994 Рік тому

      @@mariusespejo alright, thanks will give it a shot following the docs this time.

  • @joewho1446
    @joewho1446 Рік тому

    no metadata for user found

  • @diveshdive
    @diveshdive 3 роки тому

    could you please share the source code link

    • @mariusespejo
      @mariusespejo  3 роки тому

      sorry I didn’t push this to a repo. If you need a written reference I highly recommend using the official nest docs as well as the crud package docs, they’re both extremely well documented

  • @NathanielBabalola
    @NathanielBabalola 3 роки тому

    what is really a service ?

    • @mariusespejo
      @mariusespejo  3 роки тому

      hey Nathaniel, I have another Nest Crash Course video on my channel which goes over the fundamentals. I would maybe recommend taking a look at the first, goes into much more detail

    • @NathanielBabalola
      @NathanielBabalola 3 роки тому

      @@mariusespejo okay, thanks. Please can you post the link

    • @mariusespejo
      @mariusespejo  3 роки тому +1

      ua-cam.com/video/2n3xS89TJMI/v-deo.html

    • @NathanielBabalola
      @NathanielBabalola 3 роки тому +1

      @@mariusespejo thank you

  • @JogloDev
    @JogloDev 3 роки тому

    Nest JS transaction, maybe it's the good topic.

  • @lutfiikbalmajid3128
    @lutfiikbalmajid3128 3 роки тому

    bye bye php and express hehe

    • @mariusespejo
      @mariusespejo  3 роки тому

      Well still express under the hood by default 😅

    • @lutfiikbalmajid3128
      @lutfiikbalmajid3128 3 роки тому

      @@mariusespejo haha yes, i just read the author, its based on express and socket io thats why could be realtime. cool

    • @lutfiikbalmajid3128
      @lutfiikbalmajid3128 3 роки тому

      @@mariusespejo btw thanks for your tutorial. like it!

  • @ngocthiennguyen3318
    @ngocthiennguyen3318 2 роки тому

    I use the command "yarn add --save @nestjs/sequelize" but when importing { SequelizeModule } from '@nestjs/sequelize';
    error Cannot find module '@nestjs/sequelize' or its corresponding type declarations. I use "yarn add --save @nestjs/sequelize" again and it gives me the error "error Missing list of packages to add to your project."

    • @mariusespejo
      @mariusespejo  2 роки тому

      I don’t think I used sequelize for this video? Might be better to ask this on in stackoverflow

  • @theBarracuda_
    @theBarracuda_ Рік тому

    Am I the only one having this issue? ts-loader 9.4.2 missing peer webpack@^5.0.0. Do I need this ts-loader if so should I install the webpack?

    • @mariusespejo
      @mariusespejo  Рік тому

      Did you use the Nest CLI to create your project? It should have come with webpack and installed it for you

    • @theBarracuda_
      @theBarracuda_ Рік тому

      @@mariusespejo yup. Maybe that’s could be related to pnpm?

    • @theBarracuda_
      @theBarracuda_ Рік тому

      @@mariusespejo also, wanted to say that you’re doing an incredible work, keep going !!

    • @mariusespejo
      @mariusespejo  Рік тому

      Thanks! Anyways Nest does use webpack when you run it in dev/watch mode so something is not right with your dependencies installation

    • @theBarracuda_
      @theBarracuda_ Рік тому

      @@mariusespejo lol weird I was able to run start:dev and everything was just fine

  • @matrixantas
    @matrixantas 3 роки тому

    Thank you for great tutorial material, maybe someone has problem with POST method within @PrimaryGeneratedColumn() ? this always return NULL, not generated number

    • @mariusespejo
      @mariusespejo  3 роки тому

      likely a problem with your datebase config, perhaps you never ran migrations?

    • @matrixantas
      @matrixantas 3 роки тому

      @@mariusespejo Yes you are absolutely right, no migrations. Is it possible to make it work without migration with existing schema and data ?

    • @mariusespejo
      @mariusespejo  3 роки тому

      yes as long as your existing schema in the db matches what you’re representing in the entity. For example it sounds to me like your primary key is not already an auto incrementing int, which is what @PrimaryGeneratedColumn does. You’d have to update the your database to match, and the proper way to do that is through a migration