Skip to content

COMbaohe/smr

Repository files navigation

Notification Service

Overview

The Notification Service is a modular application designed to manage subscriptions and send notifications through multiple channels. It supports subscription management, scheduled notifications, and distribution across various platforms such as email, SMS, and push notifications.

Project Structure

  • src/: Contains the source code for the application.

    • index.ts: Entry point of the application.
    • controllers/: Contains controllers for handling requests.
      • subscription.controller.ts: Manages subscription-related operations.
    • services/: Contains business logic for the application.
      • subscription.service.ts: Handles subscription management.
      • scheduler.service.ts: Manages scheduled notifications.
      • dispatcher.service.ts: Distributes notifications across channels.
    • channels/: Contains implementations for different notification channels.
      • email.channel.ts: Sends notifications via email.
      • sms.channel.ts: Sends notifications via SMS.
      • push.channel.ts: Sends push notifications.
    • models/: Defines data structures.
      • subscription.ts: Represents a subscription object.
    • jobs/: Contains job definitions for scheduled tasks.
      • send-job.ts: Defines the job for sending notifications.
    • utils/: Utility functions and helpers.
      • logger.ts: Provides logging functionality.
    • types/: Type definitions used throughout the application.
      • index.ts: Exports various TypeScript types and interfaces.
  • config/: Contains configuration files.

    • default.json: Default configuration settings.
  • scripts/: Contains scripts for various tasks.

    • migrate.ts: Database migration script.
  • package.json: NPM configuration file.

  • tsconfig.json: TypeScript configuration file.

  • .env.example: Example environment variables.

Setup Instructions

  1. Clone the repository:

    git clone <repository-url>
    cd notification-service
    
  2. Install dependencies:

    npm install
    
  3. Configure environment variables by copying .env.example to .env and updating the values as needed.

  4. Run the application:

    npm start
    

Usage

  • To manage subscriptions, use the SubscriptionController methods:

    • createSubscription: Create a new subscription.
    • getSubscriptions: Retrieve all subscriptions.
    • deleteSubscription: Remove a subscription.
  • Notifications can be scheduled using the SchedulerService, and they will be dispatched through the appropriate channels by the DispatcherService.

Contributing

Contributions are welcome! Please submit a pull request or open an issue for discussion.

License

This project is licensed under the MIT License.

About

第一个测试仓库

Resources

Stars

Watchers

Forks