Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Commit

Permalink
Create basic Express server
Browse files Browse the repository at this point in the history
  • Loading branch information
derekhouck committed Feb 1, 2019
1 parent abb777a commit 5b5df74
Show file tree
Hide file tree
Showing 6 changed files with 1,666 additions and 2 deletions.
5 changes: 5 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
PORT: process.env.PORT || 8080
};
29 changes: 29 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';

const express = require('express');

const { PORT } = require('./config');

const app = express();

app.use(express.static('public'));

function runServer(port = PORT) {
const server = app
.listen(port, () => {
// eslint-disable-next-line no-console
console.info(`App listening on port ${server.address().port}`);
})
.on('error', err => {
// eslint-disable-next-line no-console
console.error('Express failed to start');
// eslint-disable-next-line no-console
console.error(err);
});
}

if (require.main === module) {
runServer();
}

module.exports = app;
Loading

0 comments on commit 5b5df74

Please sign in to comment.