Looking for an easy-to-use web framework? 🍍 😎 👍
Learn about Node.js here 🤓 :What’s Node.js: https://ineedmoreplates.medium.com/learning-node-js-8288e0411957Server-Setup with Node.js: https://ineedmoreplates.medium.com/node-js-setting-up-a-server-534d86658252
Express.js is a web framework that has become very popular over the years for Node Developers. This blog will dive into this, giving you a bit of history and context. I’ll cover what a web framework is. Why we use it in the developer world, and how to install Express.js on Vscode via terminal commands. Don’t forget to check the links below, they offer more in-depth coverage on these topics. You’ll just get broad strokes 🎨 🖌 and brass tax 💰 in this article!
Web frameworks 🕷 🕸 🪰
If you’ve built a project with Vanilla Node.js you’ll notice there’s a bit more setup involved. Setting up your backend takes longer, as you often write a lot of sections of code that are repeated in multiple places with little to no variation. This code is referred to as Boilerplate code. You write a lot of it building out your web app. Programmers generally don’t like doing this kind of work and often use other software to making building apps more efficient.
This is where Frameworks come in, which does what we just discussed. It abstracts your standard boilerplate code. This not only takes out the boilerplate but ALSO standardizes writing the boilerplate itself on a universal level, minimizing human error. It can also provide further functionality by implementing support programs, compilers, code libraries, toolsets, and APIs(application program interfaces).
Express.js is a web framework. Like all frameworks the point is to abstract away the boilerplate, saving us time. We use this time to build out other things in our application. Making us overall more efficient.
Note about Vanilla Node.js:When learning anything new in software engineering, it’s best to read up on the concepts, best practices, and general history. The insight is really valuable. Context helps not only with your understanding of the topic but also your ability to explain the topic. Developers need to be able to communicate effectively as much as they do code. Just keep that in mind!
There is a lot written about Web frameworks you can find online about this topic. Check out the links below which will give you a deeper understanding of Web frameworks. It’s worth your time if you want to build websites and web apps.
History of Express.js 📜 ⏰ 🧮
TJ Holowaychuk is credited for the creation of Express.js. Inspired by Sinatra a Web framework for Ruby(Object Oriented Programming language). He liked the minimal approach with many features available as plugins. The first release for Express.js was November 16, 2010, and was licensed under MIT so it’s open-source(it’s free).
Why so popular? 📸 🤩 🌴
💰 That’s right it’s Free! 💵
Express.js has gained much popularity over the years as a de facto framework for Node.js. It’s important to note that it isn’t the only framework out there, just the most popular. Yet what makes this module so appealing to developers? How did it become the top choice for Node.js Frameworks?
This brings me to my next point Node + Express play well together. Which cuts down on debugging pesky issues. That’s always a plus in my book, as you can spend more time on the front-end stuff!
Express also supports the Model-View-Controller architecture which is quite common and popular among Web Developers. Anyone who wants to learn to code will eventually work with a website or app at some point. You will most often learn this pattern. Making it a popular combo to reach for.
It’s cross-platform, so you can work on your favorite operating system. You can customize Express based on what you need. Making the whole thing very lightweight and easier to implement on a Web application.
Express can throw up a website quickly. Much like Ruby on Rails, Express has a module called Express Generator that can quickly build a website saving a lot of time. If you are a full-stack developer, that’s huge! As a lot of time is spent on the Front-end building out awesome features for your users.
Installing Express.js 💳 💎 😆
Have I got you psyched up for using Express.js yet? Awesome, let’s install the Express.js module together. I’ll go through the install step by step on Vscode(it’s my favorite IDE).
- Open up an existing project with Node.js already set up. If you’d like to start a new project and/or not really sure how to approach this. Check out my setup guide:
Yup, it’s in the same link! 😎What’s Node.js: https://ineedmoreplates.medium.com/learning-node-js-8288e0411957
2. Make sure you are in the right directory before you install anything. You want the root directory of your project.
3. In your terminal type 🎹 :
npm install --save express
4. We should have global access to Express.js. Create a file called App.js and let’s import it at the top of this file. 🚢
const express = require('express') <-- same Node.js syntax for importing
5. Done! You’ve got access to the framework from the global state. Check out all the cool specialized functions that you with Express.js. Don’t be scared to invoke them and read additional documentation. Playing is the best way you can learn, so don’t be shy! 🙈🙈 🙈
Express.js is a no-brainer choice for a Node.js web framework. It’s great if you are new to Back-end Web development or are looking to expand into another Tech stack. Major bonus if your a Rails developer as it’s inspired by Sinatra! Personally (I love Rails💎 🚂 😎 ), I found the transition easy enough, the basic concepts are the same. There is a bit of a curve, but it’s not terrible with some additional reading or video tutorials.
Hopefully, you’ve learned a bit about Web Frameworks, Express’s history, and its popularity. Stay tuned 📺 for additional blogs I’ll be writing about Node.js and Express.js in the near future. Happy Coding 👩💻 👨💻 🧑💻 !!!
Links Below 👎 😊 👌
Check’em out!!! 👀