Skip to main content

Posts

Showing posts from February, 2021

Getting started with Ejs template engine

 Hi. In this tutorial, I will show you how start using template engines in your node js/express js applications. Template engines are the easiest ways to get started with building your express js application.  I recommend you check out our video content and other useful resources on our YouTube channel and this blog respectively. NB: Basic node js/express knowledge required for this tutorial What is template engine? In simple terms, a template engine is a package that renders data in HTML pages. It easily allows us to create and use static html page. One particularity with template engines is their ability to inject data from the server into an html template and then send the final html page to the client side. In other words, a variable can be created in our server and then be inserted in an html template.  We have several examples of template engines which are usable with node js and express js which include: Pug Handlebars  EJS Hogan etc With simplicity in syntax ...

Express js morgan third party middleware

  Hello. Welcome to another new tutorial on express JS. Today, we will be talking about a third-party middleware which is also a module called morgan . To follow along in this article, you should have basic knowledge of node js and express. If this is your first time learning about middleware or express js, I recommend you navigate to the node js section of this website and our YouTube channel to learn more. As commonly described, morgan is an http request logger middleware. That is, morgan middleware prints out the details of every request made from your application on the console or command-line. This is a handy tool used during the development process for testing an application. This is possible because it morgan is a middleware, and you know every middleware has access to the request-response cycle of an application.  Since morgan is a third-party middleware and module, it therefore needs to be installed before usage. To install morgan, navigate to your project directory ...

Serve-favicon third party middleware

  Hello!. Welcome to another moment with me again to learn and code on this platform. Today, I am going to be talking about how to add favicons on your web applications. Basic knowledge in node js and express js is needed to go through this tutorial. I know some people might be wondering what a favicon is. I think let me show you what it is, since a picture speaks a thousand times better than words. Have you ever noticed a little thumbnail image beside the title at the tab of a webpage ? Did you see that!. That’s a favicon. As you can see, the one above is for medium.com website and that of express website. I mentioned earlier that serve-favicon is a third-party middleware, meaning it must be installed before usage. To install this middleware or module, navigate to your project’s directory from a command prompt window and type the command; npm install serve-favicon Ensure you have a working and good internet connection. Wait for some time as npm downloads and installs this module ...

Express js built-in middleware

Hey!. In this article, we are going to talk about express js built-in middleware. If you are totally new in this, I recommend you check out my last articles on express js middleware by simply navigating to the node js section on this blog. From the word built-in, you can understand this middleware doesn’t need any installation and hence comes with express by default. On this blog, we are going to look at two different built-in middleware which are express.static () and express.json () . Today, we will learn about the express.static () middleware. Express static middleware is responsible or used to serve static files or static assets such as a webpage, files, images, style sheets, … This is very useful in the sense, when ever you include a static asset like images, stylesheet etc in your app, express first checks the folder holding static resources or files. It is mostly named the “public” folder for best practices and I also think its conventional. Whenever express finds a public fold...

Express Router Level Middleware

Hi Everyone 😎 . Welcome to another moment with me in this tutorial. Today, I will be teaching you about express js router level middleware. If you are totally new in your knowledge about middleware functions, please navigate to the node js section of this website or our YouTube channel and checkout my tutorial on express js middleware. In my last article before this, we looked at the meaning of middleware, its uses or roles and then we ended up by studying the application-level middleware. In this new tutorial, we will look at the following about the router-level middleware; Definition   Use and  Example   DEFINITION AND USE Now let’s try explaining what the router-level middleware is all about. Remember the application level middleware is bound to an instance of the app object which could either be with app.use() or app.METHOD () where the method refers to the http method (get, put, post, delete). The router-level middleware works like the application-level middleware e...

MVC EXPLAINED FOR BEGINNERS

Hola!. In this article, I am going to break down the terrifying design model known as MVC for easy understanding to all. You might consider reading this article as a beginner or maybe preparing for that scary interview ☺ . As usual, many developers just get excited and start writing code without having a good mastery of these concepts which are very necessary in building, programming and writing better code. Hey! friend ☺ , don’t think you are reading what won’t help you ok!. MVC which is known as model view controller is an architectural pattern used in building web apps nowadays. This architectural pattern separated an application into three parts: Model View Controller  In this article, will explain the following  Components Advantages Now let’s begin with; COMPONENTS As mentioned earlier, MVC architectural pattern states that, an application is made up of three parts which are model, view and controller . Now let us break them down; The view is the user interface. Meaning...

Express Application-Level Middleware

Hi everyone ☺ . This is Godwill today, I will be talking about Express.js application-level middleware. I recommend you check out my Youtube videos and other Node Js and Express tutorials on this blog. If you have coded in Node Js or Express Js before, I guess you must have come across the word middleware. In this tutorial, I am going to cover the following; What is a middleware? Types of middleware Case of an application-level middleware What is a middleware in Express? Middleware is a function that gets executed during the request-response lifecycle of an application. So you got the word function which literally mean middleware are actually functions in your Express application. These middleware functions have access to the request and response objects of the route it is attached to it in the application lifecycle. According to expressjs.com, middleware functions are capable of; Executing block of codes, Modifying the request and response objects, End an apps request and response cyc...

image

 

Getting started with Express and Node JS

Hello, this is Godwill Tetah. In this tutorial, I am going to teach you how to use the Express JS web framework alongside with Node JS. Whether you are noob in Node JS development or advanced, you are at the right place and the right time ☺. Basic knowledge on Node JS is required though. To those who are still starting up Node JS back-end development, I will teach you how to get started with express while for those who already have some good knowledge in this field, this is the right place to quickly revise and refresh your knowledge in preparation for that interview, exam or anything else. In this tutorial, we will cover the following; What is Express JS? What make Express JS very important? Installation Routing and HTTP methods