v1.6.3/api performance
This commit is contained in:
+12
-14
@@ -1,9 +1,9 @@
|
|||||||
import firebase from "firebase/app";
|
import firebase from 'firebase/app';
|
||||||
import "firebase/auth";
|
import 'firebase/auth';
|
||||||
|
|
||||||
const API = window.location.href.includes("localhost")
|
const API = window.location.href.includes('localhost')
|
||||||
? "http://localhost:5000/watch-party-crx/us-central1/admin"
|
? 'http://localhost:5001/watch-party-crx/us-central1/admin'
|
||||||
: "https://us-central1-watch-party-crx.cloudfunctions.net/admin";
|
: 'https://us-central1-watch-party-crx.cloudfunctions.net/admin';
|
||||||
|
|
||||||
const fetcher = async ({ endpoint, method, bodyData }) => {
|
const fetcher = async ({ endpoint, method, bodyData }) => {
|
||||||
const idToken = await firebase.auth().currentUser.getIdToken();
|
const idToken = await firebase.auth().currentUser.getIdToken();
|
||||||
@@ -12,21 +12,19 @@ const fetcher = async ({ endpoint, method, bodyData }) => {
|
|||||||
method,
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Token ${idToken}:${firebase.auth().currentUser.uid}`,
|
Authorization: `Token ${idToken}:${firebase.auth().currentUser.uid}`,
|
||||||
"Access-Control-Allow-Origin": "*",
|
'Access-Control-Allow-Origin': '*',
|
||||||
},
|
},
|
||||||
body,
|
body,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getPartyDashboardData = () =>
|
export const getPartyDashboardData = () => fetcher({ endpoint: 'partyDashboard', method: 'GET' });
|
||||||
fetcher({ endpoint: "partyDashboard", method: "GET" });
|
export const getServerDashboardData = () => fetcher({ endpoint: 'serverDashboard', method: 'GET' });
|
||||||
export const getServerDashboardData = () =>
|
|
||||||
fetcher({ endpoint: "serverDashboard", method: "GET" });
|
|
||||||
export const postUpdateVersionActive = (bodyData) =>
|
export const postUpdateVersionActive = (bodyData) =>
|
||||||
fetcher({ endpoint: "updateVersionActive", method: "POST", bodyData });
|
fetcher({ endpoint: 'updateVersionActive', method: 'POST', bodyData });
|
||||||
export const postUpdateVideoSelectors = (bodyData) =>
|
export const postUpdateVideoSelectors = (bodyData) =>
|
||||||
fetcher({ endpoint: "updateVideoSelectors", method: "POST", bodyData });
|
fetcher({ endpoint: 'updateVideoSelectors', method: 'POST', bodyData });
|
||||||
export const postUpdateVideoNameSelectors = (bodyData) =>
|
export const postUpdateVideoNameSelectors = (bodyData) =>
|
||||||
fetcher({ endpoint: "updateVideoNameSelectors", method: "POST", bodyData });
|
fetcher({ endpoint: 'updateVideoNameSelectors', method: 'POST', bodyData });
|
||||||
export const postSendMessage = (bodyData) =>
|
export const postSendMessage = (bodyData) =>
|
||||||
fetcher({ endpoint: "sendMessage", method: "POST", bodyData });
|
fetcher({ endpoint: 'sendMessage', method: 'POST', bodyData });
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
const AdminModules = require('./index');
|
||||||
|
const express = require('express');
|
||||||
|
const cors = require('cors');
|
||||||
|
|
||||||
|
require('https').globalAgent.keepAlive = true;
|
||||||
|
|
||||||
|
// ADMIN
|
||||||
|
const admin = express();
|
||||||
|
admin.use(
|
||||||
|
cors({
|
||||||
|
origin: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
admin.use(AdminModules.superAuth);
|
||||||
|
admin.get('/partyDashboard', AdminModules.partyDashboard);
|
||||||
|
admin.get('/serverDashboard', AdminModules.serverDashboard);
|
||||||
|
admin.post('/updateVersionActive', AdminModules.updateVersionActive);
|
||||||
|
admin.post('/updateVideoSelectors', AdminModules.updateVideoSelectors);
|
||||||
|
admin.post('/updateVideoNameSelectors', AdminModules.updateVideoNameSelectors);
|
||||||
|
admin.post('/sendMessage', AdminModules.sendMessage);
|
||||||
|
|
||||||
|
module.exports = admin;
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
const FunctionModules = require("./modules/index");
|
|
||||||
const Webhooks = require("./webhooks/index");
|
|
||||||
const AdminModules = require("./admin/index");
|
|
||||||
const express = require("express");
|
|
||||||
const cors = require("cors");
|
|
||||||
|
|
||||||
// WEBHOOKS
|
|
||||||
const webhooks = express();
|
|
||||||
webhooks.use(cors({ origin: true }));
|
|
||||||
webhooks.all("/conferenceEnded", Webhooks.conferenceEnd);
|
|
||||||
webhooks.all("/scheduledCleanup", Webhooks.scheduledCleanUp);
|
|
||||||
webhooks.all("/ask", Webhooks.ask);
|
|
||||||
webhooks.all("/userCleanUp", Webhooks.userCleanUp);
|
|
||||||
|
|
||||||
// VERSION 1
|
|
||||||
const app = express();
|
|
||||||
app.use(cors({ origin: true }));
|
|
||||||
app.use(FunctionModules.authenticator);
|
|
||||||
app.get("/validator/:partyName", FunctionModules.tokenValidator);
|
|
||||||
app.get("/refresher/:token", FunctionModules.tokenRefresher);
|
|
||||||
app.post("/create", FunctionModules.createRoom);
|
|
||||||
app.post("/join", FunctionModules.joinRoom);
|
|
||||||
app.post("/message", FunctionModules.sendMessage);
|
|
||||||
app.post("/updatePlayer", FunctionModules.updatePlayer);
|
|
||||||
app.post("/updateVoxeet", FunctionModules.updateVoxeet);
|
|
||||||
app.delete("/leave/:rid/users/:uid", FunctionModules.leaveRoom);
|
|
||||||
app.delete("/delete/:rid", FunctionModules.deleteRoom);
|
|
||||||
app.put("/updateAdminOnly/:rid/:adminOnly", FunctionModules.updateAdminOnly);
|
|
||||||
|
|
||||||
// ADMIN
|
|
||||||
const admin = express();
|
|
||||||
admin.use(
|
|
||||||
cors({
|
|
||||||
origin: true,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
admin.use(AdminModules.superAuth);
|
|
||||||
admin.get("/partyDashboard", AdminModules.partyDashboard);
|
|
||||||
admin.get("/serverDashboard", AdminModules.serverDashboard);
|
|
||||||
admin.post("/updateVersionActive", AdminModules.updateVersionActive);
|
|
||||||
admin.post("/updateVideoSelectors", AdminModules.updateVideoSelectors);
|
|
||||||
admin.post("/updateVideoNameSelectors", AdminModules.updateVideoNameSelectors);
|
|
||||||
admin.post("/sendMessage", AdminModules.sendMessage);
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
v1: app,
|
|
||||||
webhooks,
|
|
||||||
admin,
|
|
||||||
};
|
|
||||||
|
|||||||
+18
-4
@@ -1,7 +1,8 @@
|
|||||||
const functions = require('firebase-functions');
|
const functions = require('firebase-functions');
|
||||||
const secret = require('./FirebaseSecret.json');
|
const secret = require('./FirebaseSecret.json');
|
||||||
const admin = require('firebase-admin');
|
const admin = require('firebase-admin');
|
||||||
const REST = require('./app');
|
|
||||||
|
require('https').globalAgent.keepAlive = true;
|
||||||
|
|
||||||
const FIREBASE_OPTIONS = {
|
const FIREBASE_OPTIONS = {
|
||||||
credential: admin.credential.cert(secret),
|
credential: admin.credential.cert(secret),
|
||||||
@@ -10,9 +11,22 @@ const FIREBASE_OPTIONS = {
|
|||||||
|
|
||||||
admin.initializeApp(FIREBASE_OPTIONS);
|
admin.initializeApp(FIREBASE_OPTIONS);
|
||||||
|
|
||||||
|
let WidgetsReceiver;
|
||||||
|
let WebhooksReceiver;
|
||||||
|
let AdminReceiver;
|
||||||
|
|
||||||
// VERSION 1
|
// VERSION 1
|
||||||
exports.widgets = functions.https.onRequest(REST.v1);
|
exports.widgets = functions.https.onRequest((req, res) => {
|
||||||
|
if (!WidgetsReceiver) WidgetsReceiver = require('./modules/app');
|
||||||
|
return WidgetsReceiver(req, res);
|
||||||
|
});
|
||||||
// WEBHOOKS
|
// WEBHOOKS
|
||||||
exports.webhooks = functions.https.onRequest(REST.webhooks);
|
exports.webhooks = functions.https.onRequest((req, res) => {
|
||||||
|
if (!WebhooksReceiver) WebhooksReceiver = require('./webhooks/app');
|
||||||
|
return WebhooksReceiver(req, res);
|
||||||
|
});
|
||||||
// ADMIN
|
// ADMIN
|
||||||
exports.admin = functions.https.onRequest(REST.admin);
|
exports.admin = functions.https.onRequest((req, res) => {
|
||||||
|
if (!AdminReceiver) AdminReceiver = require('./admin/app');
|
||||||
|
return AdminReceiver(req, res);
|
||||||
|
});
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
const FunctionModules = require('./index');
|
||||||
|
const express = require('express');
|
||||||
|
const cors = require('cors');
|
||||||
|
|
||||||
|
require('https').globalAgent.keepAlive = true;
|
||||||
|
|
||||||
|
// VERSION 1
|
||||||
|
const app = express();
|
||||||
|
app.use(cors({ origin: true }));
|
||||||
|
app.use(FunctionModules.authenticator);
|
||||||
|
app.get('/validator/:partyName', FunctionModules.tokenValidator);
|
||||||
|
app.get('/refresher/:token', FunctionModules.tokenRefresher);
|
||||||
|
app.post('/create', FunctionModules.createRoom);
|
||||||
|
app.post('/join', FunctionModules.joinRoom);
|
||||||
|
app.post('/message', FunctionModules.sendMessage);
|
||||||
|
app.post('/updatePlayer', FunctionModules.updatePlayer);
|
||||||
|
app.post('/updateVoxeet', FunctionModules.updateVoxeet);
|
||||||
|
app.delete('/leave/:rid/users/:uid', FunctionModules.leaveRoom);
|
||||||
|
app.delete('/delete/:rid', FunctionModules.deleteRoom);
|
||||||
|
app.put('/updateAdminOnly/:rid/:adminOnly', FunctionModules.updateAdminOnly);
|
||||||
|
|
||||||
|
module.exports = app;
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
const WebhookModules = require('./index');
|
||||||
|
const express = require('express');
|
||||||
|
const cors = require('cors');
|
||||||
|
|
||||||
|
require('https').globalAgent.keepAlive = true;
|
||||||
|
|
||||||
|
// WEBHOOKS
|
||||||
|
const webhooks = express();
|
||||||
|
webhooks.use(cors({ origin: true }));
|
||||||
|
webhooks.all('/conferenceEnded', WebhookModules.conferenceEnd);
|
||||||
|
webhooks.all('/scheduledCleanup', WebhookModules.scheduledCleanUp);
|
||||||
|
webhooks.all('/ask', WebhookModules.ask);
|
||||||
|
webhooks.all('/userCleanUp', WebhookModules.userCleanUp);
|
||||||
|
|
||||||
|
module.exports = webhooks;
|
||||||
Reference in New Issue
Block a user