@xyzblocks/web-notifications-domain
v2.0.8
Published
Web Notification Domain
Downloads
4
Readme
@xyzblocks/web-notifications-domain
Web Notifications Domain
Installation
npm install @xyzblocks/web-notifications-domain --save
API
INotification
Properties
image: string
message: string
timestamp: string
title: string
url: string
INotificationRepository
Methods
create(subscriptionId: string, notification: INotification): Promise<void>
findAll(subscriptionId: string, timestamp: number): Promise<Array<INotification>>
markAsRead(subscriptionId: string, timestamp: number): Promise<void>
ISubscription
Properties
channels: Array<string>
id: string
webPushSubscription: IWebPushSubscription
ISubscriptionRepository
Methods
create(subscription: ISubscription): Promise<void>
delete(id: string): Promise<void>
find(id: string): Promise<ISubscription>
findAll(channel: string): Promise<Array<ISubscription>>
update(subscription: ISubscription): Promise<void>
IWebPushSubscription
Properties
endpoint: string
expirationTime: number
keys: { auth: string, p256dh: string }
SubscriptionService
Methods
create(subscription: ISubscription): Promise<void>
delete(id: string): Promise<void>
find(id: string): Promise<ISubscription>
generatePrivateKeyAndPublicKey(): { publicKey: string; privateKey: string }
readNotifications(id: string, timestamp: number): Promise<Array<INotification>>
sendNotification(channel: string, notification: INotification): Promise<void>
subscribeToChannel(id: string, channel: string): Promise<void>
unsubscribeFromChannel(id: string, channel: string): Promise<void>