import * as Hapi from '@hapi/hapi' ; import * as Joi from 'joi' ; import { verifyToken } from '@auth/features/verifyToken/service' ; import { internal } from '@hapi/boom' ; interface IVerifyTokenPayload { token : string ; } export default async function verifyTokenHandler ( request , h ) { const { token } = request . payload as IVerifyTokenPayload ; let valid = false ; try { valid = await verifyToken ( token ) ; } catch ( err ) { throw internal ( 'Failed to verifyToken token' , err ) ; } return { valid } ; } export const reqVerifyTokenSchema = Joi . object ( { token : Joi . string ( ) } ) ; export const resVerifyTokenSchema = Joi . object ( { valid : Joi . boolean ( ) } ) ;