import { Database } from './index' ; import jwt from 'jsonwebtoken' ; require ( 'dotenv' ) . config ( ) ; param user export const generateToken = ( user ) : string => { const u = { username : user . username , playerID : user . playerID , creationDate : user . creationDate , } ; return jwt . sign ( u , process . env . JWT_SECRET , { expiresIn : 7 * 60 * 60 * 24 , } ) ; } ; param token export async function verify ( token ) { return new Promise ( ( resolve , reject ) => { jwt . verify ( token , process . env . JWT_SECRET , ( err , user ) => { if ( err ) reject ( err ) ; resolve ( user ) ; } ) ; } ) ; }