DEV Community

Royal Jain
Royal Jain

Posted on

2 1

Contribute to Open-Source: A step-by-step guide for Express NodeJs

Express is a minimal and flexible Node.js web application framework for Node. It’s top features include DSL for routing, HTTP helpers like redirection, caching, cookie management etc with focus on high performance

We will explore the internals of express through a series of tasks of increasing complexity and scope. Each task will have a scope and runtime with it so you can get started without the setup load.


Repository Overview

Express is a lightweight framework which relies on developers adding custom middleware for their specific use case. It relies on Node’s http server to run and adds some core objects like

  • Request - Object which handles request parsing for headers, fresh / stale, checking for proxy etc
  • Response - Object for sending response (setting headers, attaching files, response codes etc)
  • Router - Core routing logic ( setting up API path’s and corresponding functions) + framework for adding Middleware

Middlewares provide custom functionality and can be added by using app.use interface

  • Middleware - Adding functionality to express like cookie-parsing, cors etc can be done by adding middleware functions which can alter request and response object. In-depth.
  • Application - Finally everything is wrapped around in the Application Object

Tasks

Task #1: Add default port 1994 to the express server

Description: Express has a default port of 3000, try changing this to 1994. Get yourself familiar with lib/express.js and lib/application.js. Ignore other files for now.

Scope:

  1. lib/application.js
  2. lib/express.js

Hint: Searching for app.listen will be a good starting point

Run Task

Checkout complete tutorial at Full Tutorial

SurveyJS custom survey software

Build Your Own Forms without Manual Coding

SurveyJS UI libraries let you build a JSON-based form management system that integrates with any backend, giving you full control over your data with no user limits. Includes support for custom question types, skip logic, an integrated CSS editor, PDF export, real-time analytics, and more.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay