-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dips, push notif backend progress, speaker links
- Loading branch information
Showing
16 changed files
with
252 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Request, Response, Router } from 'express' | ||
import { PrismaClient } from '@/db/clients/account' | ||
|
||
const prisma = new PrismaClient() | ||
|
||
export const pushNotificationRouter = Router() | ||
|
||
pushNotificationRouter.post('/subscriptions', subscribeToPushNotifications) | ||
pushNotificationRouter.delete('/subscriptions', unsubscribeFromPushNotifications) | ||
|
||
async function subscribeToPushNotifications(req: Request, res: Response) { | ||
// #swagger.tags = ['Push Notifications'] | ||
const { endpoint, keys } = req.body | ||
|
||
if (!endpoint || !keys || !keys.auth || !keys.p256dh) { | ||
return res.status(400).send({ status: 400, message: 'Endpoint and keys (auth and p256dh) are required', data: null }) | ||
} | ||
|
||
try { | ||
await prisma.pushSubscription.create({ | ||
data: { | ||
endpoint, | ||
auth: keys.auth, | ||
p256dh: keys.p256dh, | ||
}, | ||
}) | ||
res.status(201).send({ status: 201, message: 'Subscription successful', data: null }) | ||
} catch (error) { | ||
console.error('Error subscribing to push notifications:', error) | ||
res.status(500).send({ status: 500, message: 'Internal server error', data: null }) | ||
} | ||
} | ||
|
||
async function unsubscribeFromPushNotifications(req: Request, res: Response) { | ||
// #swagger.tags = ['Push Notifications'] | ||
const { endpoint } = req.body | ||
|
||
if (!endpoint) { | ||
return res.status(400).send({ status: 400, message: 'Endpoint is required', data: null }) | ||
} | ||
|
||
try { | ||
await prisma.pushSubscription.delete({ | ||
where: { endpoint }, | ||
}) | ||
res.status(200).send({ status: 200, message: 'Unsubscription successful', data: null }) | ||
} catch (error) { | ||
console.error('Error unsubscribing from push notifications:', error) | ||
res.status(500).send({ status: 500, message: 'Internal server error', data: null }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { Sort, SortButton, useSort, SortVariation } from './Sort' | ||
export { Sort, SortButton, useSort, SortVariation, presetSortingMethods } from './Sort' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.