import cors from 'cors';
import Express from 'express';

import strategies from './strategies';

const app = Express();
const ejs = require('ejs').__express;

app.use(cors());
app.set('view engine', 'ejs');
app.engine('.ejs', ejs);

const viewPath = process.env.NODE_ENV_URL === 'local'
  ? `${__dirname}/../views`
  : '/usr/src/app/node_modules/@madbean/authentication/views';

app.set('views', viewPath);

const account = (req, res) => {
  res.status(200)
    .send('secured');
};

const home = (req, res) => {
  res.status(200)
    .send('login please');
};

strategies(app, account, home);

app.listen(3000, () => console.log('authentication is running on : http://localhost:3000'));
