import { authorize } from "@liveblocks/node" ; import { NextApiRequest , NextApiResponse } from "next" ; const API_KEY = process . env . LIVEBLOCKS_SECRET_KEY ; export default async function auth ( req , res ) { if ( ! API_KEY ) { return res . status ( 403 ) . end ( ) ; } const response = await authorize ( { room : req . body . room , secret : API_KEY , userInfo : { name : NAMES [ Math . floor ( Math . random ( ) * NAMES . length ) ] , picture : `/assets/avatars/${ Math . floor ( Math . random ( ) * 10 ) }.png` , } , } ) ; return res . status ( response . status ) . end ( response . body ) ; } const NAMES = [ "Charlie Layne" , "Mislav Abha" , "Tatum Paolo" , "Anjali Wanda" , "Jody Hekla" , "Emil Joyce" , "Jory Quispe" , "Quinn Elton" , ] ;