title
Fastify Crash Course | Node.js Framework

description
Fastify is a "fast" Node.js framework. In this video, we will build a REST API with validation schemas and swagger documentation Code: https://github.com/bradtraversy/fastify-crash-course Website & Docs: https://www.fastify.io/ Article: Fastify vs. Express https://medium.com/@onufrienkos/express-vs-fastify-performance-4dd5d73e08e2 Latest Udemy Courses: https://traversymedia.com​ 💖 Support The Channel! http://www.patreon.com/traversymedia Timestamps: 0:00 - Intro 2:26 - Install & Setup 3:42 - Basic Server 5:30 - Create a Basic Route 6:33 - VSCode REST Client 7:50 - Data File 11:03 - Separate Routes File 13:30 - Options, Validation Schemas & Handlers 20:25 - Creating a Controller 22:37 - Fastify Swagger API Documentation 24:47 - Add Item POST 30:22 - Body Validation 31:59 - Remove Item DELETE 35:20 - Update Item PUT

detail
{'title': 'Fastify Crash Course | Node.js Framework', 'heatmap': [{'end': 550.943, 'start': 523.256, 'weight': 0.726}, {'end': 793.475, 'start': 713.073, 'weight': 0.751}, {'end': 954.813, 'start': 906.161, 'weight': 0.713}, {'end': 1124.54, 'start': 1087.811, 'weight': 0.784}, {'end': 1334.999, 'start': 1311.198, 'weight': 0.726}, {'end': 1481.155, 'start': 1429.623, 'weight': 1}], 'summary': 'This fastify crash course introduces fastify, highlighting its advantages such as a complete ecosystem of plugins and its 20% faster speed than express. it covers building a crud api, creating routes, handling data, setting up api validation, route refactoring, and implementing fastify swagger for documentation.', 'chapters': [{'end': 100.788, 'segs': [{'end': 37.91, 'src': 'embed', 'start': 7.338, 'weight': 1, 'content': [{'end': 9.841, 'text': 'hey guys, welcome to my fastify crash course.', 'start': 7.338, 'duration': 2.503}, {'end': 15.949, 'text': "so fastify is, as you can see on the website here, it's a fast and low overhead web framework for node.js.", 'start': 9.841, 'duration': 6.108}, {'end': 21.997, 'text': "so it's comparable to express and it's it's very similar in that it's very minimalistic.", 'start': 15.949, 'duration': 6.048}, {'end': 26.521, 'text': 'But there are some advantages that I really like about Fastify.', 'start': 22.518, 'duration': 4.003}, {'end': 30.744, 'text': 'One is the complete ecosystem of plugins that are offered.', 'start': 27.002, 'duration': 3.742}, {'end': 37.91, 'text': "So basically, if you want, you know, let's say JSON Web Tokens, there's a Fastify JWT plugin.", 'start': 31.125, 'duration': 6.785}], 'summary': 'Fastify is a fast and minimalistic web framework for node.js, with a rich ecosystem of plugins.', 'duration': 30.572, 'max_score': 7.338, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA7338.jpg'}, {'end': 109.756, 'src': 'embed', 'start': 75.944, 'weight': 0, 'content': [{'end': 77.485, 'text': 'This is actually from 2019, so it is a bit old,', 'start': 75.944, 'duration': 1.541}, {'end': 86.314, 'text': 'but He did some benchmarking and shows you the results of Express versus Fastify with different endpoints here.', 'start': 77.485, 'duration': 8.829}, {'end': 92.78, 'text': 'And the conclusion was that Fastify was around 20% faster than Express in almost every request.', 'start': 86.874, 'duration': 5.906}, {'end': 98.707, 'text': 'So that is another pro to using Fastify is the speed and efficiency of it.', 'start': 92.86, 'duration': 5.847}, {'end': 100.788, 'text': "So we're just going to kind of dive in.", 'start': 99.247, 'duration': 1.541}, {'end': 103.01, 'text': "We're going to build a CRUD API.", 'start': 100.868, 'duration': 2.142}, {'end': 109.756, 'text': "We're going to I'm going to show you the very basic way to create routes and fetch some data.", 'start': 103.391, 'duration': 6.365}], 'summary': 'Fastify was around 20% faster than express in almost every request.', 'duration': 33.812, 'max_score': 75.944, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA75944.jpg'}], 'start': 7.338, 'title': 'Fastify crash course', 'summary': 'Introduces fastify, highlighting its advantages such as a complete ecosystem of plugins and its speed. benchmarks show fastify to be around 20% faster than express.', 'chapters': [{'end': 100.788, 'start': 7.338, 'title': 'Fastify crash course', 'summary': 'Introduces fastify, highlighting its advantages such as a complete ecosystem of plugins and its speed, with benchmarks showing fastify to be around 20% faster than express.', 'duration': 93.45, 'highlights': ['Fastify is a fast and low overhead web framework for node.js, comparable to Express but with advantages such as a complete ecosystem of plugins, including MongoDB, Redis, and Swagger.', 'Fastify was benchmarked to be around 20% faster than Express in almost every request, making it a more efficient option for web development.', 'Fastify offers a minimalistic organization of plugins, providing a more organized approach compared to using Express with various modules.']}], 'duration': 93.45, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA7338.jpg', 'highlights': ['Fastify was benchmarked to be around 20% faster than Express in almost every request, making it a more efficient option for web development.', 'Fastify is a fast and low overhead web framework for node.js, comparable to Express but with advantages such as a complete ecosystem of plugins, including MongoDB, Redis, and Swagger.', 'Fastify offers a minimalistic organization of plugins, providing a more organized approach compared to using Express with various modules.']}, {'end': 341.107, 'segs': [{'end': 139.92, 'src': 'embed', 'start': 100.868, 'weight': 0, 'content': [{'end': 103.01, 'text': "We're going to build a CRUD API.", 'start': 100.868, 'duration': 2.142}, {'end': 109.756, 'text': "We're going to I'm going to show you the very basic way to create routes and fetch some data.", 'start': 103.391, 'duration': 6.365}, {'end': 115.401, 'text': "We're just going to use a file for data for now, and then we'll go ahead and build some controllers.", 'start': 109.776, 'duration': 5.625}, {'end': 122.607, 'text': "I'll show you how we can add different options for our routes, for different responses, and just show you some of the benefits of Fastify.", 'start': 115.461, 'duration': 7.146}, {'end': 127.331, 'text': "So I'm going to go ahead and open up VS Code and I just have an empty folder called Fastify API.", 'start': 122.727, 'duration': 4.604}, {'end': 136.897, 'text': "Now, I'm using an extension called Rest Client, and we're going to be using this to make requests to different endpoints of our API.", 'start': 127.831, 'duration': 9.066}, {'end': 139.92, 'text': 'Now, if you want to use Postman or something different, you can,', 'start': 136.977, 'duration': 2.943}], 'summary': 'Building a crud api using fastify, demonstrating route creation and data fetching.', 'duration': 39.052, 'max_score': 100.868, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA100868.jpg'}, {'end': 215.699, 'src': 'embed', 'start': 164.973, 'weight': 1, 'content': [{'end': 176.435, 'text': "And we also want a plugin we're going to be using called Fastify Swagger, which will give us a really nice open API documentation for for our API.", 'start': 164.973, 'duration': 11.462}, {'end': 181.737, 'text': "And then I'm also using a module called UUID to generate random IDs.", 'start': 176.795, 'duration': 4.942}, {'end': 183.417, 'text': "So we're going to install those.", 'start': 182.297, 'duration': 1.12}, {'end': 193.587, 'text': "and then, as far as dev dependencies, i'm just going to install nodemon, so npm, install dash, uppercase d, nodemon and that'll make it so you know,", 'start': 184.614, 'duration': 8.973}, {'end': 197.072, 'text': "it'll watch the server and we don't have to keep restarting it after every change.", 'start': 193.587, 'duration': 3.485}, {'end': 205.793, 'text': "And then in the scripts here I'm just going to add just a basic start script that will run node and then our main file,", 'start': 197.788, 'duration': 8.005}, {'end': 207.354, 'text': "which I'm going to call server JS.", 'start': 205.793, 'duration': 1.561}, {'end': 208.655, 'text': 'So just node server.', 'start': 207.394, 'duration': 1.261}, {'end': 213.998, 'text': "And then let's go ahead and create another one here that's going to run node mon.", 'start': 209.155, 'duration': 4.843}, {'end': 215.699, 'text': "And that's going to be our dev script.", 'start': 214.078, 'duration': 1.621}], 'summary': 'Using fastify swagger for api documentation, uuid for generating random ids, and nodemon for automatic server restart.', 'duration': 50.726, 'max_score': 164.973, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA164973.jpg'}, {'end': 294.849, 'src': 'embed', 'start': 242.664, 'weight': 5, 'content': [{'end': 245.945, 'text': "I'm going to keep it as fastify just because that's how it is in the docs.", 'start': 242.664, 'duration': 3.281}, {'end': 251.227, 'text': 'And then here we can add a set of parentheses and then an object with some options.', 'start': 246.646, 'duration': 4.581}, {'end': 257.23, 'text': "And we're just going to set logger to true, which will just give us some extra information down in the console.", 'start': 251.267, 'duration': 5.963}, {'end': 259.37, 'text': 'now to start up our server.', 'start': 257.93, 'duration': 1.44}, {'end': 265.777, 'text': 'we can call fastify.listen, similar to you know, app.listen with express.', 'start': 259.37, 'duration': 6.407}, {'end': 266.918, 'text': 'it does return a promise.', 'start': 265.777, 'duration': 1.141}, {'end': 282.592, 'text': "so we are going to create a function here called start and make sure we make this asynchronous and then in here we'll have a try catch and inside the try let's await on fastify,", 'start': 266.918, 'duration': 15.674}, {'end': 286.762, 'text': "dot, listen and then a port which I'm going to put.", 'start': 282.592, 'duration': 4.17}, {'end': 288.644, 'text': "I'm going to create a variable up here.", 'start': 286.762, 'duration': 1.882}, {'end': 294.849, 'text': "So call this port and I'm going to use port 5000, but feel free to use whatever you'd like.", 'start': 289.685, 'duration': 5.164}], 'summary': 'Using fastify, set logger to true, start server on port 5000.', 'duration': 52.185, 'max_score': 242.664, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA242664.jpg'}], 'start': 100.868, 'title': 'Building and running fastify server', 'summary': 'Covers building a crud api using fastify, creating routes, using rest client for making requests, installing fastify, fastify swagger, and uuid modules, and using nodemon as a dev dependency. it also provides a guide on setting up and running a fastify server with nodemon, adding start scripts, creating a server file, and starting the server on a specific port, with the logger option providing extra information in the console.', 'chapters': [{'end': 193.587, 'start': 100.868, 'title': 'Building crud api with fastify', 'summary': 'Covers building a crud api using fastify, including creating routes, using rest client for making requests, installing fastify, fastify swagger, and uuid modules, and using nodemon as a dev dependency.', 'duration': 92.719, 'highlights': ['Building a CRUD API using Fastify Demonstrating the basic way of creating routes and fetching data to build a CRUD API.', 'Using Rest Client for making requests Utilizing the Rest Client extension to make requests to different endpoints of the API without leaving Visual Studio Code.', 'Installing Fastify, Fastify Swagger, and UUID modules Installing Fastify, Fastify Swagger for open API documentation, and UUID for generating random IDs as essential modules for building the API.', 'Using nodemon as a dev dependency Installing nodemon as a dev dependency to automatically restart the server upon file changes, enhancing the development experience.']}, {'end': 341.107, 'start': 193.587, 'title': 'Setting up and running fastify server with nodemon', 'summary': 'Provides a guide on setting up and running a fastify server with nodemon, including adding start scripts, creating a server file, and starting the server on a specific port, with the logger option providing extra information in the console.', 'duration': 147.52, 'highlights': ['Setting up start scripts to run node and nodemon The chapter demonstrates setting up start scripts for running node and nodemon with basic start script for running node and dev script for running nodemon.', 'Creating a server file and configuring Fastify It explains the process of creating a server file, bringing in Fastify, and configuring it with options, such as setting logger to true for extra information in the console.', 'Starting the server on a specific port The chapter covers starting the server on a specific port, using async function with try catch block, and setting the port to 5000.']}], 'duration': 240.239, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA100868.jpg', 'highlights': ['Building a CRUD API using Fastify Demonstrating the basic way of creating routes and fetching data to build a CRUD API.', 'Installing Fastify, Fastify Swagger, and UUID modules Installing Fastify, Fastify Swagger for open API documentation, and UUID for generating random IDs as essential modules for building the API.', 'Using Rest Client for making requests Utilizing the Rest Client extension to make requests to different endpoints of the API without leaving Visual Studio Code.', 'Using nodemon as a dev dependency Installing nodemon as a dev dependency to automatically restart the server upon file changes, enhancing the development experience.', 'Setting up start scripts to run node and nodemon The chapter demonstrates setting up start scripts for running node and nodemon with basic start script for running node and dev script for running nodemon.', 'Creating a server file and configuring Fastify It explains the process of creating a server file, bringing in Fastify, and configuring it with options, such as setting logger to true for extra information in the console.', 'Starting the server on a specific port The chapter covers starting the server on a specific port, using async function with try catch block, and setting the port to 5000.']}, {'end': 654.377, 'segs': [{'end': 388.974, 'src': 'embed', 'start': 341.147, 'weight': 0, 'content': [{'end': 343.968, 'text': 'We can do dot route and we can pass in some options.', 'start': 341.147, 'duration': 2.821}, {'end': 346.269, 'text': 'But the shorthand is to just use the method.', 'start': 344.008, 'duration': 2.261}, {'end': 351.15, 'text': "So let's say get slash items and then we have a handler.", 'start': 346.709, 'duration': 4.441}, {'end': 353.571, 'text': 'So this is, again, very similar to express.', 'start': 351.21, 'duration': 2.361}, {'end': 358.073, 'text': 'So this is going to be request and then reply.', 'start': 354.111, 'duration': 3.962}, {'end': 362.335, 'text': 'So reply is kind of the this is the convention for this.', 'start': 359.053, 'duration': 3.282}, {'end': 366.377, 'text': 'But of course, you could call it, you know, res or response.', 'start': 363.175, 'duration': 3.202}, {'end': 376.501, 'text': "And then in here, all I'm going to do for now is take that reply object and I'm going to call dot, send and I'll pass in just an object with,", 'start': 367.137, 'duration': 9.364}, {'end': 379.643, 'text': "let's say, I don't know, test and hello.", 'start': 376.501, 'duration': 3.142}, {'end': 383.253, 'text': 'OK, so creating a route is as simple as that.', 'start': 380.532, 'duration': 2.721}, {'end': 388.974, 'text': "Now, to test this route, I'm going to be using my rest client that I have installed for VSCode.", 'start': 383.773, 'duration': 5.201}], 'summary': 'Creating a route in express-like framework with request and reply objects.', 'duration': 47.827, 'max_score': 341.147, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA341147.jpg'}, {'end': 487.88, 'src': 'embed', 'start': 459.303, 'weight': 2, 'content': [{'end': 463.487, 'text': "We'll do it in this file, but we're going to move this to a separate routes file in a few minutes.", 'start': 459.303, 'duration': 4.184}, {'end': 469.013, 'text': "As far as data, I'm just going to use a file, a JavaScript file.", 'start': 464.408, 'duration': 4.605}, {'end': 473.035, 'text': "So let's create to create items.js.", 'start': 469.033, 'duration': 4.002}, {'end': 477.276, 'text': 'okay, capital i items.js, and this is basically going to be our data.', 'start': 473.035, 'duration': 4.241}, {'end': 479.597, 'text': "we're not using a database in this case,", 'start': 477.276, 'duration': 2.321}, {'end': 487.88, 'text': 'although i may add another video where we can use either postgres or mongo or something like that with the fastify plugin,', 'start': 479.597, 'duration': 8.283}], 'summary': 'Moving data to separate routes file, using javascript file for data, considering adding database integration.', 'duration': 28.577, 'max_score': 459.303, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA459303.jpg'}, {'end': 566.22, 'src': 'heatmap', 'start': 523.256, 'weight': 3, 'content': [{'end': 536.942, 'text': "so i'm going to bring this into this file by just saying const items and set that to require and we want to require dot slash items, okay,", 'start': 523.256, 'duration': 13.686}, {'end': 539.804, 'text': 'and then down here i want to return those items.', 'start': 536.942, 'duration': 2.862}, {'end': 544.146, 'text': "so let's get rid of this object and just return items or send items.", 'start': 539.804, 'duration': 4.342}, {'end': 550.943, 'text': "so now, if i go back to my test, http, we're going to go ahead and get those items back All right.", 'start': 544.146, 'duration': 6.797}, {'end': 557.871, 'text': "Now let's create one more route in here and then we'll move it to a separate separate file.", 'start': 551.784, 'duration': 6.087}, {'end': 560.453, 'text': 'I want to create a route that just gets a single item.', 'start': 558.031, 'duration': 2.422}, {'end': 566.22, 'text': 'So what we can do is grab this paste that in there.', 'start': 561.234, 'duration': 4.986}], 'summary': 'Code extracts items from file and creates routes for getting items.', 'duration': 26.416, 'max_score': 523.256, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA523256.jpg'}], 'start': 341.147, 'title': 'Creating routes and handling data in express.js and fastify', 'summary': "Discusses creating routes in express.js using the 'get' method and testing the route with a rest client resulting in a 200 response, as well as the process of handling data and using fastify plugin to get items and a single item.", 'chapters': [{'end': 437.493, 'start': 341.147, 'title': 'Creating routes in express.js', 'summary': "Discusses creating routes in express.js by using the 'get' method to define a route handler that responds to a specific endpoint. it also demonstrates testing the route using a rest client and receiving a 200 response.", 'duration': 96.346, 'highlights': ["The chapter discusses creating routes in Express.js by using the 'get' method to define a route handler that responds to a specific endpoint.", 'It demonstrates testing the route using a REST client and receiving a 200 response.', "The shorthand method for creating routes in Express.js is to use the 'get' method, which simplifies the process.", 'A demonstration of using a REST client to test the created route and receiving a 200 response.']}, {'end': 654.377, 'start': 438.013, 'title': 'Fastify plugin for handling data', 'summary': 'Explains the process of creating a separate routes file, using a javascript file as data without a database, and implementing a route to get a single item using fastify plugin, with a demonstration of getting items and a single item.', 'duration': 216.364, 'highlights': ['The process of creating a separate routes file Demonstrates the intention to move the current code to a separate routes file for better organization and maintainability.', 'Using a JavaScript file as data without a database Explains the approach of using a JavaScript file as data instead of a database, providing a clear strategy for data management.', "Implementing a route to get a single item using Fastify plugin Illustrates the implementation of a route to retrieve a single item using the Fastify plugin, enhancing the understanding of the plugin's capabilities.", 'Demonstration of getting items and a single item Shows a practical demonstration of getting a list of items and a single item, providing a hands-on understanding of the functionality.']}], 'duration': 313.23, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA341147.jpg', 'highlights': ["The chapter discusses creating routes in Express.js by using the 'get' method to define a route handler that responds to a specific endpoint.", 'Demonstrates testing the route using a REST client and receiving a 200 response.', 'Demonstrates the intention to move the current code to a separate routes file for better organization and maintainability.', "Illustrates the implementation of a route to retrieve a single item using the Fastify plugin, enhancing the understanding of the plugin's capabilities."]}, {'end': 979.014, 'segs': [{'end': 793.475, 'src': 'heatmap', 'start': 654.477, 'weight': 3, 'content': [{'end': 657.779, 'text': 'If I go to then we can see the second.', 'start': 654.477, 'duration': 3.302}, {'end': 659.8, 'text': "But I'll just keep that at one.", 'start': 658.499, 'duration': 1.301}, {'end': 662.959, 'text': "Okay, so we know that's working.", 'start': 661.698, 'duration': 1.261}, {'end': 668.486, 'text': 'Now, as you can imagine, this can get quite messy if we leave this in server.js.', 'start': 663.48, 'duration': 5.006}, {'end': 672.33, 'text': "So what we'll do is create a separate folder here called routes.", 'start': 668.967, 'duration': 3.363}, {'end': 676.916, 'text': "And inside routes, we'll create items.js.", 'start': 673.312, 'duration': 3.604}, {'end': 679.038, 'text': 'So these will be all of our items routes.', 'start': 677.296, 'duration': 1.742}, {'end': 688.049, 'text': 'Now, with Fastify and using a separate file for routes, we can actually register our routes as as a plug in.', 'start': 679.699, 'duration': 8.35}, {'end': 691.253, 'text': 'So the way that we can do that is by using a function.', 'start': 688.59, 'duration': 2.663}, {'end': 695.958, 'text': "So we're going to say function and this is going to take in.", 'start': 692.074, 'duration': 3.884}, {'end': 698.381, 'text': "Actually, let's call this item routes.", 'start': 695.978, 'duration': 2.403}, {'end': 706.448, 'text': 'And this is going to take in three things takes in fastify options and then a callback called done.', 'start': 699.363, 'duration': 7.085}, {'end': 712.593, 'text': 'And you just want to make sure at the end of all this you call done and then you can put your routes in here.', 'start': 707.249, 'duration': 5.344}, {'end': 715.555, 'text': "So we'll go ahead and grab the two routes we created.", 'start': 713.073, 'duration': 2.482}, {'end': 721.199, 'text': "So take these and we'll cut those out and we'll put those right in here.", 'start': 716.636, 'duration': 4.563}, {'end': 725.648, 'text': 'And we also want the data.', 'start': 723.047, 'duration': 2.601}, {'end': 727.529, 'text': "So this doesn't need to be here anymore.", 'start': 725.728, 'duration': 1.801}, {'end': 728.93, 'text': "We'll take that.", 'start': 728.169, 'duration': 0.761}, {'end': 731.651, 'text': "We'll put that in our routes file above the function.", 'start': 728.97, 'duration': 2.681}, {'end': 737.053, 'text': "And since we're we're down a level, it's going to be dot dot slash items.", 'start': 732.631, 'duration': 4.422}, {'end': 742.355, 'text': 'OK And then we just want to make sure that we export item routes.', 'start': 738.013, 'duration': 4.342}, {'end': 745.637, 'text': 'So down here at the bottom module dot exports.', 'start': 742.695, 'duration': 2.942}, {'end': 748.88, 'text': 'item routes.', 'start': 747.179, 'duration': 1.701}, {'end': 758.547, 'text': 'OK Now, since we wrap this in this function like this, we should be able to just register just like we would when we use a plug in.', 'start': 750.381, 'duration': 8.166}, {'end': 763.531, 'text': 'We register it with fastify dot register.', 'start': 758.587, 'duration': 4.944}, {'end': 769.008, 'text': 'And then in here we want to require Dot.', 'start': 764.511, 'duration': 4.497}, {'end': 774.07, 'text': 'What is it? Dot slash routes slash items.', 'start': 769.188, 'duration': 4.882}, {'end': 783.473, 'text': 'OK, so just doing that, if we save and we go back to our HTTP file and I send, it should still work the same way so we can get all of them.', 'start': 774.09, 'duration': 9.383}, {'end': 784.733, 'text': 'We can get a single item.', 'start': 783.513, 'duration': 1.22}, {'end': 793.475, 'text': 'Now, another thing that we can do is validation with certain schemas for what we want to return from these routes.', 'start': 785.922, 'duration': 7.553}], 'summary': 'Creating separate routes folder for fastify, registering items routes as a plug-in, and implementing validation with schemas.', 'duration': 77.174, 'max_score': 654.477, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA654477.jpg'}, {'end': 905.375, 'src': 'embed', 'start': 822.961, 'weight': 0, 'content': [{'end': 829.722, 'text': 'So basically we can format what is to be returned or responded with from each of these routes.', 'start': 822.961, 'duration': 6.761}, {'end': 832.243, 'text': "So I'm going to create an object here.", 'start': 830.343, 'duration': 1.9}, {'end': 834.684, 'text': "I'm going to call it get items.", 'start': 832.263, 'duration': 2.421}, {'end': 837.624, 'text': 'So plural ops for options.', 'start': 834.864, 'duration': 2.76}, {'end': 841.585, 'text': "I mean, you can call it what you want, but we're going to call it that.", 'start': 838.184, 'duration': 3.401}, {'end': 844.926, 'text': 'And then in here we can add a schema.', 'start': 841.705, 'duration': 3.221}, {'end': 855.999, 'text': 'So a schema object and we can actually format for each response, which in this case is going to be a 200 response, because reply dot send.', 'start': 846.226, 'duration': 9.773}, {'end': 858.32, 'text': "as long as nothing goes wrong, that's going to be a 200..", 'start': 855.999, 'duration': 2.321}, {'end': 864.744, 'text': "So I'm going to say for a 200 response for this particular route.", 'start': 858.32, 'duration': 6.424}, {'end': 870.987, 'text': "we're going to want this to be in an array in this case, because we're getting multiple items.", 'start': 864.744, 'duration': 6.243}, {'end': 882.201, 'text': "So let's say type and set that to array and then for the, We want to say for the items,", 'start': 871.067, 'duration': 11.134}, {'end': 892.247, 'text': 'we want that to be a type of an object and then we can specify the properties that are to be returned.', 'start': 882.201, 'duration': 10.046}, {'end': 895.129, 'text': 'So in our case, we have what an ID and a name.', 'start': 892.347, 'duration': 2.782}, {'end': 897.55, 'text': "So let's say ID and we can actually type this.", 'start': 895.169, 'duration': 2.381}, {'end': 903.894, 'text': "So I'm going to say type string and then we'll copy that down.", 'start': 898.631, 'duration': 5.263}, {'end': 905.375, 'text': 'And we also have a name.', 'start': 903.914, 'duration': 1.461}], 'summary': 'Creating a schema for returning items with id and name in an array for 200 response.', 'duration': 82.414, 'max_score': 822.961, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA822961.jpg'}, {'end': 954.813, 'src': 'heatmap', 'start': 906.161, 'weight': 0.713, 'content': [{'end': 908.022, 'text': 'which is also going to be a string.', 'start': 906.161, 'duration': 1.861}, {'end': 909.922, 'text': 'So say name.', 'start': 908.762, 'duration': 1.16}, {'end': 914.823, 'text': "OK So we're kind of just formatting how the schema is for the response for this.", 'start': 910.702, 'duration': 4.121}, {'end': 917.484, 'text': 'Now this get items ops.', 'start': 915.504, 'duration': 1.98}, {'end': 921.705, 'text': 'All we have to do to use this in one of our routes is put it as a second argument.', 'start': 917.644, 'duration': 4.061}, {'end': 924.106, 'text': 'So this is the route to get all items.', 'start': 922.105, 'duration': 2.001}, {'end': 926.967, 'text': "I'm going to paste that in right here as a second argument.", 'start': 924.126, 'duration': 2.841}, {'end': 930.748, 'text': "So it's the endpoint the options and then the handler.", 'start': 927.387, 'duration': 3.361}, {'end': 934.891, 'text': "So I'm going to save that and this should still work just the same.", 'start': 931.548, 'duration': 3.343}, {'end': 937.753, 'text': 'It gets, you know, fetches all three items.', 'start': 934.931, 'duration': 2.822}, {'end': 941.777, 'text': 'But if I go up here, so this is our schema right here.', 'start': 938.374, 'duration': 3.403}, {'end': 944.139, 'text': "If I were to comment out, let's say the ID.", 'start': 941.817, 'duration': 2.322}, {'end': 949.79, 'text': "And I make that request again notice how I'm not it's not giving me the I.D.", 'start': 945.447, 'duration': 4.343}, {'end': 954.813, 'text': "even though I returned it in my in my code it's not going to allow that I.D.", 'start': 950.05, 'duration': 4.763}], 'summary': 'Formatting response schema for get all items route, testing and observing behavior', 'duration': 48.652, 'max_score': 906.161, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA906161.jpg'}], 'start': 654.477, 'title': 'Fastify route setup and api validation', 'summary': 'Covers setting up fastify routes, creating items routes, and registering routes as a plugin, along with creating api routes, implementing schema validation, configuring response schemas, and enforcing data types.', 'chapters': [{'end': 731.651, 'start': 654.477, 'title': 'Setting up fastify routes', 'summary': 'Discusses the process of setting up fastify routes by creating a separate folder called routes, creating an items.js file for the items routes, and registering the routes as a plugin with fastify, showcasing the function and callback process.', 'duration': 77.174, 'highlights': ['Creating a separate folder called routes to organize the routes', 'Registering the routes as a plugin with Fastify using a function and callback process', 'Moving the data to the routes file above the function']}, {'end': 979.014, 'start': 732.631, 'title': 'Fastify api routes and schema validation', 'summary': 'Demonstrates how to create api routes and implement schema validation for returning multiple items, with details on configuring response schemas and enforcing data types.', 'duration': 246.383, 'highlights': ['Demonstration of creating API routes and schema validation for returning multiple items The transcript provides step-by-step guidance on how to create API routes and implement schema validation for returning multiple items.', 'Configuration of response schemas for API routes The chapter elaborates on the process of configuring response schemas for API routes, including specifying properties such as ID and name with type definitions.', 'Enforcement of data types in the schema validation process It explains the enforcement of data types in the schema validation process, demonstrating how changing the type from string to integer affects the returned data.']}], 'duration': 324.537, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA654477.jpg', 'highlights': ['Demonstration of creating API routes and schema validation for returning multiple items', 'Configuration of response schemas for API routes', 'Enforcement of data types in the schema validation process', 'Registering the routes as a plugin with Fastify using a function and callback process', 'Moving the data to the routes file above the function', 'Creating a separate folder called routes to organize the routes']}, {'end': 1360.202, 'segs': [{'end': 1044.964, 'src': 'embed', 'start': 1008.477, 'weight': 1, 'content': [{'end': 1010.078, 'text': "And let's say for this.", 'start': 1008.477, 'duration': 1.601}, {'end': 1013.1, 'text': 'So we want our schema.', 'start': 1011.839, 'duration': 1.261}, {'end': 1016.423, 'text': 'So schema and then the response.', 'start': 1014.401, 'duration': 2.022}, {'end': 1029.779, 'text': 'We want to say for response 200, then we want not an array like we did here, but just the object so I can actually copy this.', 'start': 1019.346, 'duration': 10.433}, {'end': 1036.74, 'text': 'wait, yeah, items so type object.', 'start': 1033.378, 'duration': 3.362}, {'end': 1038.881, 'text': 'so the, the type and the properties.', 'start': 1036.74, 'duration': 2.141}, {'end': 1044.964, 'text': 'if you have an array, then you have an additional items, because then you need to say well, what is in that array?', 'start': 1038.881, 'duration': 6.083}], 'summary': 'Define schema for response 200 as an object, not an array.', 'duration': 36.487, 'max_score': 1008.477, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA1008477.jpg'}, {'end': 1124.54, 'src': 'heatmap', 'start': 1087.811, 'weight': 0.784, 'content': [{'end': 1097.256, 'text': "So what we can do is create up here, let's say item schema and let's say cons uppercase I item.", 'start': 1087.811, 'duration': 9.445}, {'end': 1099.437, 'text': "And we're going to set that equal to.", 'start': 1097.496, 'duration': 1.941}, {'end': 1105.366, 'text': 'this type object and then our properties.', 'start': 1100.743, 'duration': 4.623}, {'end': 1108.467, 'text': "it'll be an object with those in there.", 'start': 1105.366, 'duration': 3.101}, {'end': 1117.933, 'text': 'so now, instead of repeating ourselves this type array items, we can just replace this with item.', 'start': 1108.467, 'duration': 9.466}, {'end': 1124.54, 'text': 'and then down here, where we have the type, type and properties, we can just replace this with item.', 'start': 1117.933, 'duration': 6.607}], 'summary': 'Creating item schema with object properties to avoid repetition.', 'duration': 36.729, 'max_score': 1087.811, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA1087811.jpg'}, {'end': 1171.518, 'src': 'embed', 'start': 1144.701, 'weight': 3, 'content': [{'end': 1150.224, 'text': 'I want to clean this up a little more and create controller functions.', 'start': 1144.701, 'duration': 5.523}, {'end': 1156.468, 'text': 'So basically, with these options, in addition to the schema, we can also add the handler here.', 'start': 1150.745, 'duration': 5.723}, {'end': 1158.389, 'text': 'Right now, the handler is down here.', 'start': 1156.548, 'duration': 1.841}, {'end': 1160.05, 'text': "Right It's this function.", 'start': 1158.909, 'duration': 1.141}, {'end': 1163.052, 'text': 'So what we can do is just grab.', 'start': 1160.59, 'duration': 2.462}, {'end': 1171.518, 'text': "We want to keep that last parenthesis, but I'm going to grab this and just cut it so that all we have in here is the endpoint and the options.", 'start': 1163.592, 'duration': 7.926}], 'summary': 'Propose cleaning up and adding controller functions to the code.', 'duration': 26.817, 'max_score': 1144.701, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA1144701.jpg'}, {'end': 1258.331, 'src': 'embed', 'start': 1223.548, 'weight': 0, 'content': [{'end': 1223.828, 'text': 'All right.', 'start': 1223.548, 'duration': 0.28}, {'end': 1226.711, 'text': "So we're just cleaning this up a bit before we add more routes.", 'start': 1223.868, 'duration': 2.843}, {'end': 1232.296, 'text': 'And like I said, the final thing I want to do to kind of clean this up is create controller methods.', 'start': 1227.452, 'duration': 4.844}, {'end': 1236.42, 'text': "So I'm actually going to create a new folder here called Controllers.", 'start': 1232.817, 'duration': 3.603}, {'end': 1244.1, 'text': "And in here, we'll create items.js or you can call it item controller, whatever you like.", 'start': 1237.794, 'duration': 6.306}, {'end': 1250.205, 'text': "So for this, this is where we're actually going to need our data now so we can grab it from here.", 'start': 1245.1, 'duration': 5.105}, {'end': 1258.331, 'text': "We can cut it from the actual route file, put it in here, and then let's create our first function, which is going to be get items.", 'start': 1250.265, 'duration': 8.066}], 'summary': 'Cleaning up code by creating controller methods and moving data to new folder.', 'duration': 34.783, 'max_score': 1223.548, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA1223548.jpg'}, {'end': 1341.266, 'src': 'heatmap', 'start': 1311.198, 'weight': 0.726, 'content': [{'end': 1314.301, 'text': 'And then we can go into our routes and we can bring those in.', 'start': 1311.198, 'duration': 3.103}, {'end': 1316.203, 'text': "So let's say const.", 'start': 1314.321, 'duration': 1.882}, {'end': 1322.45, 'text': "We want to bring in get items and get item and that's going to be from.", 'start': 1316.804, 'duration': 5.646}, {'end': 1332.737, 'text': 'Where are we dot dot slash controllers? Slash items and then we can just simply replace this function here.', 'start': 1324.948, 'duration': 7.789}, {'end': 1334.999, 'text': 'So this is to get all items.', 'start': 1333.137, 'duration': 1.862}, {'end': 1341.266, 'text': 'So we want to replace that with get items From our controller and then this one here, this function.', 'start': 1334.999, 'duration': 6.267}], 'summary': 'Bringing in routes to get all items and replace functions.', 'duration': 30.068, 'max_score': 1311.198, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA1311198.jpg'}, {'end': 1360.202, 'src': 'embed', 'start': 1334.999, 'weight': 2, 'content': [{'end': 1341.266, 'text': 'So we want to replace that with get items From our controller and then this one here, this function.', 'start': 1334.999, 'duration': 6.267}, {'end': 1345.51, 'text': "We're gonna replace that with get item for the single item.", 'start': 1341.266, 'duration': 4.244}, {'end': 1350.159, 'text': 'So now this is Oh, this is way cleaner than it was before.', 'start': 1345.83, 'duration': 4.329}, {'end': 1356.033, 'text': "And let's just test it out so we can get all of our items and we can get a single item.", 'start': 1350.961, 'duration': 5.072}, {'end': 1360.202, 'text': 'Okay, so now we have basically the structure of everything.', 'start': 1357.301, 'duration': 2.901}], 'summary': 'Replacing functions improved code structure and functionality.', 'duration': 25.203, 'max_score': 1334.999, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA1334999.jpg'}], 'start': 979.354, 'title': 'Fastify route validation and api route refactoring', 'summary': "Discusses fastify's route validation and schema creation, emphasizing the need for route options and response schemas. additionally, it demonstrates refactoring api routes and implementing controller functions to handle requests, resulting in cleaner and more efficient code.", 'chapters': [{'end': 1044.964, 'start': 979.354, 'title': 'Fastify route validation', 'summary': 'Discusses the feature of fastify for route validation and schema creation, emphasizing the need for creating options for routes and specifying response schemas for different data types and structures.', 'duration': 65.61, 'highlights': ['The chapter emphasizes the need for creating options for all routes, indicating a focus on ensuring comprehensive route coverage and functionality.', 'The speaker discusses the need to specify response schemas for different data types and structures, exemplifying the difference in response handling for objects versus arrays.']}, {'end': 1360.202, 'start': 1044.964, 'title': 'Refactoring api routes and implementing controller functions', 'summary': 'Demonstrates the refactoring of api routes by creating a more organized structure and implementing controller functions to handle get all items and get single item requests, resulting in cleaner and more efficient code.', 'duration': 315.238, 'highlights': ['Implementing controller functions for get all items and get single item requests The speaker creates controller methods for get all items and get single item requests, resulting in a more organized and modular code structure.', 'Refactoring API routes by moving handler functions to options The speaker refactors API routes by moving the handler functions from the main body to the options object, resulting in a cleaner and more streamlined code.', 'Creating a new folder for Controllers and organizing code A new folder called Controllers is created to house the controller functions, leading to a more organized codebase.']}], 'duration': 380.848, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA979354.jpg', 'highlights': ['The chapter emphasizes the need for creating options for all routes, ensuring comprehensive route coverage and functionality.', 'The speaker discusses the need to specify response schemas for different data types and structures, exemplifying the difference in response handling for objects versus arrays.', 'Implementing controller functions for get all items and get single item requests results in a more organized and modular code structure.', 'Refactoring API routes by moving handler functions to options leads to a cleaner and more streamlined code.', 'Creating a new folder for Controllers and organizing code results in a more organized codebase.']}, {'end': 2382.591, 'segs': [{'end': 1410.125, 'src': 'embed', 'start': 1382.874, 'weight': 2, 'content': [{'end': 1386.358, 'text': "Whenever you install a plugin, you're going to register it, much like we did our routes.", 'start': 1382.874, 'duration': 3.484}, {'end': 1392.925, 'text': "So let's say Fastify register and we want to then pass in require.", 'start': 1387.019, 'duration': 5.906}, {'end': 1402.439, 'text': 'We want to require fastify swagger and we want to add on to this a second argument of options.', 'start': 1395.673, 'duration': 6.766}, {'end': 1410.125, 'text': "And the first thing we want is expose route, which we're going to set to true, which will enable the documentation route.", 'start': 1403.219, 'duration': 6.906}], 'summary': 'When installing a plugin in fastify, you register it and can pass options. for example, setting expose route to true enables the documentation route.', 'duration': 27.251, 'max_score': 1382.874, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA1382874.jpg'}, {'end': 1527.031, 'src': 'heatmap', 'start': 1429.623, 'weight': 1, 'content': [{'end': 1432.146, 'text': "And if you look at the docs, you'll see all the different options.", 'start': 1429.623, 'duration': 2.523}, {'end': 1434.549, 'text': "But we're just going to say Fastify API.", 'start': 1432.647, 'duration': 1.902}, {'end': 1441.992, 'text': 'OK so we registered fastify swagger and we added some of these options and it should just work.', 'start': 1436.71, 'duration': 5.282}, {'end': 1449.395, 'text': 'So if we go to the browser now and we go to HTTP local host port 5000 slash docs.', 'start': 1442.052, 'duration': 7.343}, {'end': 1458.596, 'text': "You're going to see your swagger documentation, which is really nice.", 'start': 1454.534, 'duration': 4.062}, {'end': 1461.017, 'text': "It's nicely laid out and you can see our two routes.", 'start': 1458.636, 'duration': 2.381}, {'end': 1463.458, 'text': 'You can even try it out.', 'start': 1461.957, 'duration': 1.501}, {'end': 1472.141, 'text': 'So if we say try it out and execute, it gives us back the request URL, the code, the body, that response headers.', 'start': 1463.538, 'duration': 8.603}, {'end': 1473.541, 'text': 'So really, really cool.', 'start': 1472.261, 'duration': 1.28}, {'end': 1476.903, 'text': 'And each route that we add will just automatically.', 'start': 1473.962, 'duration': 2.941}, {'end': 1481.155, 'text': 'will automatically be added to this documentation here.', 'start': 1477.81, 'duration': 3.345}, {'end': 1481.916, 'text': 'All right.', 'start': 1481.716, 'duration': 0.2}, {'end': 1485.462, 'text': "So let's continue on with our API.", 'start': 1481.956, 'duration': 3.506}, {'end': 1487.064, 'text': 'So we have two routes right now.', 'start': 1485.542, 'duration': 1.522}, {'end': 1491.036, 'text': 'Right We have get all items, get single items.', 'start': 1488.413, 'duration': 2.623}, {'end': 1495.16, 'text': "So let's go ahead and do add item.", 'start': 1491.556, 'duration': 3.604}, {'end': 1502.868, 'text': "So we're going to say fastify dot post because this is going to be a post request to slash items.", 'start': 1495.701, 'duration': 7.167}, {'end': 1504.93, 'text': "And then we're going to have post.", 'start': 1503.449, 'duration': 1.481}, {'end': 1508.474, 'text': "Let's say post item.", 'start': 1506.032, 'duration': 2.442}, {'end': 1510.837, 'text': 'Yeah Post item ops.', 'start': 1509.415, 'duration': 1.422}, {'end': 1514.185, 'text': "which doesn't exist yet.", 'start': 1512.964, 'duration': 1.221}, {'end': 1518.927, 'text': "So we're going to go up here and add the options for that.", 'start': 1514.305, 'duration': 4.622}, {'end': 1521.088, 'text': "So I'm going to copy.", 'start': 1518.947, 'duration': 2.141}, {'end': 1522.389, 'text': "Let's see.", 'start': 1521.868, 'duration': 0.521}, {'end': 1527.031, 'text': "We'll just copy this here and paste that in.", 'start': 1522.429, 'duration': 4.602}], 'summary': 'Using fastify api, added routes, and generated swagger documentation with try-it feature.', 'duration': 90.321, 'max_score': 1429.623, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA1429623.jpg'}, {'end': 1639.024, 'src': 'embed', 'start': 1609.789, 'weight': 4, 'content': [{'end': 1617.975, 'text': "So I'm going to actually just structure and take the name from request body that will give us whatever name is sent.", 'start': 1609.789, 'duration': 8.186}, {'end': 1623.118, 'text': "And then let's construct the item which consists of an ID.", 'start': 1618.575, 'duration': 4.543}, {'end': 1629.182, 'text': "Now for the ID I'm going to use the you ID module that that I installed earlier.", 'start': 1623.599, 'duration': 5.583}, {'end': 1635.687, 'text': "So up here let's say const and we're going to take say require.", 'start': 1629.743, 'duration': 5.944}, {'end': 1639.024, 'text': "And it's called UUID.", 'start': 1637.696, 'duration': 1.328}], 'summary': 'The transcript discusses structuring and taking the name from the request body and constructing an item with an id using the uuid module.', 'duration': 29.235, 'max_score': 1609.789, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA1609789.jpg'}, {'end': 2057.389, 'src': 'embed', 'start': 2019.793, 'weight': 5, 'content': [{'end': 2020.053, 'text': 'All right.', 'start': 2019.793, 'duration': 0.26}, {'end': 2024.098, 'text': "Now, as far as deleting it, I mean, we're just we're just going to use filter.", 'start': 2020.153, 'duration': 3.945}, {'end': 2028.583, 'text': 'So first of all, we need to get the ID, which is on the request dot params.', 'start': 2024.558, 'duration': 4.025}, {'end': 2034.149, 'text': "Right So let's say const will destructure the ID from request dot params.", 'start': 2028.643, 'duration': 5.506}, {'end': 2035.811, 'text': 'So we have the ID.', 'start': 2034.81, 'duration': 1.001}, {'end': 2038.454, 'text': "Now I'm going to just set.", 'start': 2037.052, 'duration': 1.402}, {'end': 2041.797, 'text': 'items, which is basically our state.', 'start': 2039.555, 'duration': 2.242}, {'end': 2057.389, 'text': "we're going to set it to items dot filter and then we're going to pass in our arrow function and say for each item we want to filter where item dot ID is not equal to the ID from the params.", 'start': 2041.797, 'duration': 15.592}], 'summary': 'Using filter method to delete item by id from state.', 'duration': 37.596, 'max_score': 2019.793, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA2019793.jpg'}, {'end': 2348.668, 'src': 'embed', 'start': 2321.692, 'weight': 0, 'content': [{'end': 2327.017, 'text': "And if I were to get all my items, you'll see the second one has the name of updated item.", 'start': 2321.692, 'duration': 5.325}, {'end': 2329.199, 'text': 'So we now have a full CRUD API.', 'start': 2327.598, 'duration': 1.601}, {'end': 2339.46, 'text': 'And we have, you know, our options inside of our routes with some a little bit of validation with some schemas or a schema.', 'start': 2330.912, 'duration': 8.548}, {'end': 2345.385, 'text': 'And, you know, we have our swagger documentation, which we can actually take a quick look at.', 'start': 2340.181, 'duration': 5.204}, {'end': 2348.668, 'text': 'So if I reload this, it should show all of our different routes.', 'start': 2345.525, 'duration': 3.143}], 'summary': 'Developed a full crud api with route options and swagger documentation.', 'duration': 26.976, 'max_score': 2321.692, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA2321692.jpg'}, {'end': 2382.591, 'src': 'embed', 'start': 2366.878, 'weight': 7, 'content': [{'end': 2375.285, 'text': 'So let me know if you guys like this and you want me to continue on and maybe do some authentication, deal with the database.', 'start': 2366.878, 'duration': 8.407}, {'end': 2378.528, 'text': "There's plugins for cores and just a whole bunch of stuff.", 'start': 2375.425, 'duration': 3.103}, {'end': 2379.829, 'text': "So that's it, guys.", 'start': 2378.968, 'duration': 0.861}, {'end': 2382.591, 'text': 'I hope you found this useful, and I will see you next time.', 'start': 2379.849, 'duration': 2.742}], 'summary': 'Discussion of potential future topics including authentication, database management, and plugins for cores.', 'duration': 15.713, 'max_score': 2366.878, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA2366878.jpg'}], 'start': 1361.203, 'title': 'Fastify api development', 'summary': 'Covers implementing fastify swagger plugin for documentation, adding/deleting items in the controller, and creating a full crud api with fastify, demonstrating request methods and suggesting further plugin exploration.', 'chapters': [{'end': 1550.012, 'start': 1361.203, 'title': 'Implementing fastify swagger plugin', 'summary': 'Discusses implementing the fastify swagger plugin to generate documentation for routes, registering the plugin with specific options, and accessing the generated swagger documentation, showcasing two existing routes and adding a new post route.', 'duration': 188.809, 'highlights': ['Accessing Swagger documentation at HTTP local host port 5000 /docs. The Swagger documentation can be accessed at the specified URL, providing a visually appealing layout and the ability to execute requests.', 'Adding a new post route for items and defining the expected response. The chapter covers adding a new post route for items and specifying the expected response, including setting the response to a 201 status code and defining the item structure.', "Registering the Fastify Swagger plugin with specific options to enable documentation route and set route prefix. The process of registering the Fastify Swagger plugin with specific options is described, including enabling the documentation route and setting the route prefix to '/docs'."]}, {'end': 2080.063, 'start': 1550.132, 'title': 'Adding and deleting items in controller', 'summary': 'Covers adding and deleting items in the controller, including creating a new item with a unique id, adding it to the data state, and implementing required fields for the body of a post request, resulting in an error message for missing fields and using the filter function to delete an item by id.', 'duration': 529.931, 'highlights': ['Creating a new item with a unique ID using the UUID module and adding it to the state The script explains how to construct a new item with a unique ID generated using the UUID module and add it to the existing state, demonstrating the process of creating and manipulating items in the controller.', 'Implementing required fields for the body of a post request and receiving an error message for missing fields The chapter details the implementation of required fields for the body of a post request, resulting in an error message for missing fields, ensuring the necessary data is provided for successful item addition.', 'Using the filter function to delete an item by ID from the state and sending a confirmation message The script illustrates the use of the filter function to delete an item by ID from the state, followed by sending a confirmation message, showcasing the deletion process in the controller.']}, {'end': 2382.591, 'start': 2080.123, 'title': 'Creating a full crud api with fastify', 'summary': 'Demonstrates creating a full crud api with fastify, including creating, reading, updating, and deleting items, with examples of request methods and their outcomes, showcasing the capabilities of fastify and suggesting further exploration of plugins for additional functionalities.', 'duration': 302.468, 'highlights': ['The chapter demonstrates creating a full CRUD API with Fastify The chapter covers the process of creating a full CRUD API with Fastify, showcasing the capabilities of Fastify for handling create, read, update, and delete operations.', 'Examples of request methods and their outcomes are provided The transcript provides examples of request methods such as create, read, update, and delete, along with their outcomes, demonstrating the practical implementation of these operations in Fastify.', 'Suggests further exploration of plugins for additional functionalities The chapter suggests further exploration of plugins for additional functionalities, such as authentication, database integration, CORS, and other capabilities that can be leveraged with Fastify, hinting at the extensibility of the framework.']}], 'duration': 1021.388, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/Lk-uVEVGxOA/pics/Lk-uVEVGxOA1361203.jpg', 'highlights': ['The chapter demonstrates creating a full CRUD API with Fastify', 'Accessing Swagger documentation at HTTP local host port 5000 /docs', 'Registering the Fastify Swagger plugin with specific options to enable documentation route and set route prefix', 'Adding a new post route for items and defining the expected response', 'Creating a new item with a unique ID using the UUID module and adding it to the state', 'Using the filter function to delete an item by ID from the state and sending a confirmation message', 'Examples of request methods and their outcomes are provided', 'Suggests further exploration of plugins for additional functionalities']}], 'highlights': ['Fastify was benchmarked to be around 20% faster than Express in almost every request, making it a more efficient option for web development.', 'Fastify offers a minimalistic organization of plugins, providing a more organized approach compared to using Express with various modules.', 'Building a CRUD API using Fastify Demonstrating the basic way of creating routes and fetching data to build a CRUD API.', 'Installing Fastify, Fastify Swagger, and UUID modules Installing Fastify, Fastify Swagger for open API documentation, and UUID for generating random IDs as essential modules for building the API.', 'Using Rest Client for making requests Utilizing the Rest Client extension to make requests to different endpoints of the API without leaving Visual Studio Code.', 'Using nodemon as a dev dependency Installing nodemon as a dev dependency to automatically restart the server upon file changes, enhancing the development experience.', 'Setting up start scripts to run node and nodemon The chapter demonstrates setting up start scripts for running node and nodemon with basic start script for running node and dev script for running nodemon.', 'Creating a server file and configuring Fastify It explains the process of creating a server file, bringing in Fastify, and configuring it with options, such as setting logger to true for extra information in the console.', 'Starting the server on a specific port The chapter covers starting the server on a specific port, using async function with try catch block, and setting the port to 5000.', 'Demonstration of creating API routes and schema validation for returning multiple items', 'Configuration of response schemas for API routes', 'Enforcement of data types in the schema validation process', 'Registering the routes as a plugin with Fastify using a function and callback process', 'Moving the data to the routes file above the function', 'Creating a separate folder called routes to organize the routes', 'The chapter emphasizes the need for creating options for all routes, ensuring comprehensive route coverage and functionality.', 'The speaker discusses the need to specify response schemas for different data types and structures, exemplifying the difference in response handling for objects versus arrays.', 'Implementing controller functions for get all items and get single item requests results in a more organized and modular code structure.', 'Refactoring API routes by moving handler functions to options leads to a cleaner and more streamlined code.', 'Creating a new folder for Controllers and organizing code results in a more organized codebase.', 'The chapter demonstrates creating a full CRUD API with Fastify', 'Accessing Swagger documentation at HTTP local host port 5000 /docs', 'Registering the Fastify Swagger plugin with specific options to enable documentation route and set route prefix', 'Adding a new post route for items and defining the expected response', 'Creating a new item with a unique ID using the UUID module and adding it to the state', 'Using the filter function to delete an item by ID from the state and sending a confirmation message', 'Examples of request methods and their outcomes are provided', 'Suggests further exploration of plugins for additional functionalities']}