A simple Company Management System built with Express.js and MongoDB. This system allows for basic functionalities like user authentication, employee management, and more. It provides an API for managing employees and authenticating users.
company-management-system/
β
βββ config/
β βββ db.js # MongoDB connection configuration
βββ controllers/ # API logic for different routes
β βββ employeeController.js
βββ models/ # Mongoose models for database
β βββ Employee.js
β βββ User.js # User model for authentication
βββ routes/ # Route definitions
β βββ employeeRoutes.js
β βββ authRoutes.js # Authentication routes (login/signup)
βββ .env # Environment variables
βββ server.js # Main Express server file
βββ package.json
- Clone the repository:
git clone https://github.com/mscbuild/CHMS_expressJS.git cd CHMS_expressJS
- Install dependencies:
Run the following command to install the necessary dependencies:
npm install
- Set up environment variables:
Create a .env
file in the root directory and define the following environment variables:
MONGO_URI=mongodb://localhost:27017/companyDB
JWT_SECRET=your_jwt_secret_key
PORT=5000
MONGO_URI
: Your MongoDB connection string. If you're using MongoDB Atlas, use the connection string provided by Atlas.
JWT_SECRET
: A secret key for JWT encoding.
PORT
: The port the application will run on (default is 5000).
To start the development server, use:
npx nodemon server.js
The server will run at http://localhost:5000
by default.
{
"name": "John Doe",
"role": "Software Engineer",
"department": "Engineering",
"contact": "[email protected]",
"salary": 70000
}