Skip to content

Commit

Permalink
feat: create a pass utils class (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
aahna-ashina committed May 23, 2022
1 parent d7ed197 commit 4c5fc53
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
12 changes: 9 additions & 3 deletions server/pages/api/pushNotification.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NextApiRequest, NextApiResponse } from "next"
import basicAuthCheck from "../../utils/basicAuthCheck"
import { Passes } from "../../utils/Passes"

async function performBasicAuth(req: NextApiRequest, res: NextApiResponse) {
console.log('performBasicAuth')
Expand Down Expand Up @@ -41,9 +42,14 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
const trimmedContent = String(content).trim()

// Push notification
// TODO

res.status(response.statusCode).json({ text: '// TODO' })
const notificationSent: boolean = Passes.pushNotification(trimmedTitle, trimmedContent);
console.log('notificationSent:', notificationSent)

res.status(response.statusCode).json({
notificationSent: notificationSent,
title: trimmedTitle,
content: trimmedContent
})
}
})
}
20 changes: 20 additions & 0 deletions server/utils/Passes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export class Passes {

/**
* Pushes a notification to all the passes
*/
static pushNotification(title: string, content: string): boolean {
console.log('pushNotification')

console.log(`title: "${title}"`)
console.log(`content: "${content}"`)

// Get the list of registered passes
// TODO

// For each registered pass, push the notification
// TODO

return true
}
}

0 comments on commit 4c5fc53

Please sign in to comment.