This Framework provides a convenient interface and essential features for managing notifications within your application.
Our journey to version 1.0.0 includes:
-
Testing:
- Expand unit tests coverage.
- Add integration tests by integrating the framework into a Node.js project to demonstrate its functionality.
-
Documentation:
- Improve and expand documentation.
- Include detailed examples and usage scenarios.
-
More Examples:
- Provide additional examples showcasing different configurations and use cases.
-
Community Feedback:
- Gather feedback from early adopters to refine features and fix bugs.
- Interfaces for managing notifications and user-notification features.
- Singleton pattern to ensure a single instance with consistent configuration.
- Supports multiple database configurations, including Mongo collections, and in-memory databases (more options to come).
- Provides access to
NotificationService
andUserNotificationMetadataService
for managing notifications and metadata.
-
Clone the Git repository:
git clone https://github.com/Jhotika/notification-framework
-
Install the dependencies using npm:
npm install
or yarn:
yarn install
To use the NotificationFramework
, initialize it with a logger (optional) and a database configuration.
import NotificationFramework from "notification-framework/lib";
import { DatabaseType } from "notification-framework/lib/configs/db/database.config";
import { Logger } from "path/to/your/logger"; // Example logger
const dbConfig = {
type: DatabaseType.MongoDocuments,
config: {
// MongoDB configuration here
},
};
// optional logger
const logger = new Logger();
const framework = NotificationFramework.getInstanceX(
dbConfig,
[MockNotification], // list of your concrete notification classes
logger // optional
);
// Use the framework to get services
const notificationService = framework.getNotificationServiceX("viewerId");
const userMetadataService =
framework.getUserNotificationMetadataServiceX("viewerId");
You can also use the NotificationFrameworkBuilder
to configure and create the framework instance.
import { NotificationFrameworkBuilder } from "notification-framework/lib";
import { Logger } from "path/to/your/logger"; // Example logger
const builder = new NotificationFrameworkBuilder()
.withMongoCollectionConfig({
notificationCollection, // your notification collection
userNotificationMetadataCollection, // your notification metadata collection
})
.withConcreteNotificationClasses([MockNotification]) // list of your concrete notification classes
.withLogger(new Logger()); // optional
const framework = builder.buildX();
// Use the framework to get services
const notificationService = framework.getNotificationServiceX("viewerId");
const userMetadataService =
framework.getUserNotificationMetadataServiceX("viewerId");
To configure the framework with Mongo collections:
import { IMongoCollectionConfig } from "notification-framework/lib/configs/db/mongoCollection.config";
const mongoCollectionsConfig: IMongoCollectionConfig = {
notificationCollection: your-mongo-collection-for-notifications,
userNotificationMetadataCollection: your-mongo-collection-for-metadata,
};
For in-memory database configuration:
import { IInMemoryConfig } from "notification-framework/lib/configs/db/inMemory.config";
const inMemoryConfig: IInMemoryConfig = {};
We welcome contributions to the Notification Framework. To contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Commit your changes and push the branch.
- Open a pull request describing your changes.
- Join our Facebook group! - Facebook Group
To maintain code quality and consistency, please follow these guidelines:
- Method naming:
- Async methods are prefixed with
gen
. e.g.,genResponse
- Methods that might throw are suffixed with
X
, e.g.,buildX
orgenMarkAsReadX
- Async methods are prefixed with
- Keep external dependencies as low as possible
- No offsite write! We delegate offsite writes to the Framework users.
- Testing: Write unit tests for new features and bug fixes. Ensure all tests pass before submitting a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to reach out with any questions or suggestions. Happy coding! 🚀