const path = require('path');
const express = require('express');
const config = require('@devcms/config');
const ejs = require('ejs');

const app = express();

app.engine('html', ejs.renderFile);
app.set('view engine', 'html');

app.use(express.static(path.join(__dirname, 'build'), {
  index: false
}));

app.get('/*', (req, res) => {
 res.render(path.join(__dirname, 'build', 'index.html'), {
  base_api_url: config.get('base_api_url', ''),
  basename: config.get('basename', '/')
 });
});

module.exports = {
  config: config,
  app: app
};
