diff options
author | mat <27899617+mat-1@users.noreply.github.com> | 2021-02-13 15:03:13 -0600 |
---|---|---|
committer | mat <27899617+mat-1@users.noreply.github.com> | 2021-02-13 15:03:13 -0600 |
commit | 8d2722bdd81591feef14dd4ccdf99ac9c1309925 (patch) | |
tree | e3d4f49ad705b1ef085d0425568f0e4e6b5d610e /src/index.ts | |
parent | e9bd7f931e071311ff9a3b83673042f8da352554 (diff) | |
download | skyblock-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.ts | 10 |
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 :)')) |