pull/134/head
Alex Kern 12 months ago
parent cb344d153f
commit 3fc13eb062
No known key found for this signature in database
GPG Key ID: EF051FACCACBEE25

@ -5,7 +5,10 @@ export async function POST(request: Request): Promise<NextResponse> {
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)

@ -20,16 +20,9 @@ const ChannelSchema = z.object({
})
export interface ChannelRepo {
createChannel(
uploaderPeerID: string,
ttl?: number,
): Promise<Channel>
createChannel(uploaderPeerID: string, ttl?: number): Promise<Channel>
fetchChannel(slug: string): Promise<Channel | null>
renewChannel(
slug: string,
secret: string,
ttl: number,
): Promise<boolean>
renewChannel(slug: string, secret: string, ttl: number): Promise<boolean>
destroyChannel(slug: string, secret: string): Promise<void>
}
@ -61,7 +54,10 @@ export class RedisChannelRepo implements ChannelRepo {
return channel
}
async fetchChannel(slug: string, scrubSecret = false): Promise<Channel | null> {
async fetchChannel(
slug: string,
scrubSecret = false,
): Promise<Channel | null> {
const shortChannelStr = await this.client.get(this.getShortSlugKey(slug))
if (shortChannelStr) {
return this.deserializeChannel(shortChannelStr, scrubSecret)

@ -7,4 +7,4 @@ export function ErrorMessage({ message }: { message: string }): JSX.Element {
<span className="block sm:inline">{message}</span>
</div>
)
}
}

@ -4,4 +4,4 @@ import * as React from 'react'
import { ThemeProvider as NextThemesProvider } from 'next-themes'
export type ThemeProviderProps = Parameters<typeof NextThemesProvider>[0]
export const ThemeProvider = NextThemesProvider as React.FC<ThemeProviderProps>
export const ThemeProvider = NextThemesProvider as React.FC<ThemeProviderProps>

@ -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

@ -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)
}

Loading…
Cancel
Save