No video

Fastest Way to Create APIs? | NestJS Tutorial

In this video I walk you through one of the fastest ways to create a fully working RESTful Node.js CRUD API utilizing the Nestjs framework, TypeORM, Swagger/OpenAPI, and a few other packages!
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

Пікірлер: 118

  • @mariusespejo
    @mariusespejo3 жыл бұрын

    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

  • @martinmtandi335
    @martinmtandi3353 жыл бұрын

    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 жыл бұрын

    Glad I could help!

  • @SameerG2387
    @SameerG2387 Жыл бұрын

    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.

  • @ryangolash6310
    @ryangolash63103 жыл бұрын

    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!

  • @glnse6907
    @glnse69073 жыл бұрын

    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

  • @Electricity0
    @Electricity03 жыл бұрын

    Thanks for this intro, very helpful.

  • @mariusespejo

    @mariusespejo

    3 жыл бұрын

    thanks for the feedback! glad it’s helpful

  • @Squest
    @Squest9 ай бұрын

    This tutorial is great! Thank u so much!

  • @alice7613
    @alice76132 жыл бұрын

    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 🙂

  • @DavidWoodMusic
    @DavidWoodMusic2 жыл бұрын

    Great video brother.

  • @mariusespejo

    @mariusespejo

    2 жыл бұрын

    Thanks Rick! 👊

  • @EstebanHelgueroCardiff
    @EstebanHelgueroCardiff Жыл бұрын

    Great tutorial! Thanks for sharing it!

  • @mariusespejo

    @mariusespejo

    Жыл бұрын

    Glad it was helpful!

  • @sanse4409
    @sanse4409 Жыл бұрын

    Thank you for this amazing tutorial! SUBED!

  • @markgerado2070
    @markgerado20703 жыл бұрын

    Damn 🔥 Quality content. Keep it up man

  • @mariusespejo

    @mariusespejo

    3 жыл бұрын

    hey Mark! thank you!

  • @nonenone8709
    @nonenone87092 жыл бұрын

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

  • @mariusespejo

    @mariusespejo

    2 жыл бұрын

    Thank you!

  • @choicechoices
    @choicechoices10 ай бұрын

    very helpful!

  • @Not256O0
    @Not256O03 жыл бұрын

    Thank you for saving me some hours of work man

  • @mariusespejo

    @mariusespejo

    3 жыл бұрын

    no problem! glad it’s helpful

  • @ethanliu4012
    @ethanliu40123 жыл бұрын

    I am the 250 subscriber!

  • @mariusespejo

    @mariusespejo

    3 жыл бұрын

    haha yes!!

  • @holidayabovesky8922
    @holidayabovesky89222 жыл бұрын

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

  • @kazejohns
    @kazejohns3 жыл бұрын

    Really cool bro!

  • @smren
    @smren2 жыл бұрын

    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

  • @ErrorSolution
    @ErrorSolution2 жыл бұрын

    my hero of the day real boss

  • @oussamasethoum1665
    @oussamasethoum16652 жыл бұрын

    Thank you so much, this is very useful

  • @OrbitTurner
    @OrbitTurner3 жыл бұрын

    🔥🔥🔥 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 жыл бұрын

    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 жыл бұрын

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

  • @BasuraRatnayake
    @BasuraRatnayake Жыл бұрын

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

  • @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😃

  • @theoverallsite
    @theoverallsite3 жыл бұрын

    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 жыл бұрын

    definitely making more fullstack content! thanks for the suggestion!

  • @theoverallsite

    @theoverallsite

    3 жыл бұрын

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

  • @martinmtandi335

    @martinmtandi335

    3 жыл бұрын

    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! kzread.info/dash/bejne/pYKj1a5uZ5urc9I.html

  • @sadekhossain9566
    @sadekhossain95663 жыл бұрын

    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!

  • @matrixantas
    @matrixantas3 жыл бұрын

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

  • @koljacheesch
    @koljacheesch2 жыл бұрын

    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

    2 жыл бұрын

    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

  • @Imsurethishasnotbeentaken
    @Imsurethishasnotbeentaken7 ай бұрын

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

  • @mariusespejo

    @mariusespejo

    7 ай бұрын

    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

    7 ай бұрын

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

  • @mariusespejo

    @mariusespejo

    7 ай бұрын

    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

    7 ай бұрын

    @@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

  • @LeeXtremist
    @LeeXtremist5 ай бұрын

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

  • @mariusespejo

    @mariusespejo

    5 ай бұрын

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

  • @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

  • @AfifAlfiano
    @AfifAlfiano3 жыл бұрын

    Nice content. Thanks

  • @BrendanTheDude88
    @BrendanTheDude883 жыл бұрын

    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

  • @scottgasparick3753
    @scottgasparick37532 жыл бұрын

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

  • @mariusespejo

    @mariusespejo

    2 жыл бұрын

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

  • @aravindpvk
    @aravindpvk3 жыл бұрын

    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 жыл бұрын

    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.

  • @tanzimibthesam5861
    @tanzimibthesam58613 жыл бұрын

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

  • @mariusespejo

    @mariusespejo

    3 жыл бұрын

    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.

  • @KavehSaket
    @KavehSaket3 жыл бұрын

    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.

  • @ngocthiennguyen3318
    @ngocthiennguyen33182 жыл бұрын

    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

  • @joewho1446
    @joewho1446 Жыл бұрын

    no metadata for user found

  • @iqbal045
    @iqbal0453 жыл бұрын

    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

  • @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.

  • @sameeraperera7912
    @sameeraperera79123 жыл бұрын

    Thanks

  • @productive1185
    @productive11853 жыл бұрын

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

  • @mariusespejo

    @mariusespejo

    3 жыл бұрын

    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

  • @nishattasnimmithila9397
    @nishattasnimmithila93972 жыл бұрын

    what's the theme you are using?

  • @mariusespejo

    @mariusespejo

    2 жыл бұрын

    I believe night owl in this one

  • @blacktipe9922
    @blacktipe99223 жыл бұрын

    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

  • @JogloDev
    @JogloDev3 жыл бұрын

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

  • @mariusespejo

    @mariusespejo

    3 жыл бұрын

    will consider it, thanks!

  • @diveshdive
    @diveshdive3 жыл бұрын

    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
    @NathanielBabalola3 жыл бұрын

    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 жыл бұрын

    kzread.info/dash/bejne/ZKJn2rVxabewfaw.html

  • @NathanielBabalola

    @NathanielBabalola

    3 жыл бұрын

    @@mariusespejo thank you

  • @lutfiikbalmajid3128
    @lutfiikbalmajid31283 жыл бұрын

    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!

  • @matrixantas
    @matrixantas3 жыл бұрын

    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