const express = require('express')
const wkd = require('express-wkd')
const app = express()
const fs = require('fs')
const path = require('path')
const util = require('./server/util')
require('dotenv').config()

app.set('env', process.env.NODE_ENV || "production")
app.set('view engine', 'pug')
app.set('port', process.env.PORT || 3000)

app.use(wkd({ domain: 'yarmo.eu' }))

app.use('/', require('./routes/main'))
app.use('/', require('./routes/static'))
app.use('/feed', require('./routes/feed'))
app.use('/rss', require('./routes/feed'))

console.log('Updating DB...')
util.updateDB()
console.log('- done!')

app.listen(app.get('port'), () => {
    console.log(`Node server listening at http://localhost:${app.get('port')}`)
})
