Notes/src/app.js

61 lines
1.8 KiB
JavaScript
Raw Normal View History

const express = require('express');
const path = require('path');
const favicon = require('serve-favicon');
const cookieParser = require('cookie-parser');
2017-10-15 16:32:49 -04:00
const helmet = require('helmet');
const compression = require('compression');
const sessionParser = require('./routes/session_parser');
2024-02-16 21:38:09 +02:00
const utils = require('./services/utils');
2023-05-07 15:23:46 +02:00
2024-04-04 23:04:54 +03:00
require('./services/handlers');
2024-02-17 20:45:31 +02:00
require('./becca/becca_loader');
const app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
if (!utils.isElectron()) {
app.use(compression()); // HTTP compression
}
2022-08-20 17:30:35 -04:00
2018-10-14 11:31:23 +02:00
app.use(helmet({
2022-01-12 19:32:23 +01:00
hidePoweredBy: false, // errors out in electron
2022-05-18 22:56:29 +02:00
contentSecurityPolicy: false,
crossOriginEmbedderPolicy: false
2018-10-14 11:31:23 +02:00
}));
2024-04-03 20:47:41 +03:00
app.use(express.text({ limit: '500mb' }));
app.use(express.json({ limit: '500mb' }));
app.use(express.raw({ limit: '500mb' }));
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public/root')));
2022-12-02 22:06:18 +01:00
app.use(`/manifest.webmanifest`, express.static(path.join(__dirname, 'public/manifest.webmanifest')));
app.use(`/robots.txt`, express.static(path.join(__dirname, 'public/robots.txt')));
app.use(sessionParser);
app.use(favicon(`${__dirname}/../images/app-icons/win/icon.ico`));
2024-04-07 14:02:52 +03:00
require('./routes/assets').register(app);
2024-04-11 23:00:24 +03:00
require('./routes/routes').register(app);
2024-04-07 14:05:50 +03:00
require('./routes/custom').register(app);
require('./routes/error_handlers').register(app);
// triggers sync timer
2024-02-18 13:10:51 +02:00
require('./services/sync');
2017-10-21 21:10:33 -04:00
// triggers backup timer
2024-02-17 19:33:29 +02:00
require('./services/backup');
2017-12-14 22:16:26 -05:00
// trigger consistency checks timer
2024-04-03 20:47:41 +03:00
require('./services/consistency_checks');
2017-12-14 22:16:26 -05:00
2024-04-04 23:08:32 +03:00
require('./services/scheduler');
2021-11-18 21:35:23 +01:00
if (utils.isElectron()) {
require('@electron/remote/main').initialize();
}
2021-11-16 22:43:08 +01:00
2023-05-07 15:23:46 +02:00
module.exports = app;