Compare commits

...

13 Commits

Author SHA1 Message Date
Jonas Schell
8c748e4144 Merge branch 'main' into test-pages-deployment 2024-08-26 11:19:50 +02:00
Jonas Schell
aa921d911c move runtime export to the bottom of the file 2024-08-23 12:14:09 +02:00
Jonas Schell
05c923206f remove crypto dependency 2024-08-23 11:09:30 +02:00
Jonas Schell
40b44fa14e add runtime export 2024-08-23 10:44:14 +02:00
Jonas Schell
fa5a38d6a8 Merge branch 'main' into test-pages-deployment 2024-08-23 10:35:17 +02:00
Jonas Schell
383428125d chore: Update NEXT_PUBLIC_LK_TOKEN_ENDPOINT in wrangler.toml configuration file 2024-08-23 10:31:19 +02:00
Jonas Schell
710a7ac6d1 chore: Update wrangler.toml configuration file 2024-08-23 10:28:57 +02:00
Jonas Schell
66be5cd4a6 update wrangler.toml 2024-08-22 13:49:17 +02:00
Jonas Schell
fd2204d829 chore: Update wrangler.toml configuration file 2024-08-22 13:36:32 +02:00
Jonas Schell
4e82693238 add cloudflare build and preview scripts 2024-08-22 12:12:46 +02:00
Jonas Schell
15e862533d cloudflare config 2024-08-22 11:43:48 +02:00
Jonas Schell
7978271f0f chore: Add wrangler.toml configuration file 2024-08-22 11:33:35 +02:00
Jonas Schell
370fc9a47e add dependency to @cloudflare/next-on-pages v1.13.2 2024-08-22 11:32:01 +02:00
11 changed files with 2724 additions and 11 deletions

3
.gitignore vendored
View File

@ -36,3 +36,6 @@ yarn-error.log*
# typescript
*.tsbuildinfo
# cloudflare
.wrangler

View File

@ -1,5 +1,4 @@
import { ConnectionDetails } from '@/lib/types';
import { randomUUID } from 'crypto';
import { AccessToken, AccessTokenOptions, VideoGrant } from 'livekit-server-sdk';
import { NextRequest, NextResponse } from 'next/server';
@ -29,7 +28,7 @@ export async function GET(request: NextRequest) {
// Generate participant token
const participantToken = await createParticipantToken(
{
identity: `${participantName}__${randomUUID()}`,
identity: pseudoRandomParticipantId(participantName),
name: participantName,
metadata,
},
@ -65,6 +64,15 @@ function createParticipantToken(userInfo: AccessTokenOptions, roomName: string)
return at.toJwt();
}
function pseudoRandomParticipantId(participantName: string): string {
const randomPart = 'xxxx-xxxx-xxxx'.replace(/[x]/g, function (c) {
const r = (Math.random() * 16) | 0;
const v = c === 'x' ? r : (r & 0x3) | 0x8;
return `${v.toString(16)}`;
});
return `${participantName}_${randomPart}`;
}
/**
* Get the LiveKit server URL for the given region.
*/
@ -79,3 +87,5 @@ function getLiveKitURL(region: string | null): string {
}
return url;
}
export const runtime = 'edge'; // Can be removed if not deploying to Edge Runtime. See https://nextjs.org/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes

View File

@ -68,3 +68,5 @@ export async function GET(req: NextRequest) {
}
}
}
export const runtime = 'edge'; // Can be removed if not deploying to Edge Runtime. See https://nextjs.org/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes

View File

@ -37,3 +37,5 @@ export async function GET(req: NextRequest) {
}
}
}
export const runtime = 'edge'; // Can be removed if not deploying to Edge Runtime. See https://nextjs.org/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes

View File

@ -26,3 +26,5 @@ export default function CustomRoomConnection(props: {
</main>
);
}
export const runtime = 'edge'; // Can be removed if not deploying to Edge Runtime. See https://nextjs.org/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes

View File

@ -199,3 +199,5 @@ export default function Page() {
</>
);
}
export const runtime = 'edge'; // Can be removed if not deploying to Edge Runtime. See https://nextjs.org/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes

View File

@ -24,3 +24,5 @@ export default function Page({
<PageClientImpl roomName={params.roomName} region={searchParams.region} hq={hq} codec={codec} />
);
}
export const runtime = 'edge'; // Can be removed if not deploying to Edge Runtime. See https://nextjs.org/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes

View File

@ -1,3 +1,5 @@
import { setupDevPlatform } from '@cloudflare/next-on-pages/next-dev';
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: false,
@ -13,4 +15,10 @@ const nextConfig = {
},
};
module.exports = nextConfig;
// This allows you to access Cloudflare bindings in local development.
// Ignore this, you probably don't need it.
if (process.env.NODE_ENV === 'development') {
await setupDevPlatform();
}
export default nextConfig;

View File

@ -6,7 +6,9 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"pages:build": "pnpm dlx @cloudflare/next-on-pages",
"preview": "pnpm pages:build && pnpm --package=wrangler dlx wrangler pages dev"
},
"dependencies": {
"@datadog/browser-logs": "^5.10.0",
@ -22,6 +24,7 @@
"tinykeys": "^2.1.0"
},
"devDependencies": {
"@cloudflare/next-on-pages": "^1.13.2",
"@types/node": "20.14.13",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",

2683
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

10
wrangler.toml Normal file
View File

@ -0,0 +1,10 @@
# Generated by Wrangler on Thu Aug 22 2024 13:43:56 GMT+0200 (Central European Summer Time)
name = "meet-sandbox-staging"
pages_build_output_dir = ".vercel/output/static"
compatibility_date = "2024-08-22"
compatibility_flags = [ "nodejs_compat" ]
send_metrics = false
[vars]
NEXT_PUBLIC_LK_TOKEN_ENDPOINT = "/api/token"
NEXT_PUBLIC_SHOW_SETTINGS_MENU = "true"