stub middleware (including socket), controllers architecture

This commit is contained in:
Sorrel Bri 2020-01-08 11:24:24 -08:00
parent bedd175e5d
commit 7e2156ff06
7 changed files with 9 additions and 11 deletions

View file

@ -90,5 +90,5 @@ function onListening() {
} }
const socketIO = require('socket.io') const socketIO = require('socket.io')
const socket = require('../socket').socket; const enableSocket = require('../socket').enableSocket;
const io = socket(socketIO(server)); const io = enableSocket(socketIO(server));

View file

View file

0
server/routes/api.js Normal file
View file

0
server/routes/auth.js Normal file
View file

View file

@ -2,8 +2,6 @@ const createError = require('http-errors');
const express = require('express'); const express = require('express');
const cors = require('cors'); const cors = require('cors');
const socketIO = require("socket.io");
const http = require('http');
const path = require('path'); const path = require('path');
const cookieParser = require('cookie-parser'); const cookieParser = require('cookie-parser');
@ -18,14 +16,10 @@ const indexRouter = require('./routes/index');
const usersRouter = require('./routes/users'); const usersRouter = require('./routes/users');
const app = express(); const app = express();
const server = require('./bin/www');
const corsOptions = { const corsOptions = {
origin: process.env.REACT_ADDRESS origin: process.env.REACT_ADDRESS
} }
const port = process.env.PORT;
app.options('*', cors(corsOptions)); app.options('*', cors(corsOptions));
app.use('*', cors(corsOptions)); app.use('*', cors(corsOptions));

View file

@ -1,10 +1,14 @@
// TODO const someSocketLogic = require('./middleware/socketssockets/...');
module.exports = { module.exports = {
socket: io => { enableSocket: io => {
io.on('connection', () => console.log('connected')) io.on('connection', () => console.log('connected'))
io.on('connect', ()=> { io.on('connect', ()=> {
console.log('connected'); io.emit('connected', {message: 'socket connected'});
io.emit('connected', {message: 'socket connected'});
}) })
// TODO io = someSocketLogic(io);
return io; return io;
} }
} }