1
0
Fork 0

add info route

refactor/models
Matthew 2020-11-08 01:54:09 -05:00
parent c9ff543c26
commit 67dd68ecfa
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
1 changed files with 15 additions and 0 deletions

View File

@ -56,6 +56,21 @@ export default class Webhook extends Route {
return res.sendStatus(200); return res.sendStatus(200);
}); });
this.router.get('/info', async (req, res) => {
if (req.query?.authorization !== this.server.security.keys.internal.toString('hex')) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
if (!req.query?.id) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR });
const account = await this.server.client.db.Account.findOne({ userID: req.query.id.toString() }).lean().exec();
if (!account) return res.status(200).send({ found: false });
return res.status(200).send({
found: true,
emailAddress: account.emailAddress,
tier: account.tier,
supportKey: account.supportKey,
});
});
this.router.get('/score', async (req, res) => { this.router.get('/score', async (req, res) => {
try { try {
if (req.query?.authorization !== this.server.security.keys.internal.toString('hex')) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED }); if (req.query?.authorization !== this.server.security.keys.internal.toString('hex')) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });