How to connect

In the file app.js (main application file), I'm starting to listen io and http.
There is a separate module X, which I hooked up using require.
As from X do io.emit?

Ie how to handle io in a separate module, and then connect to the app X
At the moment the app looks like this:
var app = require('express')();
var http = require('http').Server(app);
var io = require('')(http);
var path = require('path');
var x = require('./x');

app.get('/', function(req, res){
 Res. sendFile(path.join(__dirname + '/public/index.html'));

http.listen(80, function(){
 console.log('http.listen on 80');

Tried = io in the app and require(app) in X. But strange how it goes, because I run app X, and then X get app. In the console the message to start the listen appears 2 times. Somehow it's not pretty
July 9th 19 at 13:19
1 answer
July 9th 19 at 13:21
var x = require('./x')(io);
// x.js
module.exports = function(io){
io.emit (......);
Thank you! What you need - kiley_Gottli commented on July 9th 19 at 13:24

Find more questions by tags