lintageddon 3

This commit is contained in:
Josh Burman 2020-02-03 16:41:13 -05:00
parent e9d7650ffe
commit 6ec98af769
15 changed files with 30 additions and 31 deletions

@ -34,7 +34,7 @@ class ChannelManager {
channelExists(channel_id: string) {
for (let channel of this.channels) {
if (channel.id == channel_id) {
if (channel.id === channel_id) {
return channel;
}
}
@ -59,7 +59,7 @@ class ChannelManager {
try {
logger.accessLog.info(`attempting to create channel of type ${data.channel_type}, channel id: ${data.channel}...`);
if (data.channel_type == 'public') {
if (data.channel_type === 'public') {
return new PublicChannel(data.channel);
} else if (data.channel_type == 'private') {
return new PrivateChannel(data.channel);
@ -82,7 +82,7 @@ class ChannelManager {
return true;
} else {
logger.errorLog.info(`client not removed from channel, or doesn't exist in channel - channel: ${channel_id}, client: ${client_id}`);
return false
return false;
}
}
}
@ -95,16 +95,16 @@ class ChannelManager {
this.removeClientFromChannel(client.id, client.channel.id);
}
let channel = this.createChannel(changeRequest);
const channel = this.createChannel(changeRequest);
this.addClientToChannel(client, channel.id);
let message = {message_type: 'requestExamStatus'};
const message = {message_type: 'requestExamStatus'};
channel.broadcastMessage(client, message);
this.purgeEmptyChannels();
}
purgeEmptyChannels() {
for (const channel of this.channels) {
if (channel.clients.length == 0 && channel.id != 'default') {
if (channel.clients.length === 0 && channel.id !== 'default') {
const index = this.channels.indexOf(channel);
this.channels.splice(index, 1);
logger.accessLog.info(`channel removed: ${channel.id}`);

@ -54,7 +54,7 @@ class ChannelBase {
removeClient(id: number) {
for (let client of this.clients) {
if (client.id === id) {
let index = this.clients.indexOf(client)
const index = this.clients.indexOf(client)
this.clients.splice(index, 1);
return true;
}

@ -7,7 +7,7 @@ class PublicChannel extends ChannelBase {
messageTransactionPossible(from: PublicClient, to: PublicClient) {
return (
to !== from
)
);
}
};

@ -10,7 +10,7 @@ class ClientManager {
clients: any[] = [];
constructor() {
//...maybe one day
// ...maybe one day
}
addClient(data: any, channelManager: ChannelManager, ws: WebSocket) {
@ -39,7 +39,7 @@ class ClientManager {
}
clientExists(id: number) {
for (let client of this.clients) {
for (const client of this.clients) {
if (client.id === id) {
return client;
}
@ -84,6 +84,6 @@ class ClientManager {
return new PublicClient(data, ws, channelManager, this);
}
}
};
}
export default ClientManager;

@ -95,6 +95,6 @@ class ClientBase {
this.ws.close();
this.ws = ws;
}
};
}
export default ClientBase;

@ -9,7 +9,7 @@ class CustomClient extends ClientBase {
constructor(data: any, ws: WebSocket, channelManager: ChannelManager, clientManager: ClientManager) {
super(data, ws, channelManager, clientManager);
this.roles = data.user_roles;
logger.accessLog.info('Custom Client Created', {data: data});
logger.accessLog.info('Custom Client Created', {data});
}
}

@ -9,8 +9,8 @@ class PrivateClient extends ClientBase {
constructor(data: any, ws: WebSocket, channelManager: ChannelManager, clientManager: ClientManager) {
super(data, ws, channelManager, clientManager);
this.roles = data.user_roles;
logger.accessLog.info('Private Client Created', {data: data});
logger.accessLog.info('Private Client Created', {data});
}
};
}
export default PrivateClient;

@ -1,5 +1,5 @@
import ClientBase from '../clientBase';
class PublicClient extends ClientBase {};
class PublicClient extends ClientBase {}
export default PublicClient;

@ -1,7 +1,7 @@
var app = require('../config/app')
const app = require('../config/app');
module.exports = {
home : (req: any, res: any) => {
home: (req: any, res: any) => {
res.send(`Welcome to Braid v${app.version}`)
}
};

@ -1,12 +1,12 @@
import * as jwt from 'jsonwebtoken';
const app = require('../config/app');
const app = require('../config/app');
module.exports = {
confirmToken : (req: any, res: any) => {
let token = req.body.token
const token = req.body.token
res.json({
response: JSON.stringify(jwt.verify(token, app.secret, app.signOptions))
});
}
}
};

@ -1,5 +1,5 @@
module.exports = {
clientExists: function(id: number) {
clientExists(id: number) {
for (const client of this.clients) {
if (client.id === id) {
return client;

@ -14,7 +14,7 @@ function loggerTransports(logName: string, logLevel: string) {
timestamp: tsFormat,
level: logLevel
})
]
];
}
const errorLog = createLogger({
@ -27,7 +27,6 @@ const accessLog = createLogger({
transports: loggerTransports('access', 'info')
});
module.exports = {
errorLog: errorLog,
accessLog: accessLog

@ -14,11 +14,11 @@ const corsOptions = {
const router = express.Router();
//application
// application
const appController = require('./controllers/appController');
router.route(['/', '/home']).get(appController.home)
router.route(['/', '/home']).get(appController.home);
//auth
// auth
const authController = require('./controllers/authController');
router.route('/auth/user').post(cors(), authController.confirmToken);

@ -74,7 +74,7 @@ function startServer() {
startServer();
module.exports = {
clientManager: clientManager,
channelManager: channelManager,
connectionManager: connectionManager
clientManager,
channelManager,
connectionManager
};

@ -1,4 +1,4 @@
import * as Joi from 'joi'
import * as Joi from 'joi';
const app = require('../config/app');