- Add Next.js app structure with base configs, linting, and formatting - Implement LiveKit Meet page, types, and utility functions - Add Docker, Compose, and deployment scripts for backend and token server - Provide E2E and smoke test scaffolding with Puppeteer and Playwright helpers - Include CSS modules and global styles for UI - Add postMessage and studio integration utilities - Update package.json with dependencies and scripts for development and testing
52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
#!/usr/bin/env node
|
|
// Simple script to request an internal session from backend-api
|
|
// Usage: node request_internal_session.js [room] [username] [ttl] [createdBy]
|
|
|
|
const url = process.env.HOST || 'http://localhost:4000';
|
|
const secret = process.env.BACKEND_REGISTER_SECRET || 'devregistersecret';
|
|
const room = process.argv[2] || 'test-room';
|
|
const username = process.argv[3] || 'e2e';
|
|
const ttl = process.argv[4] ? Number(process.argv[4]) : 300;
|
|
const createdBy = process.argv[5] ? Number(process.argv[5]) : undefined;
|
|
|
|
async function main() {
|
|
try {
|
|
if (typeof fetch === 'undefined') {
|
|
// Node older than 18 might not have fetch; try to use node-fetch
|
|
try {
|
|
global.fetch = (await import('node-fetch')).default;
|
|
} catch (e) {
|
|
console.error('Global fetch not available and node-fetch not installed. Please run on Node 18+ or install node-fetch.');
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
const body = { room, username, ttl };
|
|
if (typeof createdBy === 'number') body.createdBy = createdBy;
|
|
|
|
const res = await fetch(`${url}/api/internal/session`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'content-type': 'application/json',
|
|
'x-backend-secret': secret,
|
|
},
|
|
body: JSON.stringify(body),
|
|
});
|
|
|
|
const text = await res.text();
|
|
try {
|
|
console.log(JSON.stringify(JSON.parse(text), null, 2));
|
|
} catch (e) {
|
|
console.log(text);
|
|
}
|
|
|
|
if (!res.ok) process.exit(2);
|
|
} catch (err) {
|
|
console.error('Request failed:', err.message || String(err));
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
main();
|
|
|