Skip to content

Commit

Permalink
change api route name, better logging, require bearer token
Browse files Browse the repository at this point in the history
  • Loading branch information
ggnine-jito committed Jan 8, 2024
1 parent 1fdc8c4 commit fb8eecd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { withSentry } from '@sentry/nextjs'
import { runNotifier } from '../../scripts/governance-notifier'

async function handler(req, res) {
// if (req?.headers?.authorization !== `Bearer ${process.env.CRON_SECRET}`) {
// return res.status(401).send('Unauthorized')
// }
if (req?.headers?.authorization !== `Bearer ${process.env.CRON_SECRET}`) {
return res.status(401).send('Unauthorized')
}
try {
await runNotifier()
res.status(200).send('Notifier executed successfully')
Expand Down
1 change: 1 addition & 0 deletions scripts/governance-notifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export async function runNotifier() {
}

if (!webhookTriggered && process.env.WEBHOOK_URL) {
console.log("Nothing to Report")
axios.post(process.env.WEBHOOK_URL, { content: 'Nothing to Report' })
}

Expand Down
2 changes: 1 addition & 1 deletion vercel.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"crons": [
{
"path": "/api/governance-notifier",
"path": "/api/gov-notifier",
"schedule": "*/10 * * * *"
}
]
Expand Down

0 comments on commit fb8eecd

Please sign in to comment.