@gj-kit/nest-notifications 레시피
각 코드 블록은 패키지 README에서 이미 타입 검사하는 public-contract 예제를 재사용합니다.
1. 내구성 있는 알림 dispatcher 등록하기
섹션 제목: “1. 내구성 있는 알림 dispatcher 등록하기”앱 store, presenter, policy, push gateway를 Nest module에 명시적으로 전달합니다.
완료 상태: 앱의 store와 push gateway에 연결된 내구성 있는 relay·dispatch runner를 만듭니다.
앱 소유 경계: Nest module을 등록하기 전에 제품 정책은 앱 소유 store, presenter, scheduling policy에 둡니다.
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. store 동작과 quiet-hours policy 테스트하기
섹션 제목: “2. store 동작과 quiet-hours policy 테스트하기”제공된 contract case를 앱 store에 실행하고 quiet hours에는 timezone을 선언합니다.
두 대목 모두 실제로 강제됩니다 — 시간대 없이는 정책을 만들 수 없고, 라이브러리가 자기 인메모리 저장소에 돌리는 케이스 30개가 그대로 직접 만든 저장소의 인수 조건이 됩니다.
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));}전체 API reference에서 모든 export와 import path를 확인하세요.