A minimal Express.js application with MongoDB connection, health check endpoint, and basic configuration.
- Node.js (v14 or higher)
- MongoDB (local or Atlas)
- Clone the repository
git clone
cd express-mongo-app- Install dependencies
npm install- Configure environment variables
# Copy the example .env file and modify it with your MongoDB connection details
cp .env.example .env
# Edit the .env file with your MongoDB connection string- Start the development server
npm run dev- For production use
npm run build
npm start.
├── package.json # Project dependencies and scripts
├── .env # Environment variables
├── src/
│ ├── index.js # Main application file
│ ├── routes.js # API routes
│ └── models/ # MongoDB models
│ └── user.js # Example user model
GET /- Health check endpointGET /api/hello- Example API endpoint
npm start- Start the server in production modenpm run dev- Start the server in development mode with hot-reloadingnpm run build- Build the project for production deployment
PORT- Server port (default: 3000)MONGODB_URI- MongoDB connection string