-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit 2ed88ec Author: Jonas Simoen <[email protected]> Date: Sat May 18 23:00:58 2024 +0200 chore: remove logs commit 72be48a Author: Jonas Simoen <[email protected]> Date: Sat May 18 22:57:52 2024 +0200 fix(login): return to app when access denied commit 26b55d7 Author: Jonas Simoen <[email protected]> Date: Sat May 18 22:45:34 2024 +0200 feat(news): add news articles commit 2b6a891 Author: Jonas Simoen <[email protected]> Date: Fri May 17 19:09:32 2024 +0200 remove redirect_to_welcome commit a3e0c89 Author: Jonas Simoen <[email protected]> Date: Fri May 17 13:05:20 2024 +0200 feat(notif) commit af72256 Author: Jonas Simoen <[email protected]> Date: Thu May 16 22:04:30 2024 +0200 feat(audit): search audits commit 72e7b42 Author: Jonas Simoen <[email protected]> Date: Thu May 16 20:40:40 2024 +0200 chore(team): quicker db selects commit 3cdb613 Author: Jonas Simoen <[email protected]> Date: Thu May 16 20:18:30 2024 +0200 feat(general): user list commit 22a9ca7 Author: Jonas Simoen <[email protected]> Date: Thu May 16 18:29:35 2024 +0200 fix(boosters)
- Loading branch information
1 parent
c6c2288
commit 3691382
Showing
20 changed files
with
480 additions
and
206 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
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { prisma } from "../db/client" | ||
|
||
export const GetArticlesHandler = async (req: any, rep: any) => { | ||
const page = +req.query.page || 1; | ||
const [articleCount, articles] = await Promise.all([ | ||
await prisma.article.count(), | ||
await prisma.article.findMany({ | ||
select: { | ||
id: true, | ||
slug: true, | ||
title: true, | ||
description: true, | ||
timestampCreated: true, | ||
timestampUpdated: true, | ||
readMore: true, | ||
imageUrl: true, | ||
author: { | ||
select: { | ||
firstName: true, | ||
} | ||
} | ||
}, | ||
orderBy: { | ||
timestampCreated: 'desc' | ||
}, | ||
take: 5, | ||
skip: (page - 1) * 5 | ||
}), | ||
]) | ||
rep.send({ | ||
articles, | ||
count: articleCount, | ||
}) | ||
} | ||
export const GetArticleHandler = async (req: any, rep: any) => { | ||
const articles = await prisma.article.findFirst({ | ||
select: { | ||
id: true, | ||
slug: true, | ||
title: true, | ||
description: true, | ||
timestampCreated: true, | ||
timestampUpdated: true, | ||
imageUrl: true, | ||
readMore: true, | ||
author: { | ||
select: { | ||
firstName: true, | ||
} | ||
} | ||
}, | ||
where: { | ||
slug: req.params.slug | ||
} | ||
}); | ||
rep.send(articles) | ||
} |
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,38 @@ | ||
import { getMessaging } from "firebase-admin/messaging"; | ||
import { app } from "../../api/index" | ||
import { prisma } from "../db/client"; | ||
|
||
export const RegisterTokenHandler = async(req: any, rep: any) => { | ||
getMessaging(app).subscribeToTopic(req.body.token, "edd-app"); | ||
const token = await prisma.notificationToken.create({ | ||
data: { | ||
token: req.body.token, | ||
user: { | ||
connect: { | ||
id: +req.user.id | ||
} | ||
}, | ||
timestamp: new Date().toISOString(), | ||
} | ||
}) | ||
rep.status(200); | ||
} | ||
|
||
export const PushNotificationHandler = async(req: any, rep: any) => { | ||
|
||
const id = await getMessaging(app).send({ | ||
topic: 'edd-app', | ||
webpush: { | ||
notification: { | ||
title: req.body.title || "", | ||
body: req.body.body || "", | ||
badge: req.body.photo || "", | ||
icon: req.body.photo || "", | ||
}, | ||
fcmOptions: { | ||
link: req.body.link || "", | ||
} | ||
} | ||
}) | ||
rep.send(id); | ||
} |
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.