@node-notifications/storage-typeorm-0.3
v3.1.0
Published
TypeORM storage for Notification System
Downloads
313
Readme
Notification System TypeORM-v0.3 storage
Description
TypeORM v0.3 storage for Notification System
Install
yarn add @node-notifications/storage-typeorm-0.3
Migrations:
- Copy migrations from library to project migrations directory
cp ./node_modules/@node-notifications/storage-typeorm-0.3/migrations/*.js ./migrations/- Run migrations
./node_modules/.bin/typeorm migration:run- Revert migrations
./node_modules/.bin/typeorm migration:revertTypeORM config:
Sample usage:
import { ConsoleTransport, NotificationQueueManager, NotificationService } from '@node-notifications/core';
import { TypeormStorage } from '@node-notifications/storage-typeorm-0.3';
let service: NotificationService;
let queueManager: NotificationQueueManager;
async function main() {
// Instantiate Notification Service
service = new NotificationService(
// eslint-disable-next-line @typescript-eslint/no-var-requires
await new TypeormStorage().initialize(require('./ormconfig.js')),
{
// Log all notification to console (for test/demo purpose)
console: new ConsoleTransport(),
},
);
// Instantiate Notification Queue Manager and start Queue Processing
queueManager = new NotificationQueueManager(service).start();
// To stop Queue Processing:
// queueManager.stop();
// ...
// Sample usage (data: INotification)
service.send({ recipient: '[email protected]', payload: 'Test Notification', transports: ['console'] }).then();
}