@gj-kit/nest-notifications recipes
Each code block reuses a public-contract example already type-checked in the package README.
1. Register a durable notification dispatcher
Section titled “1. Register a durable notification dispatcher”Pass application stores, a presenter, policy, and push gateway into the Nest module explicitly.
Outcome: Durable relay and dispatch runners wired to your stores and push gateway.
Application-owned boundary: Keep product policy in app-owned stores, presenter, and scheduling policy before registering the Nest module.
import { NestNotificationsModule, type NestNotificationsOptions } from '@gj-kit/nest-notifications';
declare const options: NestNotificationsOptions; // App stores, presenter, policy, and push gateway.
export const notifications = NestNotificationsModule.forRoot(options);2. Test store behavior and quiet-hours policy
Section titled “2. Test store behavior and quiet-hours policy”Run shipped contract cases against the application store and declare a timezone for quiet hours.
Both halves are load-bearing: the policy cannot be constructed without a time zone, and the same 30 cases the library runs against its in-memory stores become the acceptance criteria for yours.
import { createQuietHoursPolicy } from '@gj-kit/nest-notifications/core';import { notificationStoreContractCases } from '@gj-kit/nest-notifications/testing';import type { NotificationStoreSuite } from '@gj-kit/nest-notifications/testing';
declare function myPostgresStores(): Promise<NotificationStoreSuite>; // the app owns this
// The library holds no regional default, so the zone cannot be left unsaid.export const policy = createQuietHoursPolicy({ timeZone: 'Asia/Seoul', quietHours: { startHour: 22, endHour: 8 }, batchWindowMs: 600_000, // must divide 24h, or assembly throws ERR_NOTIFICATION_POLICY_INVALID});// Drop timeZone and tsc stops the build:// error TS2345: Argument of type '{ quietHours: { startHour: number; endHour: number; }; }'// is not assignable to parameter of type 'QuietHoursPolicyOptions'.
// The 30 cases the library runs on its own in-memory stores, now run on yours.for (const testCase of notificationStoreContractCases({ concurrency: 8 })) { it(testCase.name, () => testCase.run(myPostgresStores));}Use the complete API reference for every export and import path.