import { NextApiRequest , NextApiResponse } from 'next' ; import firebase from 'firebase' ; import firebaseAdmin from '@utils/auth/admin' ; const handler = async ( req , res ) => { const session = req . cookies ! . session ; const CHECK_REVOKED = true ; const me = await firebaseAdmin . auth ( ) . verifySessionCookie ( session , CHECK_REVOKED ) . then ( async ( claims ) => { return ( await firebaseAdmin . auth ( ) . getUser ( claims . uid ) ) ; } ) . catch ( ( error ) => { res . status ( 401 ) . json ( { 'message' : error . message } ) ; throw Error ( error . message ) ; } ) ; res . statusCode = 200 ; res . setHeader ( 'Content-Type' , 'application/json' ) ; res . end ( JSON . stringify ( me . toJSON ( ) ) ) ; } ; export default handler ;