aboutsummaryrefslogtreecommitdiff
path: root/src/index.ts
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2021-02-13 15:03:13 -0600
committermat <27899617+mat-1@users.noreply.github.com>2021-02-13 15:03:13 -0600
commit8d2722bdd81591feef14dd4ccdf99ac9c1309925 (patch)
treee3d4f49ad705b1ef085d0425568f0e4e6b5d610e /src/index.ts
parente9bd7f931e071311ff9a3b83673042f8da352554 (diff)
downloadskyblock-api-8d2722bdd81591feef14dd4ccdf99ac9c1309925.tar.gz
skyblock-api-8d2722bdd81591feef14dd4ccdf99ac9c1309925.tar.bz2
skyblock-api-8d2722bdd81591feef14dd4ccdf99ac9c1309925.zip
add optional check to verify all clients are owned by the creator
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 :)'))