diff --git a/src/channelManager.ts b/src/channelManager.ts index b7dc29c..c335c31 100644 --- a/src/channelManager.ts +++ b/src/channelManager.ts @@ -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}`); diff --git a/src/channels/channelBase.ts b/src/channels/channelBase.ts index 2eec4e4..c05458d 100644 --- a/src/channels/channelBase.ts +++ b/src/channels/channelBase.ts @@ -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; } diff --git a/src/channels/types/publicChannel.ts b/src/channels/types/publicChannel.ts index 0bde811..101f3e0 100644 --- a/src/channels/types/publicChannel.ts +++ b/src/channels/types/publicChannel.ts @@ -7,7 +7,7 @@ class PublicChannel extends ChannelBase { messageTransactionPossible(from: PublicClient, to: PublicClient) { return ( to !== from - ) + ); } }; diff --git a/src/clientManager.ts b/src/clientManager.ts index 8d75775..2d9e0f3 100644 --- a/src/clientManager.ts +++ b/src/clientManager.ts @@ -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; diff --git a/src/clients/clientBase.ts b/src/clients/clientBase.ts index 78edf0e..dca9a1c 100644 --- a/src/clients/clientBase.ts +++ b/src/clients/clientBase.ts @@ -95,6 +95,6 @@ class ClientBase { this.ws.close(); this.ws = ws; } -}; +} export default ClientBase; diff --git a/src/clients/types/customClient.ts b/src/clients/types/customClient.ts index 73d24d2..a3e552d 100644 --- a/src/clients/types/customClient.ts +++ b/src/clients/types/customClient.ts @@ -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}); } } diff --git a/src/clients/types/privateClient.ts b/src/clients/types/privateClient.ts index 59e79c3..3254d20 100644 --- a/src/clients/types/privateClient.ts +++ b/src/clients/types/privateClient.ts @@ -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; diff --git a/src/clients/types/publicClient.ts b/src/clients/types/publicClient.ts index 620daf3..c80455e 100644 --- a/src/clients/types/publicClient.ts +++ b/src/clients/types/publicClient.ts @@ -1,5 +1,5 @@ import ClientBase from '../clientBase'; -class PublicClient extends ClientBase {}; +class PublicClient extends ClientBase {} export default PublicClient; diff --git a/src/controllers/appController.ts b/src/controllers/appController.ts index 7746e08..cc595a7 100644 --- a/src/controllers/appController.ts +++ b/src/controllers/appController.ts @@ -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}`) } }; diff --git a/src/controllers/authController.ts b/src/controllers/authController.ts index 228d014..c45238b 100644 --- a/src/controllers/authController.ts +++ b/src/controllers/authController.ts @@ -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)) }); } -} +}; diff --git a/src/helpers/clientHelpers.ts b/src/helpers/clientHelpers.ts index ae3f48e..2a8e368 100644 --- a/src/helpers/clientHelpers.ts +++ b/src/helpers/clientHelpers.ts @@ -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; diff --git a/src/logger.ts b/src/logger.ts index 2387437..bc566db 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -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 diff --git a/src/routes.ts b/src/routes.ts index c53c893..1ed8f7f 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -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); diff --git a/src/server.ts b/src/server.ts index 118c3b4..1b9a4af 100755 --- a/src/server.ts +++ b/src/server.ts @@ -74,7 +74,7 @@ function startServer() { startServer(); module.exports = { - clientManager: clientManager, - channelManager: channelManager, - connectionManager: connectionManager + clientManager, + channelManager, + connectionManager }; diff --git a/src/services/validations.ts b/src/services/validations.ts index ea8253c..92b3fbb 100644 --- a/src/services/validations.ts +++ b/src/services/validations.ts @@ -1,4 +1,4 @@ -import * as Joi from 'joi' +import * as Joi from 'joi'; const app = require('../config/app');