A TypeScript Node.js server with MongoDB integration for scheduling appointments, built with Express.js and Mongoose.
- User authentication (signup/login) with JWT tokens
- CRUD operations for appointments
- Input validation and error handling
- Appointment conflict prevention
- Email notifications for appointments
- Web configuration management
- Rate limiting and security headers
- API documentation with Swagger/OpenAPI
- Node.js (v16+)
- MongoDB
- npm or yarn
- Clone the repository
- Install dependencies:
npm install- Create a
.envfile in the root directory (use.env.exampleas a template) - Start the development server:
npm run dev- Seed the database with sample data:
npm run seedappointment-scheduling-api/
├── dist/ # Compiled TypeScript output
├── logs/ # Application logs
├── src/
│ ├── config/ # Configuration files
│ ├── controllers/ # Route controllers
│ ├── dto/ # Data Transfer Objects
│ ├── middleware/ # Custom middleware
│ ├── models/ # Mongoose models
│ ├── routes/ # Express routes
│ ├── scripts/ # Utility scripts (e.g., seed)
│ ├── utils/ # Utility functions
│ └── server.ts # Entry point
├── .env # Environment variables
├── .env.example # Example environment variables
├── package.json # Project dependencies
└── tsconfig.json # TypeScript configuration
Once the server is running, you can access the Swagger documentation at:
http://localhost:3000/api-docs
- name: string
- email: string (unique)
- phone: string
- username: string (unique)
- password: string (hashed)
- subscription: string (free, basic, premium)
- webConfig_id: ObjectId (reference to WebConfig)
- defaultLanguage: string
- timestamp: Date
- name: string
- phone: string
- user_id: ObjectId (reference to User)
- user: ObjectId (reference to User)
- type: string
- duration: number (milliseconds)
- status: string (scheduled, completed, cancelled, no-show)
- notes: string (optional)
Complex configuration object for business settings, including:
- Business information
- Working hours
- Address and contact details
- UI components configuration
- Appointment types
- Visual theme settings
The API uses JWT (JSON Web Tokens) for authentication. To access protected routes:
- Register a new user or login with existing credentials
- Use the returned token in the Authorization header:
Authorization: Bearer YOUR_TOKEN_HERE
npm run dev: Start development server with hot reloadnpm run build: Build the project for productionnpm start: Start the production servernpm run seed: Seed the database with sample datanpm run lint: Run ESLint to check code qualitynpm test: Run tests
- JWT Authentication
- Password hashing
- Input validation
- Rate limiting
- Security headers with Helmet
- Error handling