Browse Source

add .env config

develop
Rob Colbert 2 years ago
parent
commit
03af42efd7
  1. 2
      .gitignore
  2. 12
      countdown.js
  3. 1
      package.json
  4. 5
      yarn.lock

2
.gitignore

@ -1 +1,3 @@
node_modules
.env

12
countdown.js

@ -1,5 +1,7 @@
'use strict';
require('dotenv').config();
const path = require('path');
const express = require('express');
@ -36,6 +38,9 @@ module.getHomeView = async (req, res) => {
module.app.locals.moment = require('moment');
module.app.locals.numeral = require('numeral');
module.app.locals.site = {
domain: process.env.DTP_SITE_DOMAIN || 'localhost:8000',
};
module.app.set('view engine', 'pug');
module.app.set('views', path.join(__dirname, 'app', 'views'));
@ -55,7 +60,12 @@ module.getHomeView = async (req, res) => {
module.app.get('/timer', module.getTimerView);
module.app.get('/', module.getHomeView);
module.app.listen(8000, ( ) => {
const bind = {
host: process.env.DTP_HTTP_HOST || 'localhost',
port: parseInt(process.env.DTP_HTTP_PORT || '8000', 10),
};
console.log('starting service', bind);
module.app.listen(bind.port, bind.host, ( ) => {
console.log('Countdown online');
});
})();

1
package.json

@ -1,6 +1,7 @@
{
"main": "countdown.js",
"dependencies": {
"dotenv": "^16.0.1",
"express": "^4.18.1",
"forever": "^4.0.3",
"gulp": "^4.0.2",

5
yarn.lock

@ -789,6 +789,11 @@ dot-prop@^4.1.0:
dependencies:
is-obj "^1.0.0"
dotenv@^16.0.1:
version "16.0.1"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.1.tgz#8f8f9d94876c35dac989876a5d3a82a267fdce1d"
integrity sha512-1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsKQ==
duplexer@~0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6"

Loading…
Cancel
Save