Skip to content

Vmkmanoj/crud-controller-backend

Repository files navigation

Employee Management System - Backend API

A Node.js/Express backend API for the Employee Management System with MongoDB integration.

Features

  • 🔐 User Authentication (Register/Login)
  • 👥 User Management
  • 👷 Employee CRUD Operations
  • 🔒 Role-based Access Control (Admin/User)
  • 🗄️ MongoDB Database Integration
  • 🌐 CORS Support

API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - User login
  • GET /api/auth/users - Get all users (Admin only)

Employees

  • GET /api/employees - Get all employees
  • GET /api/employees/:id - Get single employee
  • POST /api/employees - Create new employee
  • PUT /api/employees/:id - Update employee
  • DELETE /api/employees/:id - Delete employee

Health Check

  • GET /api/health - Server health check

Environment Variables

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

Deployment

This project is configured for Vercel deployment.

Deploy to Vercel

  1. Install Vercel CLI:

    npm i -g vercel
  2. Login to Vercel:

    vercel login
  3. Deploy:

    vercel
  4. Set environment variables in Vercel dashboard:

    • MONGODB_URI
    • CORS_ORIGIN

Local Development

  1. Install dependencies:

    npm install
  2. Set up environment variables:

    cp env.example .env
    # Edit .env with your values
  3. Start the server:

    npm start

Tech Stack

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose
  • bcryptjs
  • CORS

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published