v1.6.5/api refactor
This commit is contained in:
+56
-12
@@ -1,22 +1,66 @@
|
||||
const FunctionModules = require('./index');
|
||||
const express = require('express');
|
||||
const cors = require('cors');
|
||||
|
||||
require('https').globalAgent.keepAlive = true;
|
||||
|
||||
let authenticator;
|
||||
let tokenValidator;
|
||||
let tokenRefresher;
|
||||
let createRoom;
|
||||
let joinRoom;
|
||||
let sendMessage;
|
||||
let updatePlayer;
|
||||
let updateVoxeet;
|
||||
let leaveRoom;
|
||||
let deleteRoom;
|
||||
let updateAdminOnly;
|
||||
|
||||
// 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);
|
||||
app.use((req, res, next) => {
|
||||
if (!authenticator) authenticator = require('./authenticator');
|
||||
authenticator(req, res, next);
|
||||
});
|
||||
app.get('/validator/:partyName', (req, res) => {
|
||||
if (!tokenValidator) tokenValidator = require('./tokenValidator');
|
||||
tokenValidator(req, res);
|
||||
});
|
||||
app.get('/refresher/:token', (req, res) => {
|
||||
if (!tokenRefresher) tokenRefresher = require('./tokenRefresher');
|
||||
tokenRefresher(req, res);
|
||||
});
|
||||
app.post('/create', (req, res) => {
|
||||
if (!createRoom) createRoom = require('./createRoom');
|
||||
createRoom(req, res);
|
||||
});
|
||||
app.post('/join', (req, res) => {
|
||||
if (!joinRoom) joinRoom = require('./joinRoom');
|
||||
joinRoom(req, res);
|
||||
});
|
||||
app.post('/message', (req, res) => {
|
||||
if (!sendMessage) sendMessage = require('./sendMessage');
|
||||
sendMessage(req, res);
|
||||
});
|
||||
app.post('/updatePlayer', (req, res) => {
|
||||
if (!updatePlayer) updatePlayer = require('./updatePlayer');
|
||||
updatePlayer(req, res);
|
||||
});
|
||||
app.post('/updateVoxeet', (req, res) => {
|
||||
if (!updateVoxeet) updateVoxeet = require('./updateVoxeet');
|
||||
updateVoxeet(req, res);
|
||||
});
|
||||
app.delete('/leave/:rid/users/:uid', (req, res) => {
|
||||
if (!leaveRoom) leaveRoom = require('./leaveRoom');
|
||||
leaveRoom(req, res);
|
||||
});
|
||||
app.delete('/delete/:rid', (req, res) => {
|
||||
if (!deleteRoom) deleteRoom = require('./deleteRoom');
|
||||
deleteRoom(req, res);
|
||||
});
|
||||
app.put('/updateAdminOnly/:rid/:adminOnly', (req, res) => {
|
||||
if (!updateAdminOnly) updateAdminOnly = require('./updateAdminOnly');
|
||||
updateAdminOnly(req, res);
|
||||
});
|
||||
|
||||
module.exports = app;
|
||||
|
||||
@@ -5,6 +5,11 @@ const mLogger = new Logger('modules', 'authenticator');
|
||||
module.exports = (req, res, next) => {
|
||||
mLogger.start();
|
||||
res.set('Access-Control-Allow-Origin', ['*']);
|
||||
if (req.url === '/') {
|
||||
mLogger.success('HEARTBEAT', { URL: req.url });
|
||||
res.status(200).send({ message: 'ALIVE' });
|
||||
return next();
|
||||
}
|
||||
if (req.method === 'OPTIONS') {
|
||||
mLogger.success('OPTIONS CALL', { URL: req.url });
|
||||
res.status(200).send();
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
const authenticator = require('./authenticator');
|
||||
const createRoom = require('./createRoom');
|
||||
const joinRoom = require('./joinRoom');
|
||||
const sendMessage = require('./sendMessage');
|
||||
const leaveRoom = require('./leaveRoom');
|
||||
const deleteRoom = require('./deleteRoom');
|
||||
const timeDiff = require('./timeDiff');
|
||||
const updatePlayer = require('./updatePlayer');
|
||||
const tokenValidator = require('./tokenValidator');
|
||||
const tokenRefresher = require('./tokenRefresher');
|
||||
const updateVoxeet = require('./updateVoxeet');
|
||||
const updateAdminOnly = require('./updateAdminOnly');
|
||||
|
||||
module.exports = {
|
||||
authenticator,
|
||||
createRoom,
|
||||
joinRoom,
|
||||
sendMessage,
|
||||
updatePlayer,
|
||||
leaveRoom,
|
||||
deleteRoom,
|
||||
timeDiff,
|
||||
tokenValidator,
|
||||
tokenRefresher,
|
||||
updateVoxeet,
|
||||
updateAdminOnly,
|
||||
};
|
||||
@@ -16,6 +16,7 @@ COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION.
|
||||
url('./fonts/pixelsplitter-bold-webfont.woff') format('woff');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'GlacialBold';
|
||||
@@ -23,6 +24,7 @@ COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION.
|
||||
url('./fonts/glacialindifference-bold-webfont.woff') format('woff');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'GlacialItalic';
|
||||
@@ -30,6 +32,7 @@ COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION.
|
||||
url('./fonts/glacialindifference-italic-webfont.woff') format('woff');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Glacial';
|
||||
@@ -37,6 +40,7 @@ COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION.
|
||||
url('./fonts/glacialindifference-regular-webfont.woff') format('woff');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
[data-font='serif'] {
|
||||
font-family: 'PixelSplitter', sans-serif;
|
||||
|
||||
Reference in New Issue
Block a user