From 3fc13eb0626572d9caf977e3b65e8d527ee644e0 Mon Sep 17 00:00:00 2001 From: Alex Kern Date: Fri, 27 Dec 2024 00:05:17 -0800 Subject: [PATCH] format --- src/app/api/create/route.ts | 5 ++++- src/channel.ts | 16 ++++++---------- src/components/ErrorMessage.tsx | 2 +- src/components/ThemeProvider.tsx | 2 +- src/components/WebRTCProvider.tsx | 7 ++++++- src/hooks/useUploaderChannel.ts | 12 ++++++++---- 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/app/api/create/route.ts b/src/app/api/create/route.ts index 830fcf2..7ee9944 100644 --- a/src/app/api/create/route.ts +++ b/src/app/api/create/route.ts @@ -5,7 +5,10 @@ export async function POST(request: Request): Promise { const { uploaderPeerID } = await request.json() if (!uploaderPeerID) { - return NextResponse.json({ error: 'Uploader peer ID is required' }, { status: 400 }) + return NextResponse.json( + { error: 'Uploader peer ID is required' }, + { status: 400 }, + ) } const channel: Channel = await channelRepo.createChannel(uploaderPeerID) diff --git a/src/channel.ts b/src/channel.ts index 239ae62..594d64f 100644 --- a/src/channel.ts +++ b/src/channel.ts @@ -20,16 +20,9 @@ const ChannelSchema = z.object({ }) export interface ChannelRepo { - createChannel( - uploaderPeerID: string, - ttl?: number, - ): Promise + createChannel(uploaderPeerID: string, ttl?: number): Promise fetchChannel(slug: string): Promise - renewChannel( - slug: string, - secret: string, - ttl: number, - ): Promise + renewChannel(slug: string, secret: string, ttl: number): Promise destroyChannel(slug: string, secret: string): Promise } @@ -61,7 +54,10 @@ export class RedisChannelRepo implements ChannelRepo { return channel } - async fetchChannel(slug: string, scrubSecret = false): Promise { + async fetchChannel( + slug: string, + scrubSecret = false, + ): Promise { const shortChannelStr = await this.client.get(this.getShortSlugKey(slug)) if (shortChannelStr) { return this.deserializeChannel(shortChannelStr, scrubSecret) diff --git a/src/components/ErrorMessage.tsx b/src/components/ErrorMessage.tsx index 702ca70..84b965b 100644 --- a/src/components/ErrorMessage.tsx +++ b/src/components/ErrorMessage.tsx @@ -7,4 +7,4 @@ export function ErrorMessage({ message }: { message: string }): JSX.Element { {message} ) -} \ No newline at end of file +} diff --git a/src/components/ThemeProvider.tsx b/src/components/ThemeProvider.tsx index 83ff228..725ba5f 100644 --- a/src/components/ThemeProvider.tsx +++ b/src/components/ThemeProvider.tsx @@ -4,4 +4,4 @@ import * as React from 'react' import { ThemeProvider as NextThemesProvider } from 'next-themes' export type ThemeProviderProps = Parameters[0] -export const ThemeProvider = NextThemesProvider as React.FC \ No newline at end of file +export const ThemeProvider = NextThemesProvider as React.FC diff --git a/src/components/WebRTCProvider.tsx b/src/components/WebRTCProvider.tsx index 324aaa4..a087b01 100644 --- a/src/components/WebRTCProvider.tsx +++ b/src/components/WebRTCProvider.tsx @@ -5,7 +5,12 @@ import Loading from './Loading' import Peer from 'peerjs' const ICE_SERVERS: RTCConfiguration = { - iceServers: [{ urls: process.env.NEXT_PUBLIC_STUN_SERVER ?? 'stun:stun.l.google.com:19302' }], + iceServers: [ + { + urls: + process.env.NEXT_PUBLIC_STUN_SERVER ?? 'stun:stun.l.google.com:19302', + }, + ], } export type WebRTCValue = Peer diff --git a/src/hooks/useUploaderChannel.ts b/src/hooks/useUploaderChannel.ts index d922a6c..67204d0 100644 --- a/src/hooks/useUploaderChannel.ts +++ b/src/hooks/useUploaderChannel.ts @@ -63,7 +63,13 @@ export function useUploaderChannel( }) const answerMutation = useMutation({ - mutationFn: async ({ offerID, answer }: { offerID: string, answer: RTCSessionDescriptionInit }) => { + mutationFn: async ({ + offerID, + answer, + }: { + offerID: string + answer: RTCSessionDescriptionInit + }) => { const response = await fetch('/api/answer', { method: 'POST', headers: { 'Content-Type': 'application/json' }, @@ -83,9 +89,7 @@ export function useUploaderChannel( const run = (): void => { timeout = setTimeout(() => { - renewMutation.mutate( - { secret }, - ) + renewMutation.mutate({ secret }) run() }, renewInterval) }