oneuptime/home/server.js

492 lines
11 KiB
JavaScript
Raw Normal View History

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');
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 }));
2019-08-02 12:56:16 +00:00
app.use(compression());
//View engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
//Routes
2020-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-08-05 16:40:29 +00:00
app.get('/product/logs-management', function(req, res) {
res.render('logs-management', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
});
app.get('/product/docker-container-security', function(req, res) {
res.render('container-security', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
});
app.get('/product/app-security', function(req, res) {
res.render('app-security', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
});
2020-10-08 09:23:52 +00:00
app.get('/product/api-monitoring', function(req, res) {
res.render('api-monitoring', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
});
app.get('/product/server-monitoring', function(req, res) {
res.render('server-monitoring', {
2020-08-05 16:40:29 +00:00
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
});
});
2020-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-05-20 07:45:05 +00:00
app.get('/table/:product', function(req, res) {
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-04-26 20:49:35 +00:00
app.get('/compare/:product', function(req, res) {
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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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-04-26 20:49:35 +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
});