Skip to content

Commit 883ff00

Browse files
author
Mikael
authored
feat: remove welcome message helsingborg (#187)
1 parent 8ba3201 commit 883ff00

File tree

6 files changed

+36
-8
lines changed

6 files changed

+36
-8
lines changed

packages/simulator/config/helsingborg.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const includedMunicipalities = ['Helsingborg']
2+
const ignoreWelcomeMessage = true
23
const defaultEmitters = [
34
'cars',
45
'postombud',
@@ -9,4 +10,5 @@ const defaultEmitters = [
910
module.exports = {
1011
includedMunicipalities,
1112
defaultEmitters,
13+
ignoreWelcomeMessage,
1214
}

packages/simulator/package-lock.json

Lines changed: 20 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/simulator/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"dependencies": {
1616
"@elastic/elasticsearch": "^7.17.0",
1717
"chalk": "^3.0.0",
18+
"cookie": "^0.5.0",
1819
"csv-parse": "^4.16.0",
1920
"csv-stream": "^0.2.0",
2021
"date-fns": "^2.29.3",

packages/simulator/web/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const server = require('http').createServer(ok)
1313

1414
const io = require('socket.io')(server, {
1515
cors: {
16-
origin: '*',
16+
origin: 'http://localhost:3000',
17+
credentials: true,
1718
methods: ['GET', 'POST'],
1819
},
1920
})

packages/simulator/web/routes.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const engine = require('../index')
22
const { saveParameters } = require('../lib/fileUtils')
33
const { info } = require('../lib/log')
4-
const { defaultEmitters } = require('../config')
4+
const { defaultEmitters, ignoreWelcomeMessage } = require('../config')
5+
const cookie = require('cookie')
56

67
function subscribe(experiment, socket) {
78
return [
@@ -23,6 +24,14 @@ function start(socket) {
2324
}
2425

2526
function register(io) {
27+
if (ignoreWelcomeMessage) {
28+
io.engine.on('initial_headers', (headers) => {
29+
headers['set-cookie'] = cookie.serialize('hideWelcomeBox', 'true', {
30+
path: '/',
31+
})
32+
})
33+
}
34+
2635
io.on('connection', function (socket) {
2736
if (!socket.data.experiment) {
2837
start(socket)

packages/visualisation/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { SocketIOProvider } from './context/socketIOProvider'
88
ReactDOM.render(
99
<SocketIOProvider
1010
url={process.env.REACT_APP_SIMULATOR_URL || 'http://localhost:4000'}
11+
opts={{ withCredentials: true }}
1112
>
1213
<App />
1314
</SocketIOProvider>,

0 commit comments

Comments
 (0)