Skip to content

Doctor-Appointment-Scheduling/backend

Repository files navigation

Backend

This is the backend for a doctor application. It is built using Node.js and Express.js and follows a modular structure for scalability and maintainability.

Features

  • Express.js: A fast and minimalist web framework for building APIs.
  • Environment Configuration: Uses .env files for environment-specific configurations.
  • Modular Structure: Organized into routes, middlewares, services, handlers, models, and utils for better code management.
  • Testing: Includes unit tests using Jest with coverage reports.
  • Graceful Shutdown: Handles server shutdown gracefully on termination signals.

Project Structure

.
├── **.env** - Environment variables  
├── **.env.example** - Example environment variables  
├── **.gitignore** - Files and directories to ignore in Git  
├── **index.js** - Entry point of the application  
├── **jest.config.js** - Jest configuration  
├── **package.json** - Project metadata and dependencies  
├── **README.md** - Project documentation  
├── **coverage/** - Test coverage reports  
├── **handlers/** - API request handlers  
├── **middlewares/** - Middleware functions  
├── **models/** - Data models  
├── **routes/** - API routes  
├── **services/** - Business logic and data processing  
├── **tests/** - Unit tests  
└── **utils/** - Utility functions

Installation

  1. Clone the repository:
    git clone https://github.com/your-username/backend.git
    cd backend
  2. Install dependencies
    npm install
  3. Create a .env file based on .env.example:
    cp .env.example .env
  4. Set the PORT variable in the .env file.

Usage

  • Development : Start the development server with hot-reloading:

    npm run dev
  • Production : Start the production server:

    npm run dev
  • Prisma:

    • Generate Client:
      prisma generate
    • Run migrations:
      npx prisma migrate dev --name init
    • Open Prisma Studio:
      npx prisma studio

Testing

  • Run unit tests:
    npm test
  • Run tests in watch mode:
    npm run test:watch
  • Generate a test coverage report:
    npm run test:coverage

API Endpoints

  • Base URL
    http://localhost:<PORT>
    

Routes

Appointments

  • GET /appointments/: Retrieves all appointments.
  • GET /appointments/:id: Retrieves a specific appointment by its ID.
  • GET /appointments/user/:userId: Retrieves all appointments for a specific user by their user ID.
  • GET /appointments/doctor/:doctorId: Retrieves all appointments for a specific doctor by their doctor ID.
  • POST /appointments/: Creates a new appointment.
  • PUT /appointments/:id: Updates an existing appointment by its ID.
  • DELETE /appointments/:id: Deletes an appointment by its ID.
  • PATCH /appointments/cancel/:id: Cancels an appointment by its ID.

QR Code

  • POST /qrCode/generate: Generates a QR code for a given text.
  • POST /qrCode/verify: Verifies a QR code against expected text and confirms the associated appointment.

Default

  • GET /: Returns a welcome message.

Feel free to add more details or endpoints as your project evolves!### Routes

Appointments

  • GET /appointments/: Retrieves all appointments.
  • GET /appointments/:id: Retrieves a specific appointment by its ID.
  • GET /appointments/user/:userId: Retrieves all appointments for a specific user by their user ID.
  • GET /appointments/doctor/:doctorId: Retrieves all appointments for a specific doctor by their doctor ID.
  • POST /appointments/: Creates a new appointment.
  • PUT /appointments/:id: Updates an existing appointment by its ID.
  • DELETE /appointments/:id: Deletes an appointment by its ID.
  • PATCH /appointments/cancel/:id: Cancels an appointment by its ID.

QR Code

  • POST /qrCode/generate: Generates a QR code for a given text.
  • POST /qrCode/verify: Verifies a QR code against expected text and confirms the associated appointment.

Default

  • GET /: Returns a welcome message.

Feel free to add more details or endpoints as your project evolves! ```

  • Routes
    GET /: Returns a welcome message.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors