1.0.4 • Published 3 years ago
@notifications-system/storage-typeorm-0.2 v1.0.4
Notifications System TypeORM-v0.2 storage
Description
TypeORM v0.2 storage for Notifications System
Install
npm i @notifications-system/storage-typeorm-0.2
Migrations:
- Copy migrations from library to project migrations directory
cp ./node_modules/@notifications-system/storage-typeorm-0.2/migrations/*.js ./migrations/
- Run migrations
./node_modules/.bin/typeorm migration:run
- Revert migrations
./node_modules/.bin/typeorm migration:revert
TypeORM config:
Sample usage:
import { ConsoleTransport, NotificationQueueManager, NotificationService, TRANSPORT_CONSOLE } from '@notifications-system/core';
import { TypeormStorage } from '@notifications-system/storage-typeorm-0.2';
let service: NotificationService;
async function main() {
// Instantiate Notification Service
service = new NotificationService(
await new TypeormStorage().initialize(require('./ormconfig.js')),
[
new ConsoleTransport(), // Log all notification to console (for test/demo purpose)
],
);
new NotificationQueueManager(service).queueStart();
// Sample usage
service.send(TRANSPORT_CONSOLE, { recipient: 'user@mail.test', payload: 'Test Notification' });
}