2019-10-28 14:00:36 +00:00
|
|
|
// vim: set ts=2 sw=2 et tw=80:
|
|
|
|
|
|
|
|
const express = require('express');
|
|
|
|
const path = require('path');
|
|
|
|
const logger = require('morgan');
|
|
|
|
const bodyParser = require('body-parser');
|
|
|
|
const kleiDust = require('klei-dust');
|
|
|
|
const methodOverride = require('method-override');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
const mongoose = require('mongoose');
|
|
|
|
mongoose.connect('mongodb://localhost/SA3_hw6', {
|
|
|
|
useNewUrlParser: true,
|
|
|
|
useUnifiedTopology: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
require('./models/Favorites');
|
|
|
|
|
|
|
|
const app = express();
|
|
|
|
|
|
|
|
//configure app
|
|
|
|
app.use(logger('dev'));
|
|
|
|
app.set('views', __dirname + '/views');
|
|
|
|
app.engine('dust', kleiDust.dust);
|
|
|
|
app.set('view engine', 'dust');
|
|
|
|
app.set('view options', { layout: false });
|
|
|
|
|
|
|
|
app.use(methodOverride('_method'));
|
|
|
|
|
|
|
|
// parse application/x-www-form-urlencoded
|
|
|
|
app.use(bodyParser.urlencoded({ extended: false }));
|
|
|
|
|
|
|
|
// parse application/json
|
|
|
|
app.use(bodyParser.json());
|
|
|
|
|
|
|
|
app.use(express.static('public'));
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize routers here
|
|
|
|
const routers = require('./routes/routers');
|
|
|
|
app.use('/', routers.root);
|
2019-10-28 21:12:20 +00:00
|
|
|
// app.use('/favorites', routers.favourites_db);
|
2019-10-28 22:05:09 +00:00
|
|
|
// app.use('/favorites', routers.favourites_db_promises);
|
|
|
|
app.use('/favorites', routers.favourites_db_asaw);
|
2019-10-28 14:00:36 +00:00
|
|
|
app.use('/bookmarked', routers.bookmarked);
|
|
|
|
|
|
|
|
module.exports = app;
|