Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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

wants to merge 1 commit into from

Conversation

iakat
Copy link

@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.
@@ -42,10 +42,11 @@ app.set('view engine', 'pug')
app.use(morgan('combined'))
app.use(express.static('offsets'))
let connectionCount = 0;
let publicConnectionCount = process.env.PUBLIC_CONNECTION_COUNT || connectionCount;

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.

let address = process.env.ADDRESS;

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

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