Skip to content

src/index: Add env var to hardcode current connections#107

Open
iakat wants to merge 1 commit intoottomated:masterfrom
iakat:patch-1
Open

src/index: Add env var to hardcode current connections#107
iakat wants to merge 1 commit intoottomated:masterfrom
iakat:patch-1

Conversation

@iakat
Copy link
Copy Markdown

@iakat iakat commented Dec 21, 2020

This prevents the data from being exposed, handy for self-hosted servers.

This prevents the data from being exposed, handy for self-hosted servers.
app.use(morgan('combined'))
app.use(express.static('offsets'))
let connectionCount = 0;
let publicConnectionCount = process.env.PUBLIC_CONNECTION_COUNT || connectionCount;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable will never change. In JS, with strings and numbers, you're not storing a reference, you're storing a value. If you wrapped this in an object that would work.


app.get('/', (_, res) => {
res.render('index', { connectionCount, address });
res.render('index', { publicConnectionCount, address });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The template views/index.pug depends on this value. So you're breaking that template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants