stub middleware (including socket), controllers architecture
This commit is contained in:
parent
bedd175e5d
commit
7e2156ff06
7 changed files with 9 additions and 11 deletions
|
@ -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));
|
||||||
|
|
0
server/controllers/auth.js
Normal file
0
server/controllers/auth.js
Normal file
0
server/controllers/index.js
Normal file
0
server/controllers/index.js
Normal file
0
server/routes/api.js
Normal file
0
server/routes/api.js
Normal file
0
server/routes/auth.js
Normal file
0
server/routes/auth.js
Normal 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));
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue