Skip to content

tarunmittal24/sample-node-js-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js Server

A simple Express.js server with environment variable support and health check endpoint.

Features

  • Express.js web server
  • Environment variable configuration using dotenv
  • Health check endpoint
  • 10-second startup delay
  • CORS support

Prerequisites

  • Node.js (version 14 or higher)
  • npm

Installation

  1. Clone the repository:
git clone <repository-url>
cd nodejs-server
  1. Install dependencies:
npm install
  1. Create a .env file in the root directory:
NAME=Your Name

Usage

  1. Start the server:
node app.js
  1. The server will start after a 10-second delay and be available at http://localhost:3000

API Endpoints

GET /

Returns the value of the NAME environment variable.

Response:

Your Name

GET /health

Health check endpoint that returns server status and uptime.

Response:

{
  "status": "healthy",
  "timestamp": "2024-01-01T00:00:00.000Z",
  "uptime": 123.456
}

Environment Variables

  • NAME - The name to display on the root endpoint

Dependencies

  • express - Web framework for Node.js
  • dotenv - Loads environment variables from .env file

License

ISC

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published