text: 'use strict'
  
  const express = require('express')
  const path    = require('path')
  const dotenv  = require('dotenv')
  
  // always start from server dir,
  // independend of from where app is called
  process.chdir(__dirname)
  global.__basedir = __dirname
  const __publicdir = __basedir + '/../public'
  
  const dotenv_result = dotenv.config()
  if (dotenv_result.error) { throw dotenv_result.error }
  
  const app = express()
  app.use(express.static(__publicdir))
  app.set('view engine', 'ejs')
  app.set('views', path.join(__dirname, 'views'))
  app.use(require('./routes'))
  
  let delivery_port=process.env.DELIVERY_PORT || 8080
  app.listen(delivery_port, () => {
    console.log('Server starting...')
    console.log('Basedir is ' + __basedir)
    console.log('Publicdir is ' + __publicdir)
    console.log('Node version ' + process.version)
    console.log('Listening on port ' + delivery_port)
  })
  
  module.exports = app
  