I am starting a series on node js. Actually I’m not super skilled with node js. So I thought let’s start from zero again and help others with me to learn about it. I saw the ‘the net ninja’ tutorials and took the syllabus from there and make a fusion of my own. I want to help you with my journey, let’s ride together into node js for 30 days…
Day 20 — Express Js Introduction — Learning Node JS In 30 Days [Mini series]
A full series to learn the basics easily of node js
Today we’re going to learn about express js.
We can start using checking the official document of express js — https://expressjs.com/
We are going to use express mostly for 3 reasons
- Easy routing system
- Can use with many templating system
- Have a middleware framework
We can start with the routing. Before express we write a long code to create a server, but with express it’s pretty easy. See the old code
Now we are going to write the same old code using express.
First we need to require express
then create an app constant using express()
Now we can write app.listen(3000) to listen 3000 port.
We can write the routes now. Like homepage -
Now our code is more readable and easy to add any route