2023-10-28 23:22:18 -04:00
|
|
|
const express = require('express');
|
|
|
|
const app = express();
|
|
|
|
const port = 3000;
|
|
|
|
|
2023-11-26 00:57:08 -05:00
|
|
|
// grab app and node.js process data
|
|
|
|
const pjson = require('./package.json');
|
|
|
|
const { versions } = require('node:process');
|
|
|
|
|
|
|
|
// register app and node.js versions with views;
|
|
|
|
app.locals.app_version = pjson.version;
|
|
|
|
app.locals.node_version = versions.node;
|
|
|
|
|
|
|
|
// initialize database
|
|
|
|
const sequelize = require('./src/models');
|
|
|
|
sequelize.sync({}).then(function(){
|
|
|
|
console.log('database has been synced');
|
|
|
|
}).catch(function(){
|
|
|
|
console.log('unable to sync database');
|
|
|
|
});
|
|
|
|
|
|
|
|
// enable sessions
|
|
|
|
const session = require("express-session");
|
|
|
|
app.use(session({ resave: true, secret: "123456", saveUninitialized: true }));
|
|
|
|
|
2023-11-26 02:07:20 -05:00
|
|
|
// enable body-parser to read form data
|
|
|
|
const bodyParser = require('body-parser');
|
|
|
|
app.use(bodyParser.urlencoded({ extended: true }));
|
|
|
|
|
2023-10-28 23:22:18 -04:00
|
|
|
// enable the Twig template engine
|
|
|
|
app.set('view engine', 'twig');
|
2023-12-02 23:41:04 -05:00
|
|
|
app.set('twig options', {
|
|
|
|
allowAsync: true,
|
|
|
|
strict_variables: false
|
|
|
|
});
|
2023-10-28 23:22:18 -04:00
|
|
|
|
|
|
|
// enable serving static files
|
|
|
|
app.use(express.static('public'));
|
|
|
|
|
2023-11-27 21:29:52 -05:00
|
|
|
// load routes to express
|
|
|
|
require('./src/routes')(app);
|
2023-10-28 23:22:18 -04:00
|
|
|
|
|
|
|
app.listen(port, () => {
|
|
|
|
console.log(`Leviathan listening on port ${port}`);
|
|
|
|
});
|