Skip to content

Commit

Permalink
[mirotalkwebrtc] - add url middleware, fix typo, update dep
Browse files Browse the repository at this point in the history
  • Loading branch information
miroslavpejic85 committed Dec 21, 2024
1 parent 5c64126 commit fdb0895
Show file tree
Hide file tree
Showing 20 changed files with 61 additions and 38 deletions.
2 changes: 1 addition & 1 deletion backend/common/ngrok.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use-strict';
'use strict';

const logs = require('../common/logs');
const log = new logs('Ngrok');
Expand Down
2 changes: 1 addition & 1 deletion backend/common/sentry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use-strict';
'use strict';

const logs = require('../common/logs');
const log = new logs('Sentry');
Expand Down
2 changes: 1 addition & 1 deletion backend/common/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use-strict';
'use strict';

const CryptoJS = require('crypto-js');
const jwt = require('jsonwebtoken');
Expand Down
2 changes: 1 addition & 1 deletion backend/config.template.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use-strict';
'use strict';

module.exports = {
App: {
Expand Down
2 changes: 1 addition & 1 deletion backend/lib/nodemailer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use-strict';
'use strict';

const logs = require('../common/logs');
const nodemailer = require('nodemailer');
Expand Down
2 changes: 1 addition & 1 deletion backend/middleware/admin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use-strict';
'use strict';

const utils = require('../common/utils');
const logs = require('../common/logs');
Expand Down
2 changes: 1 addition & 1 deletion backend/middleware/api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use-strict';
'use strict';

const utils = require('../common/utils');
const logs = require('../common/logs');
Expand Down
2 changes: 1 addition & 1 deletion backend/middleware/auth.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use-strict';
'use strict';

const utils = require('../common/utils');
const logs = require('../common/logs');
Expand Down
19 changes: 19 additions & 0 deletions backend/middleware/url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

const utils = require('../common/utils');
const logs = require('../common/logs');

const log = new logs('URL');

const url = (err, req, res, next) => {
if (err instanceof URIError) {
log.error('Malformed URL', req.url);
res.status(400).send('Bad Request: Malformed URL');
} else {
next(err);
}

return next();
};

module.exports = url;
2 changes: 1 addition & 1 deletion backend/middleware/validator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use-strict';
'use strict';

const logs = require('../common/logs');
const log = new logs('Validator');
Expand Down
2 changes: 1 addition & 1 deletion backend/models/room.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use-strict';
'use strict';

const mongoose = require('mongoose');

Expand Down
2 changes: 1 addition & 1 deletion backend/models/users.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use-strict';
'use strict';

const mongoose = require('mongoose');

Expand Down
17 changes: 9 additions & 8 deletions backend/routes/room.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const express = require('express');
const url = require('../middleware/url');
const api = require('../middleware/api');
const auth = require('../middleware/auth');
const admin = require('../middleware/admin');
Expand All @@ -9,42 +10,42 @@ const router = express.Router();
const controllersRooms = require('../controllers/rooms');

//CREATE: /api/v1/room
router.post('/room', auth, validator, (req, res) => {
router.post('/room', auth, validator, url, (req, res) => {
controllersRooms.roomCreate(req, res);
});

//EXISTS: /api/v1/room/exists
router.post('/room/exists', api, (req, res) => {
router.post('/room/exists', api, url, (req, res) => {
controllersRooms.roomExists(req, res);
});

//GET: /api/v1/room/findBy/userId
router.get('/room/findBy/:userId', auth, (req, res) => {
router.get('/room/findBy/:userId', auth, url, (req, res) => {
controllersRooms.roomFindBy(req, res);
});

//DELETE: /api/v1/findBy/userId
router.delete('/room/findBy/:userId', auth, (req, res) => {
router.delete('/room/findBy/:userId', auth, url, (req, res) => {
controllersRooms.roomDeleteFindBy(req, res);
});

//GET: /api/v1/room/id
router.get('/room/:id', auth, (req, res) => {
router.get('/room/:id', auth, url, (req, res) => {
controllersRooms.roomGet(req, res);
});

//UPDATE: /api/v1/room/id
router.patch('/room/:id', auth, validator, (req, res) => {
router.patch('/room/:id', auth, validator, url, (req, res) => {
controllersRooms.roomUpdate(req, res);
});

//DELETE: /api/v1/room/id
router.delete('/room/:id', auth, (req, res) => {
router.delete('/room/:id', auth, url, (req, res) => {
controllersRooms.roomDelete(req, res);
});

//DELETE: /api/v1/room/deleteALL
router.delete('/room/deleteAll', admin, (req, res) => {
router.delete('/room/deleteAll', admin, url, (req, res) => {
controllersRooms.roomDeleteALL(req, res);
});

Expand Down
3 changes: 2 additions & 1 deletion backend/routes/sms.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

const express = require('express');
const auth = require('../middleware/auth');
const url = require('../middleware/url');
//const admin = require('../middleware/admin');
const router = express.Router();
const controllersSmS = require('../controllers/sms');

//POST: /api/v1/sms
router.post('/sms', auth, (req, res) => {
router.post('/sms', auth, url, (req, res) => {
controllersSmS.smsSend(req, res);
});

Expand Down
3 changes: 2 additions & 1 deletion backend/routes/token.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
'use strict';

const express = require('express');
const url = require('../middleware/url');
const auth = require('../middleware/auth');
const validator = require('../middleware/validator');
const router = express.Router();
const controllersToken = require('../controllers/token');

//GET: /api/v1/token/SFU/:token
router.get('/token/SFU/:token', auth, validator, (req, res) => {
router.get('/token/SFU/:token', auth, validator, url, (req, res) => {
controllersToken.tokenSFU(req, res);
});

Expand Down
21 changes: 11 additions & 10 deletions backend/routes/users.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const express = require('express');
const url = require('../middleware/url');
const auth = require('../middleware/auth');
const admin = require('../middleware/admin');
const api = require('../middleware/api');
Expand All @@ -9,52 +10,52 @@ const router = express.Router();
const controllersUsers = require('../controllers/users');

//CREATE: /api/v1/user
router.post('/user', validator, (req, res) => {
router.post('/user', validator, url, (req, res) => {
controllersUsers.userCreate(req, res);
});

//LOGIN: /api/v1/user/login
router.post('/user/login', validator, (req, res) => {
router.post('/user/login', validator, url, (req, res) => {
controllersUsers.userLogin(req, res);
});

//POST: /api/v1/user/isAuth/
router.post('/user/isAuth', api, (req, res) => {
router.post('/user/isAuth', api, url, (req, res) => {
controllersUsers.userIsAuth(req, res);
});

//POST: /api/v1/user/isRoomAllowed/
router.post('/user/isRoomAllowed', api, (req, res) => {
router.post('/user/isRoomAllowed', api, url, (req, res) => {
controllersUsers.userIsRoomAllowed(req, res);
});

//POST: /api/v1/user/allowedRooms/
router.post('/user/roomsAllowed', api, (req, res) => {
router.post('/user/roomsAllowed', api, url, (req, res) => {
controllersUsers.userRoomsAllowed(req, res);
});

//GET: /api/v1/user/confirmation/?token=<token>
router.get('/user/confirmation', auth, (req, res) => {
router.get('/user/confirmation', auth, url, (req, res) => {
controllersUsers.userConfirmation(req, res);
});

//GET: /api/v1/user/id
router.get('/user/:id', auth, (req, res) => {
router.get('/user/:id', auth, url, (req, res) => {
controllersUsers.userGet(req, res);
});

//UPDATE: /api/v1/user/id
router.patch('/user/:id', auth, validator, (req, res) => {
router.patch('/user/:id', auth, validator, url, (req, res) => {
controllersUsers.userUpdate(req, res);
});

//DELETE: /api/v1/user/id
router.delete('/user/:id', auth, (req, res) => {
router.delete('/user/:id', auth, url, (req, res) => {
controllersUsers.userDelete(req, res);
});

//DELETE: /api/v1/user/deleteALL
router.delete('/user/deleteALL', admin, (req, res) => {
router.delete('/user/deleteALL', admin, url, (req, res) => {
controllersUsers.userDeleteALL(req, res);
});

Expand Down
2 changes: 1 addition & 1 deletion frontend/js/api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use-strict';
'use strict';

const apiPath = '/api/v1';
const userEmail = window.localStorage.email;
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use-strict';
'use strict';

/**
* MiroTalk WebRTC - Client component
Expand All @@ -9,7 +9,7 @@
* @license For private project or commercial purposes contact us at: license.mirotalk@gmail.com or purchase it directly via Code Canyon:
* @license https://codecanyon.net/item/a-selfhosted-mirotalks-webrtc-rooms-scheduler-server/42643313
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.1.27
* @version 1.1.28
*/

const isMobile = !!/Android|webOS|iPhone|iPad|iPod|BB10|BlackBerry|IEMobile|Opera Mini|Mobile|mobile/i.test(
Expand Down
2 changes: 1 addition & 1 deletion frontend/js/swal.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use-strict';
'use strict';

function popupMessage(type, message, timer = 3000) {
switch (type) {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mirotalkwebrtc",
"version": "1.1.27",
"version": "1.1.28",
"description": "MiroTalk WebRTC admin",
"main": "server.js",
"scripts": {
Expand Down Expand Up @@ -33,7 +33,7 @@
"license": "AGPL-3.0",
"homepage": "https://github.com/miroslavpejic85/mirotalkwebrtc",
"dependencies": {
"@sentry/node": "^8.45.0",
"@sentry/node": "^8.47.0",
"axios": "^1.7.9",
"bcryptjs": "^2.4.3",
"colors": "1.4.0",
Expand All @@ -44,7 +44,7 @@
"express": "^4.21.2",
"jsonwebtoken": "^9.0.2",
"js-yaml": "^4.1.0",
"mongoose": "^8.9.0",
"mongoose": "^8.9.2",
"ngrok": "^5.0.0-beta.2",
"nodemailer": "^6.9.16",
"swagger-ui-express": "^5.0.1",
Expand Down

0 comments on commit fdb0895

Please sign in to comment.