summary refs log tree commit diff
path: root/src/util/checkToken.ts
blob: b4635126476db363b3d081d6f28b711416159240 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
import { JWTOptions } from "./Constants";
import jwt from "jsonwebtoken";
import Config from "./Config";

export function checkToken(token: string): Promise<any> {
	return new Promise((res, rej) => {
		jwt.verify(token, Config.getAll().api.security.jwtSecret, JWTOptions, (err, decoded: any) => {
			if (err || !decoded) return rej("Invalid Token");

			return res(decoded);
		});
	});
}