oneuptime/home/server.js

685 lines
16 KiB
JavaScript
Raw Normal View History

2021-01-26 14:03:42 +00:00
process.on('exit', () => {
/* eslint-disable no-console */
console.log('Shutting Shutdown');
});
process.on('unhandledRejection', err => {
/* eslint-disable no-console */
console.error('Unhandled rejection in process occurred');
/* eslint-disable no-console */
console.error(err);
});
process.on('uncaughtException', err => {
/* eslint-disable no-console */
console.error('Uncaught exception in process occurred');
/* eslint-disable no-console */
console.error(err);
});
2020-02-16 23:16:14 +00:00
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const path = require('path');
const compression = require('compression');
2020-04-11 21:55:08 +00:00
const minify = require('minify');
const tryToCatch = require('try-to-catch');
const productCompare = require('./config/product-compare');
const axios = require('axios');
2019-08-02 12:56:16 +00:00
app.use(bodyParser.json());
2020-02-27 11:15:46 +00:00
app.use(bodyParser.urlencoded({ extended: true }));
2020-10-08 10:34:32 +00:00
if (process.env.NODE_ENV === 'production') {
app.use(compression());
}
2019-08-02 12:56:16 +00:00
//View engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
//Routes
2020-10-12 21:22:25 +00:00
app.get('/', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('index', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
2019-08-02 12:56:16 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/support', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('support', {
support: true,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
2019-08-02 12:56:16 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/pricing', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('pricing', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
2019-08-02 12:56:16 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/enterprise/demo', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('demo', {
support: false,
footerCards: false,
cta: false,
blackLogo: true,
requestDemoCta: false,
});
2019-08-02 12:56:16 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/product/status-page', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('status-page', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
2019-08-02 12:56:16 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/status-page', function(req, res) {
res.redirect('/product/status-page');
2020-10-08 10:46:25 +00:00
});
2020-11-20 06:57:46 +00:00
app.get('/product/public-status-page', function(req, res) {
res.render('public-status-page', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
});
app.get('/public-status-page', function(req, res) {
res.redirect('/product/public-status-page');
});
app.get('/product/private-status-page', function(req, res) {
res.render('private-status-page', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
});
app.get('/private-status-page', function(req, res) {
res.redirect('/product/private-status-page');
});
2020-10-12 21:22:25 +00:00
app.get('/status', function(req, res) {
res.redirect('https://status.fyipe.com');
2020-10-08 10:46:25 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/product/uptime-monitoring', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('uptime-monitoring', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
2019-08-02 12:56:16 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/uptime-monitoring', function(req, res) {
res.redirect('/product/uptime-monitoring');
2020-10-08 10:46:25 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/product/logs-management', function(req, res) {
2020-08-05 16:40:29 +00:00
res.render('logs-management', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
});
2020-10-12 21:22:25 +00:00
app.get('/logs-management', function(req, res) {
res.redirect('/product/logs-management');
2020-10-08 10:46:25 +00:00
});
2020-11-20 06:57:46 +00:00
app.get('/product/error-tracking', function(req, res) {
res.render('error-tracking', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
});
app.get('/error-tracking', function(req, res) {
res.redirect('/product/error-tracking');
});
app.get('/unsubscribe/:monitorId/:subscriberId', async function(req, res) {
const { monitorId, subscriberId } = req.params;
let apiHost;
if (process.env.FYIPE_HOST) {
apiHost = 'https://' + process.env.FYIPE_HOST + '/api';
} else {
apiHost = 'http://localhost:3002/api';
}
try {
2021-04-16 12:52:24 +00:00
let subscriptions = await axios({
method: 'GET',
url: `${apiHost}/subscriber/monitorList/${subscriberId}`,
});
2021-04-16 12:52:24 +00:00
res.render('subscriberMonitors', {
subscriptions: subscriptions.data.data,
defaultMonitor: monitorId,
});
2021-04-16 12:52:24 +00:00
// await axios({
// method: 'PUT',
// url: `${apiHost}/subscriber/unsubscribe/${monitorId}/${subscriberId}`,
// });
console.log(subscriptions.data);
// res.render('unsubscribe', {
// message: 'You have successfully unsubscribed from this monitor',
// });
} catch (err) {
res.render('unsubscribe', {
message:
'Encountered an error while trying to unsubscribe you from this monitor',
});
}
});
2020-10-12 21:22:25 +00:00
app.get('/product/docker-container-security', function(req, res) {
2020-08-05 16:40:29 +00:00
res.render('container-security', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
});
2020-10-12 21:22:25 +00:00
app.get('/docker-container-security', function(req, res) {
res.redirect('/product/docker-container-security');
2020-10-08 10:46:25 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/product/app-security', function(req, res) {
2020-08-05 16:40:29 +00:00
res.render('app-security', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
});
2020-10-12 21:22:25 +00:00
app.get('/app-security', function(req, res) {
res.redirect('/product/app-security');
2020-10-08 10:46:25 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/product/api-monitoring', function(req, res) {
2020-10-08 09:23:52 +00:00
res.render('api-monitoring', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
});
2020-10-12 21:22:25 +00:00
app.get('/api-monitoring', function(req, res) {
res.redirect('/product/api-monitoring');
2020-10-08 10:46:25 +00:00
});
app.get('/product/kubernetes-monitoring', function(req, res) {
res.render('kubernetes-monitoring', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
});
app.get('/kubernetes-monitoring', function(req, res) {
res.redirect('/product/kubernetes-monitoring');
});
2020-10-12 21:22:25 +00:00
app.get('/product/server-monitoring', function(req, res) {
2020-10-08 09:23:52 +00:00
res.render('server-monitoring', {
2020-08-05 16:40:29 +00:00
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
});
2020-10-12 21:22:25 +00:00
app.get('/server-monitoring', function(req, res) {
res.redirect('/product/server-monitoring');
2020-10-08 10:46:25 +00:00
});
2020-11-20 06:57:46 +00:00
app.get('/product/website-monitoring', function(req, res) {
res.render('website-monitoring', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
});
app.get('/website-monitoring', function(req, res) {
res.redirect('/product/website-monitoring');
});
app.get('/product/iot-device-monitoring', function(req, res) {
res.render('iot-device-monitoring', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
});
app.get('/iot-device-monitoring', function(req, res) {
res.redirect('/product/iot-device-monitoring');
});
2020-10-12 21:22:25 +00:00
app.get('/product/incident-management', function(req, res) {
2020-10-08 09:41:19 +00:00
res.render('incident-management', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
});
2020-10-12 21:22:25 +00:00
app.get('/incident-management', function(req, res) {
res.redirect('/product/incident-management');
2020-10-08 10:46:25 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/product/oncall-management', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('oncall-management', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
2019-08-02 12:56:16 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/oncall-management', function(req, res) {
res.redirect('/product/oncall-management');
2020-10-08 10:46:25 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/customers', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('customers', {
support: false,
footerCards: true,
cta: true,
blackLogo: true,
requestDemoCta: false,
});
2019-08-02 12:56:16 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/enterprise/resources', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('resources', {
support: false,
footerCards: false,
cta: true,
blackLogo: true,
requestDemoCta: false,
});
2019-08-02 12:56:16 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/enterprise/overview', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('enterprise-overview.ejs', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: true,
});
2019-08-02 12:56:16 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
section: 'terms',
requestDemoCta: false,
});
2019-08-02 12:56:16 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/terms', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
section: 'terms',
requestDemoCta: false,
});
2019-08-02 12:56:16 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/privacy', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
section: 'privacy',
requestDemoCta: false,
});
2019-08-02 12:56:16 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/contact', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
section: 'contact',
requestDemoCta: false,
});
2019-10-23 19:02:18 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/subprocessors', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
section: 'subprocessors',
requestDemoCta: false,
});
2019-11-03 20:50:18 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/ccpa', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
section: 'ccpa',
requestDemoCta: false,
});
2019-12-19 14:27:37 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/hipaa', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
section: 'hipaa',
requestDemoCta: false,
});
2019-10-23 19:02:18 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/dmca', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
section: 'dmca',
requestDemoCta: false,
});
2019-10-31 19:18:47 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/pci', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
section: 'pci',
requestDemoCta: false,
});
2019-10-24 20:06:44 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/iso-27001', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
section: 'iso-27001',
requestDemoCta: false,
});
2019-10-23 19:14:43 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/iso-27017', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
footerCards: true,
support: false,
cta: true,
blackLogo: false,
section: 'iso-27017',
requestDemoCta: false,
});
2019-11-01 07:41:33 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/iso-27018', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
footerCards: true,
support: false,
cta: true,
blackLogo: false,
section: 'iso-27018',
requestDemoCta: false,
});
2019-10-31 20:49:57 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/iso-27017', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
footerCards: true,
support: false,
cta: true,
blackLogo: false,
section: 'iso-27017',
requestDemoCta: false,
});
2019-10-23 19:14:43 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/iso-27018', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
footerCards: true,
support: false,
cta: true,
blackLogo: false,
section: 'iso-27018',
requestDemoCta: false,
});
2019-10-23 19:14:43 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/soc-2', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
footerCards: true,
support: false,
cta: true,
blackLogo: false,
section: 'soc-2',
requestDemoCta: false,
});
2019-10-23 19:14:43 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/soc-3', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
footerCards: true,
support: false,
cta: true,
blackLogo: false,
section: 'soc-3',
requestDemoCta: false,
});
2019-10-23 19:14:43 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/data-residency', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
footerCards: true,
support: false,
cta: true,
blackLogo: false,
section: 'data-residency',
requestDemoCta: false,
});
2019-10-23 19:02:18 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/gdpr', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
footerCards: true,
support: false,
cta: true,
blackLogo: false,
section: 'gdpr',
requestDemoCta: false,
});
2019-10-23 16:47:44 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/legal/sla', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('legal.ejs', {
footerCards: true,
support: false,
cta: true,
blackLogo: false,
section: 'sla',
requestDemoCta: false,
});
2019-08-02 12:56:16 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/enterprise/download-resource/:resourceName', function(req, res) {
2020-02-27 11:15:46 +00:00
res.render('download-resource.ejs', {
footerCards: false,
support: false,
cta: false,
blackLogo: true,
requestDemoCta: false,
});
2019-08-02 12:56:16 +00:00
});
2020-10-12 21:22:25 +00:00
app.get('/table/:product', function(req, res) {
2020-05-20 07:45:05 +00:00
const productConfig = productCompare(req.params.product);
if (!productConfig) {
res.status(404);
res.render('notFound.ejs', {
footerCards: false,
support: false,
cta: false,
blackLogo: false,
requestDemoCta: false,
});
} else {
res.render('product-compare.ejs', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
productConfig,
2020-05-20 08:02:25 +00:00
onlyShowCompareTable: true,
2020-05-20 07:45:05 +00:00
});
}
});
2020-10-12 21:22:25 +00:00
app.get('/compare/:product', function(req, res) {
2020-04-26 20:49:35 +00:00
const productConfig = productCompare(req.params.product);
if (!productConfig) {
res.status(404);
res.render('notFound.ejs', {
footerCards: false,
support: false,
cta: false,
blackLogo: false,
requestDemoCta: false,
});
2020-04-27 08:09:51 +00:00
} else {
res.render('product-compare.ejs', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
productConfig,
2020-05-20 08:02:25 +00:00
onlyShowCompareTable: false,
2020-04-27 08:09:51 +00:00
});
}
});
2020-04-11 21:55:08 +00:00
// minify default.js
2020-10-12 21:22:25 +00:00
app.get('/js/default.js', async function(req, res) {
2020-04-11 22:06:55 +00:00
res.setHeader('Content-Type', 'text/javascript');
2020-04-11 21:55:08 +00:00
//eslint-disable-next-line
const [error, data] = await tryToCatch(minify, './public/js/default.js');
res.send(data);
});
2020-04-11 22:05:50 +00:00
// minify
2020-10-12 21:22:25 +00:00
app.get('/css/home.css', async function(req, res) {
2020-04-11 22:06:55 +00:00
res.setHeader('Content-Type', 'text/css');
2020-04-11 22:05:50 +00:00
//eslint-disable-next-line
const [error, data] = await tryToCatch(minify, './public/css/home.css');
res.send(data);
});
// minify
2020-10-12 21:22:25 +00:00
app.get('/css/comparision.css', async function(req, res) {
2020-04-11 22:06:55 +00:00
res.setHeader('Content-Type', 'text/css');
2020-04-11 22:05:50 +00:00
//eslint-disable-next-line
const [error, data] = await tryToCatch(
minify,
'./public/css/comparision.css'
);
res.send(data);
});
2020-09-03 17:07:55 +00:00
// cache policy for static contents
// loads up the site faster
app.use(
express.static(path.join(__dirname, 'public'), {
setHeaders(res) {
res.setHeader('Cache-Control', 'public,max-age=31536000,immutable');
},
})
);
2019-08-02 12:56:16 +00:00
2020-10-12 21:22:25 +00:00
app.get('/*', function(req, res) {
2020-04-11 21:31:40 +00:00
res.status(404);
2020-02-27 11:15:46 +00:00
res.render('notFound.ejs', {
footerCards: false,
support: false,
cta: false,
blackLogo: false,
requestDemoCta: false,
});
2019-08-02 12:56:16 +00:00
});
app.set('port', process.env.PORT || 1444);
2020-10-12 21:22:25 +00:00
app.listen(app.get('port'), function() {
2020-02-27 11:15:46 +00:00
//eslint-disable-next-line
console.log('Server running on port : ' + app.get('port'));
2019-08-02 12:56:16 +00:00
});