Upload files to "/"
first commit
This commit is contained in:
+25
@@ -0,0 +1,25 @@
|
||||
FROM node:20-alpine
|
||||
|
||||
# Install Nginx to serve static frontend
|
||||
RUN apk add --no-cache nginx
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy application files
|
||||
COPY index.html /usr/share/nginx/html/index.html
|
||||
COPY generate-meet.js /app/generate-meet.js
|
||||
|
||||
# Configure Nginx default site to serve index.html on port 80
|
||||
RUN echo 'server { \
|
||||
listen 80; \
|
||||
location / { \
|
||||
root /usr/share/nginx/html; \
|
||||
index index.html; \
|
||||
} \
|
||||
}' > /etc/nginx/http.d/default.conf
|
||||
|
||||
# Expose HTTP frontend port (80) and Backend API port (8585)
|
||||
EXPOSE 80 8585
|
||||
|
||||
# Launch Nginx in background and run Node backend on port 8585
|
||||
CMD ["sh", "-c", "nginx && node /app/generate-meet.js 8585"]
|
||||
@@ -0,0 +1,7 @@
|
||||
# 1. Build the Docker image
|
||||
docker build -t meet-generator .
|
||||
|
||||
# 2. Run the container mapping frontend (9595) and backend (8585) ports
|
||||
docker run -d --name google-meet-app -v "$(pwd)/index.html:/usr/share/nginx/html/index.html" -p 9595:80 -p 8585:8585 meet-generator
|
||||
|
||||
# 3. Access the public url http://localhost:9595/
|
||||
@@ -0,0 +1,112 @@
|
||||
const http = require('http');
|
||||
// generate-meet.js
|
||||
|
||||
// 1. CONFIGURATION - Paste your keys here
|
||||
const CLIENT_ID = '977481853112-pdqmfvqcgnnuqbrbi88r84mgv14mqbq8.apps.googleusercontent.com';
|
||||
const CLIENT_SECRET = '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';
|
||||
const REFRESH_TOKEN = '1//04hBu9T1sojSVCgYIARAAGAQSNwF-L9IrXYktOSabjSSDtaBVKW3xRaqYKhp3x7brpaMAvcBK5rNNj2cQQMTuk0_HTkQWnJ2maLo';
|
||||
|
||||
const PORT = process.argv[2] || process.env.PORT || 3000;
|
||||
|
||||
// access token: ya29.a0AT3oNZ_5YKJidHRWMmuU7hvgcbXyNH6xttPtx2eMj0pBXPbeElKdOVOBEblX9-oVAcIjBxPlZF3yfm56lakEfu4guLDxGX4oPUxUnArEje425vee0ZvyV9ZObIvCrVhht5wD9lsR7cmg78JUE10dvfY2J9ebWZluwEMSChtIY4tk5FdyGa8sKqXyD0yTRheuYIOkR5kaCgYKAb4SARQSFQHGX2MiT1ih_xx7ZmodLXopYQ3zsw0206
|
||||
/**
|
||||
* Step 1: Silently exchange the permanent Refresh Token for a temporary 1-hour Access Token
|
||||
*/
|
||||
async function getAccessToken() {
|
||||
const response = await fetch('https://oauth2.googleapis.com/token', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
client_id: CLIENT_ID,
|
||||
client_secret: CLIENT_SECRET,
|
||||
refresh_token: REFRESH_TOKEN,
|
||||
grant_type: 'refresh_token'
|
||||
})
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
if (!response.ok) {
|
||||
throw new Error(`Token Refresh Failed: ${data.error_description || data.error}`);
|
||||
}
|
||||
return data.access_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 2: Use the Access Token to create an OPEN meeting space (no knocking required)
|
||||
*/
|
||||
async function createOpenMeetSpace(accessToken) {
|
||||
const response = await fetch('https://meet.googleapis.com/v2/spaces', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${accessToken}`,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
// "accessType: OPEN" makes sure anyone clicking this link enters instantly without waiting in a lobby
|
||||
body: JSON.stringify({
|
||||
config: {
|
||||
accessType: "OPEN"
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
if (!response.ok) {
|
||||
throw new Error(`Meet API Error: ${data.error.message}`);
|
||||
}
|
||||
return data.meetingUri;
|
||||
}
|
||||
|
||||
// 3. HTTP SERVER SETUP
|
||||
const server = http.createServer(async (req, res) => {
|
||||
// Enable CORS headers so your frontend script can call this server
|
||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
|
||||
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
|
||||
|
||||
// Handle browser CORS preflight check
|
||||
if (req.method === 'OPTIONS') {
|
||||
res.writeHead(200);
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
|
||||
// Server endpoint matching /webhook/new-meet
|
||||
if (req.url === '/webhook/new-meet' || req.url === '/generate-meet') {
|
||||
try {
|
||||
console.log(`[${new Date().toISOString()}] 🔄 Connecting to Google Cloud...`);
|
||||
const accessToken = await getAccessToken();
|
||||
|
||||
console.log(`[${new Date().toISOString()}] 🚀 Creating open Google Meet room...`);
|
||||
const meetLink = await createOpenMeetSpace(accessToken);
|
||||
|
||||
console.log(`[${new Date().toISOString()}] 🎉 Link generated: ${meetLink}`);
|
||||
|
||||
// Return JSON payload to the frontend
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({
|
||||
success: true,
|
||||
meetLink: meetLink
|
||||
}));
|
||||
|
||||
} catch (error) {
|
||||
console.error(`[${new Date().toISOString()}] ❌ Error:`, error.message);
|
||||
|
||||
res.writeHead(500, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({
|
||||
success: false,
|
||||
error: error.message
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
res.writeHead(404, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({ error: 'Endpoint not found' }));
|
||||
}
|
||||
});
|
||||
|
||||
// Start listening
|
||||
server.listen(PORT, () => {
|
||||
console.log(`=========================================`);
|
||||
console.log(`🚀 Server running at http://localhost:${PORT}`);
|
||||
console.log(`👉 Endpoint: http://localhost:${PORT}/webhook/new-meet`);
|
||||
console.log(`=========================================`);
|
||||
});
|
||||
+211
@@ -0,0 +1,211 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Google Meet Generator</title>
|
||||
<style>
|
||||
/* Page Styling */
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: #f4f7f6;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Modal Overlay */
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
backdrop-filter: blur(4px);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.modal-overlay.active {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
/* Modal Card */
|
||||
.modal-card {
|
||||
background: #ffffff;
|
||||
border-radius: 12px;
|
||||
padding: 24px;
|
||||
width: 90%;
|
||||
max-width: 480px;
|
||||
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
|
||||
position: relative;
|
||||
transform: translateY(20px);
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.modal-overlay.active .modal-card {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.modal-card h2 {
|
||||
margin-top: 0;
|
||||
font-size: 20px;
|
||||
color: #202124;
|
||||
}
|
||||
|
||||
/* Important Notice Box */
|
||||
.notice-box {
|
||||
background-color: #e8f0fe;
|
||||
border-left: 4px solid #1a73e8;
|
||||
border-radius: 4px;
|
||||
padding: 12px 14px;
|
||||
margin: 16px 0;
|
||||
font-size: 13px;
|
||||
color: #1f1f1f;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.notice-box ul {
|
||||
margin: 8px 0 0 0;
|
||||
padding-left: 18px;
|
||||
}
|
||||
|
||||
/* Styled Input + Copy Button */
|
||||
.input-group {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
.input-group input {
|
||||
flex: 1;
|
||||
padding: 10px 14px;
|
||||
border: 1px solid #dadce0;
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
outline: none;
|
||||
background: #f8f9fa;
|
||||
color: #3c4043;
|
||||
}
|
||||
|
||||
.input-group input.error {
|
||||
color: #d93025;
|
||||
border-color: #d93025;
|
||||
background-color: #fce8e6;
|
||||
}
|
||||
|
||||
.copy-btn {
|
||||
padding: 10px 18px;
|
||||
background-color: #34a853;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.copy-btn:disabled {
|
||||
background-color: #ccc;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.copy-btn:hover:not(:disabled) {
|
||||
background-color: #2d8e47;
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
right: 16px;
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
color: #5f6368;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- Popup Overlay -->
|
||||
<div class="modal-overlay" id="modalOverlay">
|
||||
<div class="modal-card">
|
||||
<button class="close-btn" id="closeBtn">×</button>
|
||||
<h2>Public Google Meet Link</h2>
|
||||
|
||||
<!-- User Guidelines / Description Notice -->
|
||||
<div class="notice-box">
|
||||
<strong>Important Usage Guidelines:</strong>
|
||||
<ul>
|
||||
<li>This public link should be used for urgent customer communications, mainly for high-priority incidents or service requests.</li>
|
||||
<li>If you only wish to chat, join the meeting room with your camera and microphone disabled.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<p style="font-size: 13px; color: #5f6368; margin: 0;">Your generated Google Meet link:</p>
|
||||
|
||||
<div class="input-group">
|
||||
<input type="text" id="meetUrlInput" readonly value="Generating link..." />
|
||||
<button class="copy-btn" id="copyBtn" disabled>Copy</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const modalOverlay = document.getElementById('modalOverlay');
|
||||
const closeBtn = document.getElementById('closeBtn');
|
||||
const meetUrlInput = document.getElementById('meetUrlInput');
|
||||
const copyBtn = document.getElementById('copyBtn');
|
||||
|
||||
window.addEventListener('DOMContentLoaded', async () => {
|
||||
modalOverlay.classList.add('active');
|
||||
meetUrlInput.value = 'Generating link...';
|
||||
copyBtn.disabled = true;
|
||||
|
||||
try {
|
||||
const response = await fetch('http://localhost:8585/webhook/new-meet', {
|
||||
method: 'POST'
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
meetUrlInput.value = data.meetLink;
|
||||
meetUrlInput.classList.remove('error');
|
||||
copyBtn.disabled = false;
|
||||
} else {
|
||||
meetUrlInput.value = 'Error: ' + (data.error || 'Failed to generate meeting link');
|
||||
meetUrlInput.classList.add('error');
|
||||
copyBtn.disabled = true;
|
||||
}
|
||||
} catch (err) {
|
||||
meetUrlInput.value = 'Error: Could not connect to backend server';
|
||||
meetUrlInput.classList.add('error');
|
||||
copyBtn.disabled = true;
|
||||
}
|
||||
});
|
||||
|
||||
closeBtn.addEventListener('click', () => {
|
||||
modalOverlay.classList.remove('active');
|
||||
});
|
||||
|
||||
copyBtn.addEventListener('click', () => {
|
||||
if (!meetUrlInput.value || meetUrlInput.classList.contains('error')) return;
|
||||
|
||||
navigator.clipboard.writeText(meetUrlInput.value);
|
||||
copyBtn.textContent = 'Copied!';
|
||||
setTimeout(() => {
|
||||
copyBtn.textContent = 'Copy';
|
||||
}, 2000);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user