aboutsummaryrefslogtreecommitdiff
path: root/src/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/index.ts b/src/index.ts
index af5095b..4ceda01 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,9 +1,15 @@
import express from 'express'
import { fetchMemberProfile, fetchUser } from './hypixel'
-import { fetchProfile } from './hypixelCached'
const app = express()
+app.use((req, res, next) => {
+ if (process.env.key && req.headers.key !== process.env.key)
+ // if a key is set in process.env and the header doesn't match return an error
+ // TODO: make this have a status code
+ return res.json({ error: 'Key in header must match key in env' })
+ next()
+})
app.get('/', async(req, res) => {
res.json({ ok: true })
@@ -24,4 +30,4 @@ app.get('/player/:user/:profile', async(req, res) => {
)
})
-app.listen(8080, () => console.log('App started :)')) \ No newline at end of file
+app.listen(8080, () => console.log('App started :)'))