29484dc7 by Jabis Sevon

downgraded to express@^3.23 and socket.io@^0.9.16

1 parent eec9eab8
1 index.rendered.html 1 index.rendered.html
2 node_modules 2 node_modules
3 examples/node_modules
......
1 const express = require('express'); 1 const express = require('express');
2 const app = express(); 2 const app = express();
3 3 const http = require('http');
4 const io = require('socket.io');
4 const config = { 5 const config = {
6 uri: 'www.cert.coder.fi',
7 port: 4000,
5 path: '/', 8 path: '/',
6 title: 'Express Status', 9 title: 'Express Status',
7 spans: [{ 10 spans: [{
...@@ -16,8 +19,9 @@ const config = { ...@@ -16,8 +19,9 @@ const config = {
16 }] 19 }]
17 } 20 }
18 21
19 app.use(require('../index')(config)); 22 var server = http.createServer(app);
23 app.use(require('../index')(config, server));
20 24
21 app.listen(3000, () => { 25 server.listen(config.port, config.uri, () => {
22 console.log('🌏 http://0.0.0.0:3000'); 26 console.log('🌏 http://'+config.uri+':'+config.port);
23 }); 27 });
......
...@@ -9,13 +9,18 @@ ...@@ -9,13 +9,18 @@
9 "name": "Julien Breux", 9 "name": "Julien Breux",
10 "email": "julien.breux@gmail.com", 10 "email": "julien.breux@gmail.com",
11 "url": "https://github.com/JulienBreux/" 11 "url": "https://github.com/JulienBreux/"
12 },
13 {
14 "name": "Jabis Sevon",
15 "email": "jabis.is@gmail.com",
16 "url": "https://jscodex.com"
12 } 17 }
13 ], 18 ],
14 "license": "MIT", 19 "license": "MIT",
15 "dependencies": { 20 "dependencies": {
16 "express": "^4.14.0", 21 "express": "^3.21.2",
17 "on-headers": "^1.0.1", 22 "on-headers": "^1.0.1",
18 "pidusage": "^1.0.4", 23 "pidusage": "^1.0.4",
19 "socket.io": "^1.4.8" 24 "socket.io": "^0.9.16"
20 } 25 }
21 } 26 }
......
1 (function () { 1 (function() {
2 'use strict'; 2 'use strict';
3 3
4 const fs = require('fs'); 4 const fs = require('fs');
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
9 let io; 9 let io;
10 10
11 const defaultConfig = { 11 const defaultConfig = {
12 uri: 'www.cert.coder.fi',
13 port: 4000,
12 title: 'Express Status', 14 title: 'Express Status',
13 path: '/status', 15 path: '/status',
14 spans: [{ 16 spans: [{
...@@ -60,7 +62,7 @@ ...@@ -60,7 +62,7 @@
60 }); 62 });
61 }; 63 };
62 64
63 const middlewareWrapper = (config) => { 65 const middlewareWrapper = (config, server) => {
64 if (config === null || config === undefined) { 66 if (config === null || config === undefined) {
65 config = defaultConfig; 67 config = defaultConfig;
66 } 68 }
...@@ -78,18 +80,20 @@ ...@@ -78,18 +80,20 @@
78 } 80 }
79 81
80 let renderedHtml; 82 let renderedHtml;
81 fs.readFile(path.join(__dirname, '/index.html'), function(err, html){ 83 fs.readFile(path.join(__dirname, '/index.html'), function(err, html) {
82 renderedHtml = html.toString().replace(/{{title}}/g, config.title); 84 renderedHtml = html.toString().replace(/{{title}}/g, config.title);
83 }); 85 });
84 86
85 return (req, res, next) => { 87 return (req, res, next) => {
86 if (io === null || io === undefined) { 88 if (io === null || io === undefined) {
87 89 //console.log(req)
88 io = require('socket.io')(req.socket.server); 90 io = require('socket.io').listen(server);
89 91
90 io.on('connection', (socket) => { 92 io.on('connection', (socket) => {
91 socket.emit('start', config.spans); 93 socket.emit('start', config.spans);
92 socket.on('change', function() { socket.emit('start', config.spans); }); 94 socket.on('change', function() {
95 socket.emit('start', config.spans);
96 });
93 }); 97 });
94 98
95 config.spans.forEach((span) => { 99 config.spans.forEach((span) => {
......
1 { 1 {
2 "name": "express-status-monitor", 2 "name": "express-status-monitor",
3 "version": "0.0.10", 3 "version": "0.0.10-dev",
4 "description": "Realtime Monitoring for Express-based Node applications", 4 "description": "Realtime Monitoring for Express-based Node applications",
5 "main": "app.js", 5 "main": "app.js",
6 "keywords": [ 6 "keywords": [
...@@ -16,7 +16,13 @@ ...@@ -16,7 +16,13 @@
16 "name": "Julien Breux", 16 "name": "Julien Breux",
17 "email": "julien.breux@gmail.com", 17 "email": "julien.breux@gmail.com",
18 "url": "https://github.com/JulienBreux/" 18 "url": "https://github.com/JulienBreux/"
19 },
20 {
21 "name": "Jabis Sevon",
22 "email": "jabis.is@gmail.com",
23 "url": "https://jscodex.com"
19 } 24 }
25
20 ], 26 ],
21 "repository": { 27 "repository": {
22 "type": "git", 28 "type": "git",
...@@ -26,6 +32,6 @@ ...@@ -26,6 +32,6 @@
26 "dependencies": { 32 "dependencies": {
27 "on-headers": "^1.0.1", 33 "on-headers": "^1.0.1",
28 "pidusage": "^1.0.4", 34 "pidusage": "^1.0.4",
29 "socket.io": "^1.4.8" 35 "socket.io": "^0.9.17"
30 } 36 }
31 } 37 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!