Skip to content

Commit

Permalink
Airbnb Style
Browse files Browse the repository at this point in the history
  • Loading branch information
omardoma committed May 22, 2018
1 parent 5f4d0bb commit 99faeb7
Show file tree
Hide file tree
Showing 7 changed files with 1,628 additions and 106 deletions.
30 changes: 15 additions & 15 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
module.exports = {
env: {
es6: true,
node: true
},
extends: 'eslint:recommended',
parserOptions: {
sourceType: 'module',
ecmaVersion: 2017
},
extends: ['airbnb-base'],
// plugins: ['prettier'],
rules: {
'no-dupe-keys': 0,
'no-console': 0,
indent: ['error', 2, { SwitchCase: 1 }],
'linebreak-style': ['error', 'unix'],
quotes: ['error', 'single'],
semi: ['error', 'always']
// 'prettier/prettier': [
// 'error',
// {
// singleQuote: true,
// trailingComma: 'all'
// }
// ],
'consistent-return': 0,
'no-shadow': 0,
'no-underscore-dangle': 0,
'function-paren-newline': 0,
'import/no-dynamic-require': 0,
'eqeqeq': 0
}
};
12 changes: 6 additions & 6 deletions api/v1/Socket.io.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ const config = require('./config');

io.adapter(redisAdapter({ host: config.REDIS_HOST, port: config.REDIS_PORT }));

io.on('connection', socket => {
socket.on('join', data => {
io.on('connection', (socket) => {
socket.on('join', (data) => {
socket.join(data.room, () => {
socket.to(data.room).emit('join', data);
});
});

socket.on('notification', notification => {
socket.on('notification', (notification) => {
io.of('/').adapter.clientRooms(socket.id, (err, rooms) => {
if (!err) {
rooms.forEach(room => {
rooms.forEach((room) => {
socket.to(room).emit('notification', notification);
});
}
});
});

socket.on('message', msg => {
socket.on('message', (msg) => {
io.of('/').adapter.clientRooms(socket.id, (err, rooms) => {
if (!err) {
rooms.forEach(room => {
rooms.forEach((room) => {
if (room === msg.room) {
socket.to(room).emit('message', msg);
}
Expand Down
2 changes: 1 addition & 1 deletion api/v1/config/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
REDIS_HOST: process.env.REDIS_HOST || 'localhost',
REDIS_PORT: process.env.REDIS_PORT || 6379
REDIS_PORT: process.env.REDIS_PORT || 6379,
};
6 changes: 3 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const express = require('express');
const logger = require('morgan');
const cors = require('cors');
const helmet = require('helmet');

const app = express();

app.use(logger(process.env.NODE_ENV === 'production' ? 'combined' : 'dev'));
app.use(
cors({
origin: true
})
origin: true,
}),
);
app.use(helmet());
app.use((req, res) => {
Expand Down
2 changes: 1 addition & 1 deletion bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ server.on('error', onError);
server.on('listening', onListening);

// Socket.io Logic
require('../api/v1/Socket.io').attach(server);
require('../api/v1/socket.io').attach(server);
Loading

0 comments on commit 99faeb7

Please sign in to comment.