Archnemix commited on
Commit
9a8f7d3
·
verified ·
1 Parent(s): 5aeb8a2

Update src/router.js

Browse files
Files changed (1) hide show
  1. src/router.js +4 -1
src/router.js CHANGED
@@ -65,6 +65,8 @@ router.post('/generate/leave', async (req, res) => {
65
  router.post('/interactions', async (req, res) => {
66
  const signature = req.headers['x-signature-ed25519']
67
  const timestamp = req.headers['x-signature-timestamp']
 
 
68
  const isValid = verifyKey(req.body, signature, timestamp, process.env.DISCORD_PUBLIC_KEY)
69
  if (!isValid) {
70
  console.warn('[interactions] Invalid signature, rejecting request')
@@ -76,10 +78,11 @@ router.post('/interactions', async (req, res) => {
76
 
77
  // PING — respond as fast as possible, no logging before this
78
  if (interaction.type === 1) {
 
79
  return res.status(200).json({ type: 1 })
80
  }
81
 
82
- // All logging happens after PING check so it never delays PONG
83
  console.log('[interactions] Incoming request, headers:', JSON.stringify(req.headers))
84
  console.log('[interactions] Signature valid')
85
  console.log('[interactions] Received interaction type:', interaction.type)
 
65
  router.post('/interactions', async (req, res) => {
66
  const signature = req.headers['x-signature-ed25519']
67
  const timestamp = req.headers['x-signature-timestamp']
68
+
69
+ console.log('[interactions] Verifying signature...')
70
  const isValid = verifyKey(req.body, signature, timestamp, process.env.DISCORD_PUBLIC_KEY)
71
  if (!isValid) {
72
  console.warn('[interactions] Invalid signature, rejecting request')
 
78
 
79
  // PING — respond as fast as possible, no logging before this
80
  if (interaction.type === 1) {
81
+ console.log('[interactions] PING received, sending PONG')
82
  return res.status(200).json({ type: 1 })
83
  }
84
 
85
+ // All other logging happens after PING check so it never delays PONG
86
  console.log('[interactions] Incoming request, headers:', JSON.stringify(req.headers))
87
  console.log('[interactions] Signature valid')
88
  console.log('[interactions] Received interaction type:', interaction.type)