Allow setting of port

This commit is contained in:
Yarmo Mackenbach 2020-08-14 19:54:28 +02:00
parent 2cc5dac911
commit 06b1c7cb17
2 changed files with 7 additions and 3 deletions

View file

@ -31,7 +31,6 @@ const express = require('express');
const md = require('markdown-it')({typographer: true});
const fs = require('fs');
const app = express();
const port = 3000;
const env = {};
const { stringReplace } = require('string-replace-middleware');
require('dotenv').config();
@ -41,6 +40,7 @@ md.use(require("markdown-it-table-of-contents"), { "includeLevel": [2, 3], "list
md.use(require('markdown-it-title'));
app.set('view engine', 'pug');
app.set('port', process.env.PORT || 3000);
app.use('/favicon.svg', express.static('favicon.svg'));
app.use(stringReplace({
@ -58,6 +58,6 @@ app.use('/proofs', require('./routes/proofs'));
app.use('/util', require('./routes/util'));
app.use('/', require('./routes/profile'));
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
app.listen(app.get('port'), () => {
console.log(`Node server listening at http://localhost:${app.get('port')}`);
});

View file

@ -1,3 +1,7 @@
# Port for Express
# Defaults to: 3000
#PORT=
# Domain for XMPP vCard fetch server
# Code for the server can be found here https://codeberg.org/keyoxide/node-xmpp-vcard
# Defaults to: "xmpp-vcard.keyoxide.org"