DEV Community

Cover image for Day 20 – Express Js Introduction - Learning Node JS In 30 Days [Mini series]
Muhammad Ali (Nerdjfpb)
Muhammad Ali (Nerdjfpb)

Posted on

Day 20 – Express Js Introduction - Learning Node JS In 30 Days [Mini series]

Today we're going to learn about express js.

We can start using checking the official document of express js - https://expressjs.com/

Alt Text

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

Alt Text

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()

Alt Text

Now we can write app.listen(3000) to listen 3000 port.

Alt Text

We can write the routes now. Like homepage -

Alt Text

Now our code is more readable and easy to add any route

Alt Text

So you like the introduction of express js ?

You can see the graphical version here

Originally it published on nerdjfpbblog. You can connect with me in twitter or linkedin !

You can read the old posts from this series (below)

Top comments (0)