

To set up nodemon, we need to add the following line of code to our package.json file, in the scripts object: “start”: “./node_modules/nodemon/bin/nodemon.js. nodemon is a replacement wrapper for node, to use nodemon replace the word node on the command line when executing your script. Nodemon does not require any additional changes to your code or method of development. Flexible MongoDB Mongoose Sorting Using URL Query Parameter in NodeJS. Nodemon nodemon is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected. Before you can implement database usage in your Node.
#Node mongodb install
Next we install all the dependancies that we will need: npm i nodemon mongoose fastify fastify-swagger boomīelow is a brief description of what each package does, quoted from their respective websites: In this file you can change the values entered when the project was initialised. Once completed, a package.json file is generated in the src directory. You will be prompted to enter several values when initialising a new project, these you can leave blank and update at a later stage. In the above code, we created two new directories, navigated into them, created an index.js file and initialed our project via npm. Initialise a new project by opening your terminal, executing each of the following lines of code: mkdir fastify-api
#Node mongodb for mac
You will also need an IDE and a terminal, I use iTerm2 for Mac and Hyper for Windows. You will need to have the following installed: It is a good idea to open the above pages in new tabs, for easy reference. You should have some beginner/intermediate JavaScript knowledge, have heard of Node.js and MongoDB, and know what REST APIs are. The source code for the project is available on GitHub. In this tutorial we are going to address all of the above using a combination of Node.js, MongoDB, Fastify and Swagger.

