You could write all your code inside the sever.js file, but this is not looking very nice and the node.js supports your to write very function to modules that will be easy maintain and to test it.
Especially in this day, we need write anything in MVC architecture way. Now we are going to creates a foleder named controllers in your project so here is the folder looks like.
now you have very nice and clear code in serve.js
The index.js under the controllers file init your controllers.
here is your homeController.js file, get,post,delete,… wirte in this file
the last step is write your view, here is the layout.vash and index.vash
Then finally, go to local host will render page: