fix: include service token in the debug route * fix: include service token in the debug route Approved-by: Bianca Widstam Approved-by: Hrishikesh Vaipurkar
27 lines
647 B
TypeScript
27 lines
647 B
TypeScript
import { notFound } from "next/navigation"
|
|
import { NextResponse } from "next/server"
|
|
|
|
import { getServiceToken } from "@scandic-hotels/common/tokenManager"
|
|
|
|
import { env } from "@/env/server"
|
|
|
|
import { auth } from "@/auth"
|
|
|
|
export const GET = async () => {
|
|
if (env.NODE_ENV !== "development") {
|
|
return notFound()
|
|
}
|
|
|
|
const user = await auth()
|
|
const serviceToken = await getServiceToken()
|
|
|
|
const sortedEnv = Object.keys(env)
|
|
.sort()
|
|
.reduce<Record<string, unknown>>((acc, key) => {
|
|
acc[key] = env[key as keyof typeof env]
|
|
return acc
|
|
}, {})
|
|
|
|
return NextResponse.json({ user, serviceToken, env: sortedEnv })
|
|
}
|