Leviathan/index.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

const express = require('express');
const app = express();
const port = 3000;
// 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 }));
// enable body-parser to read form data
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: true }));
// 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
});
// enable serving static files
app.use(express.static('public'));
// load routes to express
require('./src/routes')(app);
app.listen(port, () => {
console.log(`Leviathan listening on port ${port}`);
});