Skip to content

Commit

Permalink
Complete API key verify route.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZandercraftGames committed Sep 27, 2023
1 parent c647ffe commit 6a533a5
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,28 @@ router.get('/modpack/:slug/:build?', (req, res) => {
})

router.get('/verify/:key?', (req, res) => {
// Key validated
res.json({
valid: 'Key validated.',
name: 'API KEY',
created_at: 'A long time ago'
})
let api_key = req.params?.key

// Invalid key provided
// res.json({
// error: 'Invalid key provided.'
// })

// No key provided
// res.json({
// error: 'No API key provided.'
// })
if (api_key !== undefined) {
if (api_key === process.env?.API_KEY)
// Key validated
res.json({
valid: 'Key validated.',
name: 'API KEY',
created_at: 'A long time ago'
})
else {
// Invalid key provided
res.json({
error: 'Invalid key provided.'
})
}
} else {
// No key provided
res.json({
error: 'No API key provided.'
})
}
})

/* Invalid API Routes */
Expand Down

0 comments on commit 6a533a5

Please sign in to comment.