Skip to main content

Overview

This document provides a complete reference for the Node.js application deployed through the Jenkins CI/CD pipeline. The application is a simple Express.js web server that responds to HTTP requests.

Application Source Code

index.js

The main application file that creates and configures the Express server.
const express = require('express');
const app = express();
app.get('/', (req, res) => res.send('Hello, Elevate Labs, This is After pushing code commits to GitHub'));
app.listen(3000, () => console.log('App running on port 3000'));

Code Breakdown

Import Express

const express = require('express');
Imports the Express.js framework for building the web application.

Create Express Application

const app = express();
Creates an Express application instance.

Define Route Handler

app.get('/', (req, res) => res.send('Hello, Elevate Labs, This is After pushing code commits to GitHub'));
Defines a GET route for the root path (/) that sends a text response.
req
object
The request object containing information about the HTTP request.
res
object
The response object used to send data back to the client.

Start Server

app.listen(3000, () => console.log('App running on port 3000'));
Starts the Express server on port 3000 and logs a confirmation message.
port
number
default:"3000"
The port number on which the server listens for incoming requests.

Endpoints

GET /

The root endpoint that returns a welcome message. Request:
GET / HTTP/1.1
Host: localhost:3000
Response:
Hello, Elevate Labs, This is After pushing code commits to GitHub
Method
string
default:"GET"
HTTP method for the endpoint.
Path
string
default:"/"
The URL path for the endpoint (root path).
Response Type
string
default:"text/html"
Content type of the response. Express automatically sets this when using res.send() with a string.
Status Code
number
default:"200"
HTTP status code returned on successful request.

Testing the Endpoint

Using curl:
curl http://localhost:3000/
Using browser:
http://localhost:3000/
Expected output:
Hello, Elevate Labs, This is After pushing code commits to GitHub

Package Configuration

package.json

The package configuration file defines project metadata, dependencies, and scripts.
{
  "name": "nodejs-demo-app",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Running dummy test..\" && exit 0"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^5.1.0"
  }
}

Package Fields

name
string
default:"nodejs-demo-app"
The name of the application package.
version
string
default:"1.0.0"
The current version of the application following semantic versioning.
description
string
A brief description of the application (currently empty).
main
string
default:"index.js"
The entry point file for the application.
license
string
default:"ISC"
The license under which the application is distributed.

Scripts

test
string
default:"echo \"Running dummy test..\" && exit 0"
The test script executed when running npm test. This is a dummy test that always succeeds (exit code 0).

Dependencies

express
string
default:"^5.1.0"
Express.js framework version 5.1.0 or higher (compatible with minor and patch updates). Used for building the web server.

Application Deployment

The application is deployed through the Jenkins pipeline using Docker.

Local Development

Install dependencies:
npm install
Run the application:
node index.js
Expected output:
App running on port 3000

Docker Deployment

Build the Docker image:
docker build -t nodejs-demo-app:latest .
Run the container:
docker run --name Jenkins -d -p 80:3000 nodejs-demo-app:latest
Access the application:
http://localhost:80/

Port Configuration

Application Port
number
default:"3000"
The port on which the Express application listens inside the container.
Container Port
number
default:"3000"
The port exposed by the Docker container (defined in Dockerfile with EXPOSE 3000).
Host Port
number
default:"80"
The port on the host machine mapped to the container port. The application is accessible on port 80 in production.

Testing

The application includes a dummy test script in package.json. Run tests:
npm test
Output:
Running dummy test..
The test always exits with code 0 (success). In the Jenkins pipeline, even if tests fail, the pipeline continues:
npm test || echo "No tests defined or test failed, continuing..."

Environment

Node.js Version
string
default:"18"
The application runs on Node.js version 18, using the Alpine Linux base image for minimal size.
Express Version
string
default:"5.1.0"
The application uses Express.js version 5.1.0.
Working Directory
string
default:"/app"
The working directory inside the Docker container where the application files are located.

Build docs developers (and LLMs) love