A Node.js/Express backend API for the Employee Management System with MongoDB integration.
- 🔐 User Authentication (Register/Login)
- 👥 User Management
- 👷 Employee CRUD Operations
- 🔒 Role-based Access Control (Admin/User)
- 🗄️ MongoDB Database Integration
- 🌐 CORS Support
POST /api/auth/register
- Register new userPOST /api/auth/login
- User loginGET /api/auth/users
- Get all users (Admin only)
GET /api/employees
- Get all employeesGET /api/employees/:id
- Get single employeePOST /api/employees
- Create new employeePUT /api/employees/:id
- Update employeeDELETE /api/employees/:id
- Delete employee
GET /api/health
- Server health check
Create a .env
file with the following variables:
MONGODB_URI=your_mongodb_connection_string
PORT=3000
NODE_ENV=production
CORS_ORIGIN=https://your-frontend-domain.vercel.app
This project is configured for Vercel deployment.
-
Install Vercel CLI:
npm i -g vercel
-
Login to Vercel:
vercel login
-
Deploy:
vercel
-
Set environment variables in Vercel dashboard:
MONGODB_URI
CORS_ORIGIN
-
Install dependencies:
npm install
-
Set up environment variables:
cp env.example .env # Edit .env with your values
-
Start the server:
npm start
- Node.js
- Express.js
- MongoDB
- Mongoose
- bcryptjs
- CORS