title
Build a Node.js API - tutorial

description
Create basic CRUD routes with Node.js, Express, and MongoDB. NOTE: For this to work correctly, you must use the same version of mongodb. Your package.json file should say: "mongodb": "^2.2.33" 💻 Code on GitHub: https://github.com/beaucarnes/fcc-project-tutorials/tree/master/notable 🔗 Based on this article by Scott Domes: https://medium.freecodecamp.org/building-a-simple-node-js-api-in-under-30-minutes-a07ea9e390d2 🐦 Beau Carnes on Twitter: https://twitter.com/carnesbeau Check out free Postman programs for students and educators to help you learn more about APIs: https://www.postman.com/company/student-program/ Learn to code for free and get a developer job: https://www.freecodecamp.com Read hundreds of articles on technology: https://medium.freecodecamp.com And subscribe for new programming videos every day: https://youtube.com/subscription_center?add_user=freecodecamp

detail
{'title': 'Build a Node.js API - tutorial', 'heatmap': [{'end': 159.419, 'start': 112.288, 'weight': 0.886}, {'end': 300.53, 'start': 274.847, 'weight': 0.962}, {'end': 459.021, 'start': 435.004, 'weight': 0.718}, {'end': 527.16, 'start': 486.84, 'weight': 0.823}, {'end': 876.602, 'start': 850.628, 'weight': 1}, {'end': 1325.133, 'start': 1292.873, 'weight': 0.754}], 'summary': 'Learn to build a node.js backend with express and mongodb, create rest routes and perform crud operations for a note-taking app. setup notable project, configure mongodb with mlab, and implement crud operations in postman and node api for smooth data retrieval and management.', 'chapters': [{'end': 56.682, 'segs': [{'end': 56.682, 'src': 'embed', 'start': 0.329, 'weight': 0, 'content': [{'end': 7.773, 'text': 'This tutorial is a quick and simple guide to Node.js, the Express Framework and MongoDB,', 'start': 0.329, 'duration': 7.444}, {'end': 12.415, 'text': 'focusing on the fundamental REST routes and basic database interaction.', 'start': 7.773, 'duration': 4.642}, {'end': 18.618, 'text': "You'll build a simple API boilerplate that can then be used as the foundation for any app.", 'start': 13.075, 'duration': 5.543}, {'end': 29.163, 'text': 'So this, you should have a basic understanding of REST APIs and CRUD operations, which is just create, read, update, and delete.', 'start': 19.477, 'duration': 9.686}, {'end': 33.826, 'text': 'And you should also have some understanding of some basic JavaScript knowledge.', 'start': 30.083, 'duration': 3.743}, {'end': 39.769, 'text': 'I use ES6, mainly fat arrow functions, but nothing too complex.', 'start': 34.466, 'duration': 5.303}, {'end': 46.533, 'text': "For this tutorial, we'll create the skeleton of a backend for a note-taking app.", 'start': 40.77, 'duration': 5.763}, {'end': 48.635, 'text': 'Think something like Google Keep.', 'start': 47.154, 'duration': 1.481}, {'end': 53.399, 'text': "you'll want to be able to do all four CRUD actions on your notes.", 'start': 49.415, 'duration': 3.984}, {'end': 56.682, 'text': 'Like I was saying, create, read, update, and delete.', 'start': 53.439, 'duration': 3.243}], 'summary': 'Quick guide to building a node.js, express, and mongodb api for a note-taking app with crud operations and basic javascript knowledge.', 'duration': 56.353, 'max_score': 0.329, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj0329.jpg'}], 'start': 0.329, 'title': 'Building a node.js backend with express and mongodb', 'summary': 'Provides a guide to building a node.js backend with the express framework and mongodb, focusing on creating rest routes and basic database interaction for a note-taking app, requiring understanding of rest apis, crud operations, and basic javascript knowledge.', 'chapters': [{'end': 56.682, 'start': 0.329, 'title': 'Node.js, express, and mongodb tutorial', 'summary': 'Provides a quick and simple guide to building a node.js backend with the express framework and mongodb, focusing on creating fundamental rest routes and basic database interaction for a note-taking app, with a need for understanding rest apis, crud operations, and basic javascript knowledge.', 'duration': 56.353, 'highlights': ['The tutorial covers the fundamental REST routes and basic database interaction for a note-taking app, emphasizing the need to understand REST APIs and CRUD operations.', 'The tutorial aims to build a simple API boilerplate for a note-taking app, akin to Google Keep, allowing all four CRUD actions on notes.', 'Prior knowledge of REST APIs and CRUD operations is required for this tutorial, along with a basic understanding of JavaScript, particularly ES6 and fat arrow functions.']}], 'duration': 56.353, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj0329.jpg', 'highlights': ['The tutorial covers the fundamental REST routes and basic database interaction for a note-taking app, emphasizing the need to understand REST APIs and CRUD operations.', 'The tutorial aims to build a simple API boilerplate for a note-taking app, akin to Google Keep, allowing all four CRUD actions on notes.', 'Prior knowledge of REST APIs and CRUD operations is required for this tutorial, along with a basic understanding of JavaScript, particularly ES6 and fat arrow functions.']}, {'end': 317.188, 'segs': [{'end': 100.139, 'src': 'embed', 'start': 75.969, 'weight': 0, 'content': [{'end': 82.052, 'text': "If you don't have Node installed, check the link in the description for instructions on how to install Node.", 'start': 75.969, 'duration': 6.083}, {'end': 89.856, 'text': "So once you're in the new directory, we're just going to run npm init, and then we're going to follow along with the prompts.", 'start': 82.973, 'duration': 6.883}, {'end': 96.763, 'text': "So we'll just give it the name Notable that's already set there, version 1.1.", 'start': 90.977, 'duration': 5.786}, {'end': 100.139, 'text': "You know, we don't have to do really any of this stuff, so I'm just going to use the default for all of this.", 'start': 96.763, 'duration': 3.376}], 'summary': 'Installing node and initializing npm in new directory. using default settings.', 'duration': 24.17, 'max_score': 75.969, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj075969.jpg'}, {'end': 152.256, 'src': 'embed', 'start': 112.288, 'weight': 1, 'content': [{'end': 120.709, 'text': "You're going to use Express as your framework MongoDB as the database and a package called body parser to help deal with JSON requests.", 'start': 112.288, 'duration': 8.421}, {'end': 129.291, 'text': "So I'll just do MPM install, save Express, MongoDB, body parser.", 'start': 121.47, 'duration': 7.821}, {'end': 139.731, 'text': 'And I also highly recommend installing node mon as a dev dependency.', 'start': 135.149, 'duration': 4.582}, {'end': 144.693, 'text': "It's a simple little package that automatically restarts your server when files change.", 'start': 140.251, 'duration': 4.442}, {'end': 152.256, 'text': 'Okay, I got everything installed.', 'start': 150.896, 'duration': 1.36}], 'summary': 'Using express with mongodb and body parser, also installing node mon for automatic server restart.', 'duration': 39.968, 'max_score': 112.288, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj0112288.jpg'}, {'end': 159.419, 'src': 'heatmap', 'start': 112.288, 'weight': 0.886, 'content': [{'end': 120.709, 'text': "You're going to use Express as your framework MongoDB as the database and a package called body parser to help deal with JSON requests.", 'start': 112.288, 'duration': 8.421}, {'end': 129.291, 'text': "So I'll just do MPM install, save Express, MongoDB, body parser.", 'start': 121.47, 'duration': 7.821}, {'end': 139.731, 'text': 'And I also highly recommend installing node mon as a dev dependency.', 'start': 135.149, 'duration': 4.582}, {'end': 144.693, 'text': "It's a simple little package that automatically restarts your server when files change.", 'start': 140.251, 'duration': 4.442}, {'end': 152.256, 'text': 'Okay, I got everything installed.', 'start': 150.896, 'duration': 1.36}, {'end': 155.858, 'text': 'And now I just opened up the folder in sublime text.', 'start': 152.796, 'duration': 3.062}, {'end': 159.419, 'text': "So I'm going to go into the package dot JSON file right here.", 'start': 156.378, 'duration': 3.041}], 'summary': 'Using express framework with mongodb and body parser for json requests. installed node mon as a dev dependency.', 'duration': 47.131, 'max_score': 112.288, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj0112288.jpg'}, {'end': 300.53, 'src': 'heatmap', 'start': 250.132, 'weight': 3, 'content': [{'end': 254.813, 'text': 'Note that you also initialize your app as an instance of Express your framework.', 'start': 250.132, 'duration': 4.681}, {'end': 262.595, 'text': 'The last thing you need to do to get your server up and running is to tell your app to start listening for the HTTP requests.', 'start': 255.473, 'duration': 7.122}, {'end': 266.636, 'text': 'You can specify the port and start the listening like so.', 'start': 263.435, 'duration': 3.201}, {'end': 274.827, 'text': "console dot log, let's do a log here.", 'start': 272.466, 'duration': 2.361}, {'end': 280.57, 'text': 'And we are live on port.', 'start': 274.847, 'duration': 5.723}, {'end': 284.352, 'text': "Now I'm going to save this, I'll go back to my console.", 'start': 281.511, 'duration': 2.841}, {'end': 286.113, 'text': 'Let me clear that.', 'start': 284.372, 'duration': 1.741}, {'end': 295.264, 'text': 'If I run npm run dev, we should see an error.', 'start': 286.753, 'duration': 8.511}, {'end': 297.347, 'text': 'Okay, Express is not defined.', 'start': 295.665, 'duration': 1.682}, {'end': 298.468, 'text': "Let's see what we have to do here.", 'start': 297.367, 'duration': 1.101}, {'end': 300.53, 'text': 'I spelled this wrong.', 'start': 299.589, 'duration': 0.941}], 'summary': 'Initializing express app, starting server listening on port, and debugging with npm run dev.', 'duration': 34.22, 'max_score': 250.132, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj0250132.jpg'}], 'start': 57.482, 'title': 'Setting up notable project with node, express with mongodb and building api with server.js', 'summary': 'Demonstrates setting up a notable project using node, running npm init, and following prompts to create the project with version 1.1. it also details the process of setting up express with mongodb and body parser, including the installation of necessary dependencies and the configuration of package.json for automatic server restart using node mon. additionally, it covers creating a server.js file and building an api, requiring dependencies such as express, mongo client, and body parser, initializing the app as an instance of express, and starting the server to listen for http requests on port 8000, along with debugging the code and resolving errors.', 'chapters': [{'end': 96.763, 'start': 57.482, 'title': 'Setting up notable project with node', 'summary': 'Demonstrates setting up a notable project using node, running npm init, and following prompts to create the project, with version 1.1.', 'duration': 39.281, 'highlights': ['The chapter demonstrates setting up a Notable project using Node, running npm init, and following prompts to create the project, with version 1.1.', 'Instructions are provided for installing Node, and viewers are directed to the description for more details.', 'Acknowledgment given to Scott Domes for the original article that the video is based on.']}, {'end': 179.651, 'start': 96.763, 'title': 'Setting up express with mongodb and body parser', 'summary': 'Details the process of setting up express with mongodb and body parser, including the installation of necessary dependencies and the configuration of package.json for automatic server restart using node mon.', 'duration': 82.888, 'highlights': ['The chapter recommends using Express as the framework, MongoDB as the database, and body parser for handling JSON requests.', "The installation of necessary dependencies including Express, MongoDB, and body parser is suggested using the command 'npm install --save Express MongoDB body parser'.", 'Installing node mon as a dev dependency is highly recommended, as it automatically restarts the server when files change.', "The process of configuring the package.json file to automatically restart the server using node mon is explained, including adding 'node mon server.js' under scripts and removing unnecessary test configurations."]}, {'end': 317.188, 'start': 180.111, 'title': 'Building api with server.js', 'summary': 'Covers the process of creating a server.js file and building an api, requiring dependencies such as express, mongo client, and body parser, initializing the app as an instance of express, and starting the server to listen for http requests on port 8000. it also includes debugging the code and resolving errors.', 'duration': 137.077, 'highlights': ['Requiring dependencies such as Express, Mongo client, and body parser in server.js file.', 'Initializing the app as an instance of Express framework.', 'Starting the server to listen for HTTP requests on port 8000.', 'Debugging the code and resolving errors while running npm run dev.']}], 'duration': 259.706, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj057482.jpg', 'highlights': ['The chapter demonstrates setting up a Notable project using Node, running npm init, and following prompts to create the project, with version 1.1.', 'The chapter recommends using Express as the framework, MongoDB as the database, and body parser for handling JSON requests.', 'Installing node mon as a dev dependency is highly recommended, as it automatically restarts the server when files change.', 'Starting the server to listen for HTTP requests on port 8000.']}, {'end': 863.399, 'segs': [{'end': 400.445, 'src': 'embed', 'start': 318.257, 'weight': 0, 'content': [{'end': 320.038, 'text': "we're going to make some crud routes.", 'start': 318.257, 'duration': 1.781}, {'end': 329.722, 'text': "So for this example, we're going to build four routes, a route to create a note to read your notes to update a note and to delete a note.", 'start': 320.958, 'duration': 8.764}, {'end': 334.445, 'text': 'So this will give a good idea of how to structure almost any basic route with node.', 'start': 330.243, 'duration': 4.202}, {'end': 341.054, 'text': "to test the API, we're going to need to mimic a client side making requests.", 'start': 335.851, 'duration': 5.203}, {'end': 344.456, 'text': "So to do so we're going to use a great app called postman.", 'start': 341.434, 'duration': 3.022}, {'end': 348.919, 'text': 'It allows you to make simple HTTP requests with custom bodies and parameters.', 'start': 345.016, 'duration': 3.903}, {'end': 354.942, 'text': 'So to install postman, you can go to get postman.com and you can download it for various browsers.', 'start': 349.659, 'duration': 5.283}, {'end': 357.564, 'text': "There's also a Chrome extension.", 'start': 355.362, 'duration': 2.202}, {'end': 364.908, 'text': "So I'm just going to go to postman Chrome extension and add to Chrome.", 'start': 357.584, 'duration': 7.324}, {'end': 369.543, 'text': 'So this is one of the easiest ways to get it.', 'start': 367.662, 'duration': 1.881}, {'end': 372.285, 'text': "You don't have to install any special program on your computer.", 'start': 369.563, 'duration': 2.722}, {'end': 380.87, 'text': "And you don't even have to sign up.", 'start': 379.669, 'duration': 1.201}, {'end': 382.491, 'text': "I'll just do take me straight to the app.", 'start': 380.93, 'duration': 1.561}, {'end': 386.974, 'text': 'Okay, once you get Postman installed, it should look like this.', 'start': 383.792, 'duration': 3.182}, {'end': 388.736, 'text': "We're going to come back to this later.", 'start': 387.475, 'duration': 1.261}, {'end': 391.218, 'text': "So let's start setting up our routes.", 'start': 389.096, 'duration': 2.122}, {'end': 398.123, 'text': 'Most Node.js tutorials and many real apps put all their routes in one big routes.js file.', 'start': 392.278, 'duration': 5.845}, {'end': 400.445, 'text': "But we're going to do something different.", 'start': 398.803, 'duration': 1.642}], 'summary': 'Building 4 crud routes with node, testing using postman, and setting up routes differently.', 'duration': 82.188, 'max_score': 318.257, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj0318257.jpg'}, {'end': 463.185, 'src': 'heatmap', 'start': 435.004, 'weight': 0.718, 'content': [{'end': 438.528, 'text': "And then I'm going to make a file called index.js.", 'start': 435.004, 'duration': 3.524}, {'end': 445.115, 'text': "And then I'm going to make a file called note routes.js.", 'start': 439.008, 'duration': 6.107}, {'end': 448.578, 'text': "Okay, we're gonna go back into sublime text.", 'start': 446.396, 'duration': 2.182}, {'end': 451.882, 'text': "And we'll see if they're showing up here.", 'start': 450, 'duration': 1.882}, {'end': 454.916, 'text': "you can see they're right on the side.", 'start': 453.655, 'duration': 1.261}, {'end': 459.021, 'text': 'So are the index.js is empty, and then routes.js is empty.', 'start': 455.437, 'duration': 3.584}, {'end': 463.185, 'text': 'So these directories may seem like overkill for this simple small app.', 'start': 459.321, 'duration': 3.864}], 'summary': 'Creating index.js and note routes.js files for a small app.', 'duration': 28.181, 'max_score': 435.004, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj0435004.jpg'}, {'end': 527.16, 'src': 'heatmap', 'start': 486.84, 'weight': 0.823, 'content': [{'end': 499.308, 'text': "In your note routes that j s, we're going to put module that exports equals function app DB.", 'start': 486.84, 'duration': 12.468}, {'end': 502.03, 'text': 'Just like that.', 'start': 501.53, 'duration': 0.5}, {'end': 508.183, 'text': 'And then you can export this function through your index dot j s.', 'start': 503.519, 'duration': 4.664}, {'end': 509.905, 'text': "So let's start filling in that file.", 'start': 508.183, 'duration': 1.722}, {'end': 512.847, 'text': "First we're going to have a const.", 'start': 511.366, 'duration': 1.481}, {'end': 527.16, 'text': "note routes equals require and we're going to require require the notes routes file what we just exported then module dot exports,", 'start': 512.847, 'duration': 14.313}], 'summary': 'Create a module that exports a function for note routes in index.js.', 'duration': 40.32, 'max_score': 486.84, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj0486840.jpg'}, {'end': 680.501, 'src': 'embed', 'start': 651.276, 'weight': 6, 'content': [{'end': 656.179, 'text': "And in that callback it's going to pass in the request object,", 'start': 651.276, 'duration': 4.903}, {'end': 663.605, 'text': 'which contains the parameters or JSON of the request and a response object which is used to reply.', 'start': 656.179, 'duration': 7.426}, {'end': 667.247, 'text': "So we're going to actually test this by going into postman.", 'start': 663.625, 'duration': 3.622}, {'end': 670.189, 'text': "First, let's make sure all I'm gonna make sure all my files are saved.", 'start': 667.507, 'duration': 2.682}, {'end': 674.032, 'text': "I'm gonna run my server again with npm run dev.", 'start': 670.69, 'duration': 3.342}, {'end': 678.559, 'text': 'Oh, I have an error.', 'start': 677.558, 'duration': 1.001}, {'end': 680.501, 'text': 'It says requires not defined.', 'start': 678.579, 'duration': 1.922}], 'summary': 'Testing callback function with request and response objects, encountering an error', 'duration': 29.225, 'max_score': 651.276, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj0651276.jpg'}, {'end': 863.399, 'src': 'embed', 'start': 826.82, 'weight': 3, 'content': [{'end': 828.041, 'text': 'you can see undefined here.', 'start': 826.82, 'duration': 1.221}, {'end': 833.982, 'text': "that's because on Express can't process URL encoded forms on its own.", 'start': 828.041, 'duration': 5.941}, {'end': 838.184, 'text': 'But we did install the body parser package.', 'start': 834.743, 'duration': 3.441}, {'end': 840.785, 'text': "So let's go back into our code.", 'start': 838.984, 'duration': 1.801}, {'end': 842.985, 'text': "We're gonna go back into the server.", 'start': 841.365, 'duration': 1.62}, {'end': 850.608, 'text': "And right below the port, I'm going to do app dot use body parser.", 'start': 844.346, 'duration': 6.262}, {'end': 857.456, 'text': 'And that URL encoded and extend extended.', 'start': 850.628, 'duration': 6.828}, {'end': 863.399, 'text': "True Now it's going to be able to process that correctly.", 'start': 859.917, 'duration': 3.482}], 'summary': 'Using body parser in express to process url encoded forms.', 'duration': 36.579, 'max_score': 826.82, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj0826820.jpg'}], 'start': 318.257, 'title': 'Node.js crud routes', 'summary': 'Covers building crud routes for a note-taking application in node, emphasizing the use of postman for testing the api, setting up node.js routes using postman, and installing the body parser package for processing url encoded forms.', 'chapters': [{'end': 372.285, 'start': 318.257, 'title': 'Creating crud routes with node', 'summary': 'Covers building four crud routes - create, read, update, and delete - for a note-taking application in node, emphasizing the use of postman to test the api.', 'duration': 54.028, 'highlights': ['Building four CRUD routes - create, read, update, and delete - for a note-taking application in Node.', 'Emphasizing the use of Postman to test the API, allowing simple HTTP requests with custom bodies and parameters.', 'Instructions on installing Postman from getpostman.com for various browsers or as a Chrome extension.']}, {'end': 863.399, 'start': 379.669, 'title': 'Setting up node.js routes with postman', 'summary': "Demonstrates setting up node.js routes using postman, splitting files into separate folders for better manageability, creating a 'note' route, testing with postman, and installing the body parser package for processing url encoded forms.", 'duration': 483.73, 'highlights': ['Demonstrating setting up Node.js routes with Postman', "Creating a 'note' route", 'Testing route with Postman', 'Installing the body parser package for processing URL encoded forms']}], 'duration': 545.142, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj0318257.jpg', 'highlights': ['Building four CRUD routes - create, read, update, and delete - for a note-taking application in Node.', 'Emphasizing the use of Postman to test the API, allowing simple HTTP requests with custom bodies and parameters.', 'Demonstrating setting up Node.js routes with Postman', 'Installing the body parser package for processing URL encoded forms', 'Instructions on installing Postman from getpostman.com for various browsers or as a Chrome extension.', "Creating a 'note' route", 'Testing route with Postman']}, {'end': 1041.044, 'segs': [{'end': 917.902, 'src': 'embed', 'start': 889.529, 'weight': 0, 'content': [{'end': 892.511, 'text': "It's free for the small size and quite fast to set up.", 'start': 889.529, 'duration': 2.982}, {'end': 894.933, 'text': "So let's do that we're going to go over to our browser.", 'start': 892.832, 'duration': 2.101}, {'end': 898.515, 'text': "And we're going to go to M lab dot com.", 'start': 896.374, 'duration': 2.141}, {'end': 901.276, 'text': "Now you're going to create an account if you don't already have one.", 'start': 899.135, 'duration': 2.141}, {'end': 902.936, 'text': "Or for me I'm just going to log in.", 'start': 901.656, 'duration': 1.28}, {'end': 911.8, 'text': "OK After you get logged in to M lab or you create an account we're going to create a new MongoDB deployment.", 'start': 904.457, 'duration': 7.343}, {'end': 913.54, 'text': "So I'm just going to click create new.", 'start': 911.82, 'duration': 1.72}, {'end': 917.902, 'text': 'And just click the free one here.', 'start': 916.081, 'duration': 1.821}], 'summary': 'Mlab offers fast setup and free small-sized mongodb deployments.', 'duration': 28.373, 'max_score': 889.529, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj0889529.jpg'}, {'end': 1041.044, 'src': 'embed', 'start': 986.109, 'weight': 1, 'content': [{'end': 988.389, 'text': 'There we go.', 'start': 986.109, 'duration': 2.28}, {'end': 992.89, 'text': 'And here is my config directory that I just created.', 'start': 989.41, 'duration': 3.48}, {'end': 995.011, 'text': "And here's my database file.", 'start': 993.25, 'duration': 1.761}, {'end': 998.871, 'text': "So in this file, we're going to add the URL.", 'start': 995.831, 'duration': 3.04}, {'end': 1001.112, 'text': 'So module that exports.', 'start': 999.091, 'duration': 2.021}, {'end': 1006.75, 'text': 'equals this is the URL we just copied on MongoDB URL.', 'start': 1002.327, 'duration': 4.423}, {'end': 1010.974, 'text': "We're gonna make sure it's in parentheses.", 'start': 1006.77, 'duration': 4.204}, {'end': 1012.946, 'text': 'So I just copy this.', 'start': 1012.025, 'duration': 0.921}, {'end': 1016.448, 'text': 'Now I also have to insert my username and password.', 'start': 1013.326, 'duration': 3.122}, {'end': 1020.23, 'text': 'So the username is bofcc.', 'start': 1016.988, 'duration': 3.242}, {'end': 1023.913, 'text': 'The password, this is a very secure password.', 'start': 1020.831, 'duration': 3.082}, {'end': 1025.834, 'text': "It's just password.", 'start': 1023.973, 'duration': 1.861}, {'end': 1029.416, 'text': "And we'll change that in a little bit here.", 'start': 1026.714, 'duration': 2.702}, {'end': 1034.579, 'text': 'Now if you are going to commit this project to GitHub, you want to be sure to include the .', 'start': 1029.877, 'duration': 4.702}, {'end': 1041.044, 'text': "gitignore file so you don't share your password with everyone like I'm doing through this video.", 'start': 1034.579, 'duration': 6.465}], 'summary': "Configuring database file with mongodb url, username 'bofcc', and secure password, then adding .gitignore file to protect sensitive information.", 'duration': 54.935, 'max_score': 986.109, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj0986109.jpg'}], 'start': 863.419, 'title': 'Setting up mongodb with mlab', 'summary': 'Covers the process of setting up a mongodb database using mlab, which is free for small size and fast to set up. it includes creating a new mongodb deployment and configuring the database with a user and password.', 'chapters': [{'end': 1041.044, 'start': 863.419, 'title': 'Setting up mongodb with mlab', 'summary': 'Covers setting up a mongodb database using mlab, which is free for small size and fast to set up, creating a new mongodb deployment, and configuring the database with a user and password.', 'duration': 177.625, 'highlights': ['Creating a new MongoDB deployment in Mlab', 'Configuring the database with a user and password', 'Importance of including .gitignore file to protect sensitive information']}], 'duration': 177.625, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj0863419.jpg', 'highlights': ['Creating a new MongoDB deployment in Mlab', 'Configuring the database with a user and password', 'Importance of including .gitignore file to protect sensitive information']}, {'end': 1679.972, 'segs': [{'end': 1078.053, 'src': 'embed', 'start': 1042.425, 'weight': 4, 'content': [{'end': 1053.933, 'text': 'So now in the server dot j s file, we can use the Mongo client to connect to the database, and then use this to wrap the app setup.', 'start': 1042.425, 'duration': 11.508}, {'end': 1055.914, 'text': "So let's see how to do that.", 'start': 1054.574, 'duration': 1.34}, {'end': 1058.796, 'text': "First, we're going to require it.", 'start': 1056.555, 'duration': 2.241}, {'end': 1074.231, 'text': "So const DB, we're requiring the database, that database configuration file require a Okay, now I'm going to line this up up here.", 'start': 1058.876, 'duration': 15.355}, {'end': 1078.053, 'text': "And then down here, we're going to use the Mongo client.", 'start': 1074.251, 'duration': 3.802}], 'summary': 'Using mongo client in server.js to connect to database', 'duration': 35.628, 'max_score': 1042.425, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj01042425.jpg'}, {'end': 1203.457, 'src': 'embed', 'start': 1139.921, 'weight': 0, 'content': [{'end': 1142.843, 'text': "So that's the last of the infrastructure setup.", 'start': 1139.921, 'duration': 2.922}, {'end': 1145.225, 'text': "It's all route building from here.", 'start': 1143.604, 'duration': 1.621}, {'end': 1150.128, 'text': 'MongoDB stores data and collections, which are exactly how they sound.', 'start': 1146.225, 'duration': 3.903}, {'end': 1154.711, 'text': 'In this case, we want to store notes in a collection called notes.', 'start': 1150.608, 'duration': 4.103}, {'end': 1163.677, 'text': "So since we pass in the database as the DB argument in the routes, see right here, we're passing in the database right here in the routes.", 'start': 1155.351, 'duration': 8.326}, {'end': 1166.54, 'text': 'So we can then access it like so.', 'start': 1164.058, 'duration': 2.482}, {'end': 1169.402, 'text': "Well, first, let's delete this, this was just temporary.", 'start': 1167, 'duration': 2.402}, {'end': 1178.889, 'text': "And if we write DB dot collection, and notes, so that's just how we would access our database.", 'start': 1170.723, 'duration': 8.166}, {'end': 1185.139, 'text': 'So creating a note is as simple as calling insert on the collections.', 'start': 1180.134, 'duration': 5.005}, {'end': 1187.821, 'text': 'So we can put .', 'start': 1185.699, 'duration': 2.122}, {'end': 1195.189, 'text': 'insert and we pass in the note that we still have to create the note.', 'start': 1187.821, 'duration': 7.368}, {'end': 1203.457, 'text': "But we're also going to pass in the callback function with an error and a results.", 'start': 1195.529, 'duration': 7.928}], 'summary': 'Setting up mongodb infrastructure for note storage and access in routes.', 'duration': 63.536, 'max_score': 1139.921, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj01139921.jpg'}, {'end': 1266.006, 'src': 'embed', 'start': 1236.695, 'weight': 6, 'content': [{'end': 1242.46, 'text': "So if we go into the postman, we can see that we're passing in the title and a body.", 'start': 1236.695, 'duration': 5.765}, {'end': 1245.123, 'text': "So that's where we're getting that body there.", 'start': 1243.121, 'duration': 2.002}, {'end': 1246.965, 'text': "So I'm also going to create the note with a title.", 'start': 1245.443, 'duration': 1.522}, {'end': 1263.206, 'text': 'rec.body.title. Okay, once the insert is complete or has failed for whatever reason, we want to either send back an error or send back the newly created note object.', 'start': 1248.661, 'duration': 14.545}, {'end': 1266.006, 'text': "So here's how we finish this code up here.", 'start': 1263.746, 'duration': 2.26}], 'summary': 'Creating a note with title and body in postman, handling insert completion or failure.', 'duration': 29.311, 'max_score': 1236.695, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj01236695.jpg'}, {'end': 1325.133, 'src': 'heatmap', 'start': 1292.873, 'weight': 0.754, 'content': [{'end': 1297.375, 'text': 'So the result to opt is going to be an array here.', 'start': 1292.873, 'duration': 4.502}, {'end': 1305.198, 'text': "And we're just going to send the first element in the array back, which is the note that we just created.", 'start': 1298.055, 'duration': 7.143}, {'end': 1306.699, 'text': "So let's try it out.", 'start': 1305.578, 'duration': 1.121}, {'end': 1307.999, 'text': "I'm going to save this.", 'start': 1306.759, 'duration': 1.24}, {'end': 1310.441, 'text': "I'm going to make sure my server is running.", 'start': 1308.82, 'duration': 1.621}, {'end': 1310.721, 'text': 'It is.', 'start': 1310.461, 'duration': 0.26}, {'end': 1312.782, 'text': 'Now go into postman.', 'start': 1311.641, 'duration': 1.141}, {'end': 1323.012, 'text': "And we're going to send a x dash www dash form dash URL encoded post request with postman with a title and a body just like we have here.", 'start': 1313.303, 'duration': 9.709}, {'end': 1325.133, 'text': "So I'm just going to click Send.", 'start': 1324.053, 'duration': 1.08}], 'summary': 'Sending a post request with title and body using postman to obtain the first element in the array.', 'duration': 32.26, 'max_score': 1292.873, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj01292873.jpg'}, {'end': 1370.475, 'src': 'embed', 'start': 1341.428, 'weight': 7, 'content': [{'end': 1343.748, 'text': 'So this was supposed to be the same.', 'start': 1341.428, 'duration': 2.32}, {'end': 1346.829, 'text': "So result, now it's a singular and singular.", 'start': 1343.768, 'duration': 3.061}, {'end': 1348.809, 'text': 'So let me save that.', 'start': 1346.849, 'duration': 1.96}, {'end': 1351.189, 'text': "And we're going to go back into Postman.", 'start': 1349.569, 'duration': 1.62}, {'end': 1352.61, 'text': "We're going to send this again.", 'start': 1351.589, 'duration': 1.021}, {'end': 1354.33, 'text': 'And here we go.', 'start': 1352.63, 'duration': 1.7}, {'end': 1354.97, 'text': 'We got this.', 'start': 1354.41, 'duration': 0.56}, {'end': 1359.151, 'text': 'The text is what a great note and the title is my note title.', 'start': 1355.23, 'duration': 3.921}, {'end': 1364.812, 'text': 'So we got this response from the server and also assigned an ID to it.', 'start': 1359.531, 'duration': 5.281}, {'end': 1366.772, 'text': "So let's go into MLAB now.", 'start': 1365.292, 'duration': 1.48}, {'end': 1370.475, 'text': 'So if we go into in lab, we go to collections.', 'start': 1367.691, 'duration': 2.784}], 'summary': 'Testing process resulted in successful response and id assignment.', 'duration': 29.047, 'max_score': 1341.428, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj01341428.jpg'}, {'end': 1616.512, 'src': 'embed', 'start': 1566.489, 'weight': 3, 'content': [{'end': 1573.633, 'text': 'MongoDB requires not just an ID as a string, but an ID as an object, or as I call it an object ID.', 'start': 1566.489, 'duration': 7.144}, {'end': 1580.288, 'text': "So that's actually an easy fix to do, we're going to have to require something at the top.", 'start': 1575.467, 'duration': 4.821}, {'end': 1602.592, 'text': "So I'm gonna do var dot var object ID equals require MongoDB dot object ID.", 'start': 1580.768, 'duration': 21.824}, {'end': 1616.512, 'text': "And then down here after the git command, app.git, I'm going to put const id equals rec.params.id.", 'start': 1604.403, 'duration': 12.109}], 'summary': "Using mongodb requires an object id, which can be easily fixed by requiring mongodb's object id and assigning it to a variable.", 'duration': 50.023, 'max_score': 1566.489, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj01566489.jpg'}], 'start': 1042.425, 'title': 'Building a note-taking app with mongodb and node.js', 'summary': 'Covers setting up mongodb and creating notes, including creating a notes collection, inserting notes, handling errors, and verifying the results, as well as building a note-taking app with mongodb and node.js, focusing on creating, reading, and deleting notes from the database, and handling object ids for mongodb, resulting in smoother data retrieval and management.', 'chapters': [{'end': 1398.242, 'start': 1042.425, 'title': 'Setting up mongodb and creating notes', 'summary': 'Covers setting up mongodb using the mongo client in the server.js file, creating a notes collection, inserting notes, handling errors, and verifying the results in postman and mlab.', 'duration': 355.817, 'highlights': ['Creating a note is as simple as calling insert on the collections', 'Verifying the results in Postman and MLAB', 'Setting up MongoDB using the Mongo client in the server.js file', 'Handling errors and sending back the newly created note object']}, {'end': 1679.972, 'start': 1398.782, 'title': 'Building a note-taking app with mongodb and node.js', 'summary': 'Demonstrates building a note-taking app using mongodb and node.js, including creating, reading, and deleting notes from the database, with a focus on retrieving notes by id and handling object ids for mongodb, resulting in smoother data retrieval and management.', 'duration': 281.19, 'highlights': ['The chapter demonstrates creating, reading, and deleting notes from a MongoDB database, with a focus on retrieving notes by ID, and handling object IDs for MongoDB, leading to efficient data management.', 'The tutorial provides a step-by-step guide for building a note-taking app using MongoDB and Node.js, including creating a new note, retrieving notes by ID, and handling object IDs for MongoDB, resulting in improved data retrieval and management.', 'The speaker explains the process of retrieving a note by its ID from the database using Node.js and MongoDB, emphasizing the importance of handling object IDs for MongoDB to ensure smooth data retrieval.', 'The tutorial highlights the significance of handling object IDs for MongoDB when retrieving notes by ID, as it ensures the proper conversion of string IDs to object IDs, enabling efficient querying and retrieval of data from the database.']}], 'duration': 637.547, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj01042425.jpg', 'highlights': ['The tutorial provides a step-by-step guide for building a note-taking app using MongoDB and Node.js, including creating a new note, retrieving notes by ID, and handling object IDs for MongoDB, resulting in improved data retrieval and management.', 'The chapter demonstrates creating, reading, and deleting notes from a MongoDB database, with a focus on retrieving notes by ID, and handling object IDs for MongoDB, leading to efficient data management.', 'The speaker explains the process of retrieving a note by its ID from the database using Node.js and MongoDB, emphasizing the importance of handling object IDs for MongoDB to ensure smooth data retrieval.', 'The tutorial highlights the significance of handling object IDs for MongoDB when retrieving notes by ID, as it ensures the proper conversion of string IDs to object IDs, enabling efficient querying and retrieval of data from the database.', 'Setting up MongoDB using the Mongo client in the server.js file', 'Creating a note is as simple as calling insert on the collections', 'Handling errors and sending back the newly created note object', 'Verifying the results in Postman and MLAB']}, {'end': 1988.906, 'segs': [{'end': 1711.243, 'src': 'embed', 'start': 1679.972, 'weight': 3, 'content': [{'end': 1680.752, 'text': 'So 3000.', 'start': 1679.972, 'duration': 0.78}, {'end': 1681.633, 'text': "So let's do that.", 'start': 1680.752, 'duration': 0.881}, {'end': 1689.018, 'text': 'And it returns with the ID, the text, what a great note and my note title can also do in postman.', 'start': 1682.013, 'duration': 7.005}, {'end': 1691.431, 'text': 'First of all, let me copy this.', 'start': 1689.949, 'duration': 1.482}, {'end': 1694.535, 'text': "Let's see if that's the same one.", 'start': 1691.451, 'duration': 3.084}, {'end': 1695.757, 'text': "Yep, that's the same ID.", 'start': 1694.555, 'duration': 1.202}, {'end': 1698.32, 'text': "So I'm going to do a get.", 'start': 1696.378, 'duration': 1.942}, {'end': 1702.606, 'text': "And I'm going to do slash and then put the ID there.", 'start': 1699.802, 'duration': 2.804}, {'end': 1703.247, 'text': 'Send that.', 'start': 1702.626, 'duration': 0.621}, {'end': 1708.661, 'text': 'And yep, it comes back with my what a great note, my note title.', 'start': 1704.838, 'duration': 3.823}, {'end': 1711.243, 'text': 'And that was directly from the database.', 'start': 1709.322, 'duration': 1.921}], 'summary': 'A successful retrieval of a note with id 3000 from the database was demonstrated using postman.', 'duration': 31.271, 'max_score': 1679.972, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj01679972.jpg'}, {'end': 1857.154, 'src': 'embed', 'start': 1822.458, 'weight': 0, 'content': [{'end': 1833.281, 'text': "and we're going to pass in the details and the note and then, after we pass in the note, everything else is going to stay the same.", 'start': 1822.458, 'duration': 10.823}, {'end': 1836.162, 'text': "so let's go into postman and we're going to try these out.", 'start': 1833.281, 'duration': 2.881}, {'end': 1839.523, 'text': "so first of all, let's try this delete request.", 'start': 1836.162, 'duration': 3.361}, {'end': 1850.866, 'text': 'so if i pass in delete and send that over, this note was deleted, and if we go back into mongodb, if i refresh,', 'start': 1839.523, 'duration': 11.343}, {'end': 1857.154, 'text': 'there is no longer a note in our database.', 'start': 1853.331, 'duration': 3.823}], 'summary': 'Testing delete request in postman successfully deletes note from database.', 'duration': 34.696, 'max_score': 1822.458, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj01822458.jpg'}, {'end': 1988.906, 'src': 'embed', 'start': 1950.623, 'weight': 1, 'content': [{'end': 1957.785, 'text': 'If you fail to supply a body or title, the put request will nullify those fields on the note in the database.', 'start': 1950.623, 'duration': 7.162}, {'end': 1963.386, 'text': "You could easily add some conditional logic to update the fields only if they're present in the request.", 'start': 1958.345, 'duration': 5.041}, {'end': 1965.487, 'text': 'I left that out just to keep it simple.', 'start': 1963.966, 'duration': 1.521}, {'end': 1967.009, 'text': "Well, that's it.", 'start': 1966.368, 'duration': 0.641}, {'end': 1972.293, 'text': 'You have a working Node API with each of the four major CRUD operations.', 'start': 1967.449, 'duration': 4.844}, {'end': 1978.738, 'text': 'The goal of this tutorial was to give you a degree of familiarity with Express, Node, and MongoDB.', 'start': 1973.093, 'duration': 5.645}, {'end': 1983.161, 'text': 'You can use your simple app as a launching pad for more complex projects.', 'start': 1979.278, 'duration': 3.883}, {'end': 1984.763, 'text': 'My name is Beau Carnes.', 'start': 1983.742, 'duration': 1.021}, {'end': 1988.906, 'text': "Don't forget to subscribe and remember, use your code for good.", 'start': 1985.523, 'duration': 3.383}], 'summary': 'Tutorial covers building node api with crud operations for familiarity with express, node, and mongodb, by beau carnes.', 'duration': 38.283, 'max_score': 1950.623, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj01950623.jpg'}], 'start': 1679.972, 'title': 'Crud operations in postman and node api', 'summary': 'Covers the implementation of crud operations in postman, including sending requests, receiving responses, and making changes to the database directly. it also demonstrates the implementation of crud operations in a node api with express and mongodb, emphasizing the imperfection in the code and the potential for further conditional logic to enhance it.', 'chapters': [{'end': 1797.088, 'start': 1679.972, 'title': 'Crud operations in postman', 'summary': 'Covers the implementation of create, read, update, and delete (crud) operations in postman, including sending requests, receiving responses, and making changes to the database directly.', 'duration': 117.116, 'highlights': ['The chapter covers the implementation of Create, Read, Update, and Delete (CRUD) operations in Postman, including sending requests, receiving responses, and making changes to the database directly.', "The process involves sending a 'get' request to retrieve a specific note from the database, using the note's ID as a parameter, which returns the corresponding note and its title.", "The delete route involves making changes to the 'get' code to create the delete code, specifying the use of remove instead of find one, and indicating the request type as 'delete' to remove an object from the database.", "The update route entails using the 'put' request, which acts as a hybrid between the read and create routes, involving finding the object and then updating it accordingly."]}, {'end': 1988.906, 'start': 1797.608, 'title': 'Crud operations with node, express, and mongodb', 'summary': 'Demonstrates the implementation of crud operations in a node api with express and mongodb, covering create, read, update, and delete functionalities, with an emphasis on the imperfection in the code and the potential for further conditional logic to enhance it.', 'duration': 191.298, 'highlights': ['The tutorial covers the implementation of CRUD operations in a Node API with Express and MongoDB.', 'The imperfection in the code is highlighted, specifically mentioning the nullification of fields on the note in the database if a body or title is not supplied during a put request.', "The potential for further conditional logic to update the fields only if they're present in the request is mentioned."]}], 'duration': 308.934, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/fsCjFHuMXj0/pics/fsCjFHuMXj01679972.jpg', 'highlights': ['The chapter covers the implementation of Create, Read, Update, and Delete (CRUD) operations in Postman, including sending requests, receiving responses, and making changes to the database directly.', 'The tutorial covers the implementation of CRUD operations in a Node API with Express and MongoDB.', 'The imperfection in the code is highlighted, specifically mentioning the nullification of fields on the note in the database if a body or title is not supplied during a put request.', "The process involves sending a 'get' request to retrieve a specific note from the database, using the note's ID as a parameter, which returns the corresponding note and its title."]}], 'highlights': ['The tutorial provides a step-by-step guide for building a note-taking app using MongoDB and Node.js, including creating a new note, retrieving notes by ID, and handling object IDs for MongoDB, resulting in improved data retrieval and management.', 'The chapter covers the implementation of Create, Read, Update, and Delete (CRUD) operations in Postman, including sending requests, receiving responses, and making changes to the database directly.', 'Building four CRUD routes - create, read, update, and delete - for a note-taking application in Node.', 'The chapter demonstrates setting up a Notable project using Node, running npm init, and following prompts to create the project, with version 1.1.', 'Creating a new MongoDB deployment in Mlab', 'The tutorial aims to build a simple API boilerplate for a note-taking app, akin to Google Keep, allowing all four CRUD actions on notes.', 'Emphasizing the use of Postman to test the API, allowing simple HTTP requests with custom bodies and parameters.', 'The tutorial covers the fundamental REST routes and basic database interaction for a note-taking app, emphasizing the need to understand REST APIs and CRUD operations.', 'The chapter covers the implementation of CRUD operations in a Node API with Express and MongoDB.', 'Installing node mon as a dev dependency is highly recommended, as it automatically restarts the server when files change.']}