A simple Express.js server with environment variable support and health check endpoint.
- Express.js web server
- Environment variable configuration using dotenv
- Health check endpoint
- 10-second startup delay
- CORS support
- Node.js (version 14 or higher)
- npm
- Clone the repository:
git clone <repository-url>
cd nodejs-server
- Install dependencies:
npm install
- Create a
.env
file in the root directory:
NAME=Your Name
- Start the server:
node app.js
- The server will start after a 10-second delay and be available at
http://localhost:3000
Returns the value of the NAME
environment variable.
Response:
Your Name
Health check endpoint that returns server status and uptime.
Response:
{
"status": "healthy",
"timestamp": "2024-01-01T00:00:00.000Z",
"uptime": 123.456
}
NAME
- The name to display on the root endpoint
express
- Web framework for Node.jsdotenv
- Loads environment variables from .env file
ISC