oneuptime/Home/Index.ts

977 lines
29 KiB
TypeScript
Raw Normal View History

2022-07-05 14:14:54 +00:00
import 'ejs';
2022-06-13 20:23:16 +00:00
import Express, {
2022-03-21 21:50:11 +00:00
ExpressRequest,
ExpressResponse,
ExpressStatic,
2022-05-31 13:57:15 +00:00
ExpressApplication,
2022-04-10 21:57:14 +00:00
} from 'CommonServer/Utils/Express';
2022-05-24 16:46:21 +00:00
import App from 'CommonServer/Utils/StartServer';
2022-04-17 13:45:06 +00:00
import Dictionary from 'Common/Types/Dictionary';
2022-02-27 12:24:02 +00:00
import path from 'path';
2022-02-28 12:00:02 +00:00
2022-04-18 14:38:26 +00:00
import OneUptimeDate from 'Common/Types/Date';
2022-04-17 13:45:06 +00:00
import URL from 'Common/Types/API/URL';
2022-04-18 14:38:26 +00:00
import productCompare, { Product } from './config/product-compare';
2022-02-27 12:24:02 +00:00
import builder from 'xmlbuilder2';
2022-04-17 13:45:06 +00:00
import { XMLBuilder } from 'xmlbuilder2/lib/interfaces';
2023-01-25 20:32:35 +00:00
import API from 'Common/Utils/API';
import { JSONObject } from 'Common/Types/JSON';
2023-01-29 15:32:12 +00:00
import HTTPResponse from 'Common/Types/API/HTTPResponse';
import HTTPErrorResponse from 'Common/Types/API/HTTPErrorResponse';
2019-08-02 12:56:16 +00:00
2022-05-24 16:46:21 +00:00
export const APP_NAME: string = 'home';
2022-06-13 20:23:16 +00:00
const app: ExpressApplication = Express.getExpressApp();
2022-05-24 16:46:21 +00:00
2019-08-02 12:56:16 +00:00
//View engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
2021-11-26 20:19:51 +00:00
/**
* @param {string} val : The value to be parsed.
* @description Resolves or Parses any value to boolean value.
* @returns Boolean true or false
*/
2019-08-02 12:56:16 +00:00
//Routes
2022-03-21 21:50:11 +00:00
app.get('/', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2023-01-25 20:32:35 +00:00
app.get('/support', async (_req: ExpressRequest, res: ExpressResponse) => {
res.render('support');
2019-08-02 12:56:16 +00:00
});
2022-03-21 21:50:11 +00:00
app.get('/pricing', (_req: ExpressRequest, res: ExpressResponse) => {
2023-01-29 15:32:12 +00:00
const pricing: Array<JSONObject> = [
2023-01-25 22:17:55 +00:00
{
name: 'Status Page',
data: [
{
name: 'Public Status Page',
plans: {
free: 'Unlimited',
growth: 'Unlimited',
scale: 'Unlimited',
enterprise: 'Unlimited',
},
},
{
name: 'Subscribers',
plans: {
free: 'Unlimited',
growth: 'Unlimited',
scale: 'Unlimited',
enterprise: 'Unlimited',
},
},
{
2023-03-16 12:35:20 +00:00
name: 'Custom Branding',
2023-01-25 22:17:55 +00:00
plans: {
free: true,
growth: true,
scale: true,
enterprise: true,
},
},
{
2023-03-16 12:35:20 +00:00
name: 'SSL Certificate',
2023-01-25 22:17:55 +00:00
plans: {
free: true,
growth: true,
scale: true,
enterprise: true,
},
},
{
2023-03-16 12:35:20 +00:00
name: 'Custom Domain',
2023-01-25 22:17:55 +00:00
plans: {
2023-04-04 10:31:50 +00:00
free: true,
2023-01-25 22:17:55 +00:00
growth: true,
scale: true,
enterprise: true,
},
},
{
name: 'Private Status Page',
plans: {
free: false,
growth: 'Unlimited',
scale: 'Unlimited',
enterprise: 'Unlimited',
},
},
{
name: 'Private Status Page Users',
plans: {
free: false,
growth: 'Unlimited',
scale: 'Unlimited',
enterprise: 'Unlimited',
},
},
],
},
{
name: 'Incident Management',
data: [
{
name: 'Basic Incident Management',
plans: {
free: true,
growth: true,
scale: true,
enterprise: true,
},
},
{
name: 'Public Postmortem Notes',
plans: {
free: true,
growth: true,
scale: true,
enterprise: true,
},
},
{
name: 'Private Postmortem Notes',
plans: {
free: false,
growth: true,
scale: true,
enterprise: true,
},
},
{
name: 'Incident Workflows',
plans: {
free: false,
growth: true,
scale: true,
enterprise: true,
},
},
{
name: 'Custom Incident State',
plans: {
free: false,
growth: true,
scale: true,
enterprise: true,
},
},
{
name: 'Custom Incident Severity',
plans: {
free: false,
growth: true,
scale: true,
enterprise: true,
},
},
],
},
{
name: 'Monitoring',
data: [
{
name: 'Static / Manual Monitors',
plans: {
free: true,
growth: true,
scale: true,
enterprise: true,
},
},
{
name: 'Website Monitoring',
plans: {
2023-05-09 10:17:16 +00:00
free: true,
growth: true,
scale: true,
enterprise: true,
2023-01-25 22:17:55 +00:00
},
},
{
name: 'API Monitoring',
plans: {
2023-05-09 10:17:16 +00:00
free: true,
growth: true,
scale: true,
enterprise: true,
2023-01-25 22:17:55 +00:00
},
},
2023-01-25 22:17:55 +00:00
{
name: 'IPv4 Monitoring',
plans: {
2023-05-09 10:17:16 +00:00
free: true,
growth: true,
scale: true,
enterprise: true,
2023-01-25 22:17:55 +00:00
},
},
{
name: 'IPv6 Monitoring',
plans: {
2023-05-09 10:17:16 +00:00
free: true,
growth: true,
scale: true,
enterprise: true,
2023-01-25 22:17:55 +00:00
},
},
{
2023-05-09 10:17:16 +00:00
name: 'Container Monitoring',
2023-01-25 22:17:55 +00:00
plans: {
free: 'Coming Soon',
growth: 'Coming Soon',
scale: 'Coming Soon',
enterprise: 'Coming Soon',
},
},
2023-01-25 22:17:55 +00:00
{
name: 'VM or Server Monitoring',
plans: {
free: 'Coming Soon',
growth: 'Coming Soon',
scale: 'Coming Soon',
enterprise: 'Coming Soon',
},
},
{
name: 'Network Monitoring',
plans: {
free: 'Coming Soon',
growth: 'Coming Soon',
scale: 'Coming Soon',
enterprise: 'Coming Soon',
},
},
{
name: 'Kubernetes Cluster Monitoring',
plans: {
free: 'Coming Soon',
growth: 'Coming Soon',
scale: 'Coming Soon',
enterprise: 'Coming Soon',
},
},
],
},
{
2023-07-29 20:10:45 +00:00
name: 'On-Call and Alerts',
2023-01-25 22:17:55 +00:00
data: [
{
name: 'Phone Alerts',
plans: {
2023-07-08 13:51:54 +00:00
free: true,
growth: true,
scale: true,
enterprise: true,
2023-01-25 22:17:55 +00:00
},
},
{
name: 'SMS Alerts',
plans: {
2023-07-08 13:51:54 +00:00
free: true,
growth: true,
scale: true,
enterprise: true,
2023-01-25 22:17:55 +00:00
},
},
{
name: 'Email Alerts',
plans: {
2023-07-08 13:51:54 +00:00
free: true,
growth: true,
scale: true,
enterprise: true,
2023-01-25 22:17:55 +00:00
},
},
{
2023-07-08 13:51:54 +00:00
name: 'On-Call Escalation',
2023-01-25 22:17:55 +00:00
plans: {
2023-07-08 13:51:54 +00:00
free: false,
growth: true,
scale: true,
enterprise: true,
2023-01-25 22:17:55 +00:00
},
},
{
2023-07-08 13:51:54 +00:00
name: 'Advanced Workflows',
plans: {
free: false,
growth: true,
scale: true,
enterprise: true,
},
},
{
name: 'Logs and Events',
plans: {
free: false,
growth: true,
scale: true,
enterprise: true,
},
},
{
name: 'Webhook Alerts',
2023-01-25 22:17:55 +00:00
plans: {
free: 'Coming Soon',
growth: 'Coming Soon',
scale: 'Coming Soon',
enterprise: 'Coming Soon',
},
},
{
2023-07-08 13:51:54 +00:00
name: 'On-Call Rotation',
2023-01-25 22:17:55 +00:00
plans: {
free: 'Coming Soon',
growth: 'Coming Soon',
scale: 'Coming Soon',
enterprise: 'Coming Soon',
},
},
{
2023-07-08 13:51:54 +00:00
name: 'Vacation and OOO Policy',
2023-01-25 22:17:55 +00:00
plans: {
free: 'Coming Soon',
growth: 'Coming Soon',
scale: 'Coming Soon',
enterprise: 'Coming Soon',
},
},
2023-07-09 11:53:50 +00:00
2023-01-25 22:17:55 +00:00
{
name: 'On-Call Pay',
plans: {
free: 'Coming Soon',
growth: 'Coming Soon',
scale: 'Coming Soon',
enterprise: 'Coming Soon',
},
},
2023-07-08 13:51:54 +00:00
2023-01-25 22:17:55 +00:00
{
name: 'Reports',
plans: {
free: 'Coming Soon',
growth: 'Coming Soon',
scale: 'Coming Soon',
enterprise: 'Coming Soon',
},
},
],
},
{
name: 'Support and More',
data: [
{
name: 'Support',
plans: {
free: 'Community Support',
growth: 'Email Support',
scale: 'Email and Chat Support',
enterprise: 'Email, Chat, Phone Support',
},
},
{
name: 'Support SLA',
plans: {
free: false,
growth: '1 business day',
scale: '6 hours',
enterprise: '1 hour priority',
},
},
{
name: 'Service SLA',
plans: {
free: false,
growth: '99.90%',
scale: '99.95%',
enterprise: '99.99%',
},
},
],
},
{
name: 'Advanced Features',
data: [
{
name: 'API Access',
plans: {
free: false,
growth: true,
scale: true,
enterprise: true,
},
},
{
name: 'Advanced Workflows',
plans: {
free: false,
2023-02-24 21:42:00 +00:00
growth: '500 Runs / month',
scale: '2000 Runs /month',
enterprise: 'Unlimited Runs',
2023-01-25 22:17:55 +00:00
},
},
{
name: '5000+ Integrations',
plans: {
free: false,
growth: true,
scale: true,
enterprise: true,
},
},
],
},
{
name: 'Billing',
data: [
{
name: 'Billing Period',
plans: {
free: 'Free',
growth: 'Monthly or Yearly',
scale: 'Monthly or Yearly',
enterprise: 'Custom',
},
},
{
name: 'Payment Method',
plans: {
free: false,
growth: 'Visa / Mastercard / Amex / Bitcoin',
scale: 'Visa / Mastercard / Amex / Bitcoin',
enterprise:
'Visa / Mastercard / Amex / ACH / Invoices / Bitcoin',
},
},
{
name: 'Cancel Anytime',
plans: {
free: true,
growth: true,
scale: true,
enterprise: true,
},
},
],
},
];
2023-01-25 20:32:35 +00:00
2020-02-27 11:15:46 +00:00
res.render('pricing', {
2023-01-25 22:17:55 +00:00
pricing,
2020-02-27 11:15:46 +00:00
});
2019-08-02 12:56:16 +00:00
});
2022-03-21 21:50:11 +00:00
app.get('/enterprise/demo', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-12-22 14:41:45 +00:00
app.get(
'/product/status-page',
(_req: ExpressRequest, res: ExpressResponse) => {
2023-01-30 09:09:06 +00:00
res.render('status-page');
2022-12-22 14:41:45 +00:00
}
);
2019-08-02 12:56:16 +00:00
2023-01-02 14:18:59 +00:00
app.get('/status', (_req: ExpressRequest, res: ExpressResponse) => {
res.status(200).send({ status: 'ok' });
});
2023-01-02 14:18:21 +00:00
2022-12-22 14:38:06 +00:00
app.get('/status-page', (_req: ExpressRequest, res: ExpressResponse) => {
2023-01-24 20:24:58 +00:00
res.redirect('/product/status-page');
});
2023-01-27 11:45:11 +00:00
let gitHubContributors: Array<JSONObject> = [];
2023-01-29 15:32:12 +00:00
let gitHubBasicInfo: JSONObject | null = null;
let gitHubCommits: string = '-';
2023-01-27 11:45:11 +00:00
2023-01-25 20:32:35 +00:00
app.get('/about', async (_req: ExpressRequest, res: ExpressResponse) => {
2023-01-27 11:45:11 +00:00
if (gitHubContributors.length === 0) {
let contributors: Array<JSONObject> = [];
2023-01-25 20:32:35 +00:00
2023-01-29 15:32:12 +00:00
let hasMoreContributors: boolean = true;
2023-01-25 20:32:35 +00:00
2023-01-29 15:32:12 +00:00
let pageNumber: number = 1;
2023-01-27 11:45:11 +00:00
while (hasMoreContributors) {
2023-01-29 15:32:12 +00:00
const response:
| HTTPResponse<Array<JSONObject>>
| HTTPErrorResponse = await API.get<Array<JSONObject>>(
2023-02-24 21:42:00 +00:00
URL.fromString(
'https://api.github.com/repos/oneuptime/oneuptime/contributors?page=' +
2023-01-29 15:32:12 +00:00
pageNumber
2023-02-24 21:42:00 +00:00
)
);
2023-01-27 11:45:11 +00:00
pageNumber++;
if ((response.data as Array<JSONObject>).length < 30) {
hasMoreContributors = false;
}
2023-01-29 15:32:12 +00:00
contributors = contributors.concat(
response.data as Array<JSONObject>
);
2023-01-25 20:32:35 +00:00
}
2023-01-29 15:32:12 +00:00
//cache it.
2023-01-27 11:45:11 +00:00
gitHubContributors = [...contributors];
2023-01-25 20:32:35 +00:00
}
2023-01-29 15:32:12 +00:00
const response: HTTPResponse<JSONObject> = await API.get(
2023-01-27 11:45:11 +00:00
URL.fromString(
'https://api.github.com/repos/oneuptime/oneuptime/commits?sha=master&per_page=1&page=1'
)
2023-01-25 22:17:55 +00:00
);
2023-01-27 11:45:11 +00:00
2023-01-29 15:32:12 +00:00
if (gitHubCommits === '-') {
2023-01-27 11:45:11 +00:00
// this is of type: '<https://api.github.com/repositories/380744866/commits?sha=master&per_page=1&page=2>; rel="next", <https://api.github.com/repositories/380744866/commits?sha=master&per_page=1&page=22486>; rel="last"',
2023-01-29 15:32:12 +00:00
const link: string | undefined = response.headers['link'];
const urlString: string | undefined = link
?.split(',')[1]
?.split(';')[0]
?.replace('<', '')
.replace('>', '')
.trim();
const url: URL = URL.fromString(urlString!);
const commits: string = Number.parseInt(
url.getQueryParam('page') as string
).toLocaleString();
2023-01-27 11:45:11 +00:00
if (!gitHubBasicInfo) {
2023-01-29 15:32:12 +00:00
const basicInfo: HTTPResponse<JSONObject> = await API.get(
URL.fromString(
'https://api.github.com/repos/oneuptime/oneuptime'
)
2023-01-27 11:45:11 +00:00
);
gitHubBasicInfo = basicInfo.data as JSONObject;
}
gitHubCommits = commits;
}
2023-01-25 20:32:35 +00:00
res.render('about', {
2023-01-27 14:14:32 +00:00
contributors: gitHubContributors,
2023-01-27 11:45:11 +00:00
basicInfo: gitHubBasicInfo,
2023-01-29 15:32:12 +00:00
commits: gitHubCommits,
2023-01-25 20:32:35 +00:00
});
2020-10-08 10:46:25 +00:00
});
2022-03-21 21:50:11 +00:00
app.get(
2023-01-24 20:24:58 +00:00
'/product/status-page',
2022-03-21 21:50:11 +00:00
(_req: ExpressRequest, res: ExpressResponse) => {
2023-01-24 20:24:58 +00:00
res.render('status-page', {
2022-03-21 21:50:11 +00:00
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: false,
footerCtaText:
'Start with Status Pages, expand into everything else. Sign up today.',
});
}
);
2020-11-20 06:57:46 +00:00
2023-01-24 20:24:58 +00:00
app.get('/status-page', (_req: ExpressRequest, res: ExpressResponse) => {
res.redirect('/product/status-page');
2020-11-20 06:57:46 +00:00
});
2023-07-12 12:36:13 +00:00
app.get('/workflows', (_req: ExpressRequest, res: ExpressResponse) => {
res.redirect('/product/workflows');
});
app.get('/on-call', (_req: ExpressRequest, res: ExpressResponse) => {
res.redirect('/product/on-call');
2023-01-30 09:09:06 +00:00
});
2023-01-30 11:01:20 +00:00
app.get('/product/monitoring', (_req: ExpressRequest, res: ExpressResponse) => {
res.render('monitoring');
});
2023-07-12 12:36:13 +00:00
app.get('/product/on-call', (_req: ExpressRequest, res: ExpressResponse) => {
res.render('on-call');
});
app.get('/product/workflows', (_req: ExpressRequest, res: ExpressResponse) => {
res.render('workflows');
});
2022-03-21 21:50:11 +00:00
app.get(
'/product/incident-management',
(_req: ExpressRequest, res: ExpressResponse) => {
2023-01-31 17:57:32 +00:00
res.render('incident-management');
2022-03-21 21:50:11 +00:00
}
);
2020-10-08 09:41:19 +00:00
2022-03-21 21:50:11 +00:00
app.get(
'/incident-management',
(_req: ExpressRequest, res: ExpressResponse) => {
res.redirect('/product/incident-management');
}
);
2020-10-08 10:46:25 +00:00
2022-03-21 21:50:11 +00:00
app.get(
'/enterprise/overview',
(_req: ExpressRequest, res: ExpressResponse) => {
res.render('enterprise-overview.ejs', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
requestDemoCta: true,
});
}
);
2019-08-02 12:56:16 +00:00
2022-03-21 21:50:11 +00:00
app.get('/legal', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-03-21 21:50:11 +00:00
app.get('/legal/terms', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-03-21 21:50:11 +00:00
app.get('/legal/privacy', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-03-21 21:50:11 +00:00
app.get('/legal/contact', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-03-21 21:50:11 +00:00
app.get(
'/legal/subprocessors',
(_req: ExpressRequest, res: ExpressResponse) => {
res.render('legal.ejs', {
support: false,
footerCards: true,
cta: true,
blackLogo: false,
section: 'subprocessors',
requestDemoCta: false,
});
}
);
2019-11-03 20:50:18 +00:00
2022-03-21 21:50:11 +00:00
app.get('/legal/ccpa', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-03-21 21:50:11 +00:00
app.get('/legal/hipaa', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-03-21 21:50:11 +00:00
app.get('/legal/dmca', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-03-21 21:50:11 +00:00
app.get('/legal/pci', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-03-21 21:50:11 +00:00
app.get('/legal/iso-27001', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-03-21 21:50:11 +00:00
app.get('/legal/iso-27017', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-03-21 21:50:11 +00:00
app.get('/legal/iso-27018', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-03-21 21:50:11 +00:00
app.get('/legal/iso-27017', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-03-21 21:50:11 +00:00
app.get('/legal/iso-27018', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-03-21 21:50:11 +00:00
app.get('/legal/soc-2', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-03-21 21:50:11 +00:00
app.get('/legal/soc-3', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-03-21 21:50:11 +00:00
app.get(
'/legal/data-residency',
(_req: ExpressRequest, res: ExpressResponse) => {
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
2022-03-21 21:50:11 +00:00
app.get('/legal/gdpr', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-03-21 21:50:11 +00:00
app.get('/legal/sla', (_req: ExpressRequest, res: ExpressResponse) => {
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
});
2022-03-21 21:48:14 +00:00
app.get('/compare/:product', (req: ExpressRequest, res: ExpressResponse) => {
2022-04-20 21:10:01 +00:00
const productConfig: Product = productCompare(
req.params['product'] as string
);
if (!productConfig) {
res.status(404);
2023-01-29 13:23:08 +00:00
res.render('not-found.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
});
}
});
2022-04-15 22:14:01 +00:00
// Generate sitemap
2022-03-21 21:50:11 +00:00
app.get('/sitemap.xml', async (_req: ExpressRequest, res: ExpressResponse) => {
2022-04-17 13:45:06 +00:00
const siteUrls: Array<URL> = [
URL.fromString('https://oneuptime.com/'),
URL.fromString('https://oneuptime.com/pricing'),
URL.fromString('https://oneuptime.com/support'),
2023-01-31 17:57:32 +00:00
URL.fromString('https://oneuptime.com/about'),
2023-01-24 20:24:58 +00:00
URL.fromString('https://oneuptime.com/product/status-page'),
2022-04-17 13:45:06 +00:00
URL.fromString('https://oneuptime.com/product/incident-management'),
2023-01-31 17:57:32 +00:00
URL.fromString('https://oneuptime.com/product/on-call'),
2022-04-17 13:45:06 +00:00
URL.fromString('https://oneuptime.com/enterprise/overview'),
URL.fromString('https://oneuptime.com/enterprise/demo'),
URL.fromString('https://oneuptime.com/legal/terms'),
URL.fromString('https://oneuptime.com/legal/privacy'),
URL.fromString('https://oneuptime.com/legal/gdpr'),
URL.fromString('https://oneuptime.com/legal/ccpa'),
URL.fromString('https://oneuptime.com/legal'),
URL.fromString('https://oneuptime.com/compare/pagerduty'),
URL.fromString('https://oneuptime.com/compare/pingdom'),
2022-12-22 14:38:06 +00:00
URL.fromString('https://oneuptime.com/compare/status-page.io'),
2023-01-31 17:57:32 +00:00
URL.fromString('https://oneuptime.com/compare/incident.io'),
2022-04-17 13:45:06 +00:00
URL.fromString('https://oneuptime.com/legal/soc-2'),
URL.fromString('https://oneuptime.com/legal/soc-3'),
URL.fromString('https://oneuptime.com/legal/iso-27017'),
URL.fromString('https://oneuptime.com/legal/iso-27018'),
URL.fromString('https://oneuptime.com/legal/hipaa'),
URL.fromString('https://oneuptime.com/legal/pci'),
URL.fromString('https://oneuptime.com/legal/sla'),
URL.fromString('https://oneuptime.com/legal/iso-27001'),
URL.fromString('https://oneuptime.com/legal/data-residency'),
URL.fromString('https://oneuptime.com/legal/dmca'),
URL.fromString('https://oneuptime.com/legal/subprocessors'),
URL.fromString('https://oneuptime.com/legal/contact'),
2021-07-09 15:47:27 +00:00
];
2022-04-15 22:14:01 +00:00
// Build xml
2022-04-18 14:38:26 +00:00
const urlsetAttr: Dictionary<string> = {
xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9',
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation':
'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd',
};
2021-07-09 15:47:27 +00:00
2022-04-15 22:14:01 +00:00
// Get previous day's date/timestamp
2022-04-18 14:38:26 +00:00
const today: Date = OneUptimeDate.getOneDayAgo();
const timestamp: string = today.toISOString();
2021-07-09 15:47:27 +00:00
2022-04-17 13:45:06 +00:00
const urlset: XMLBuilder = builder.create().ele('urlset');
2021-07-09 15:47:27 +00:00
2022-04-15 22:14:01 +00:00
// Apply attributes to root element
2022-04-18 14:38:26 +00:00
for (const key in urlsetAttr) {
urlset.att({ key: urlsetAttr[key] });
}
2021-07-09 15:47:27 +00:00
2022-04-15 22:14:01 +00:00
//Append urls to root element
2022-04-18 14:38:26 +00:00
siteUrls.forEach((url: URL) => {
const urlElement: XMLBuilder = urlset.ele('url');
urlElement.ele('loc').txt(url.toString());
2021-07-09 15:47:27 +00:00
urlElement.ele('lastmod').txt(timestamp);
});
2022-04-15 22:14:01 +00:00
// Generate xml file
2022-04-18 14:38:26 +00:00
const xml: string = urlset.end({ prettyPrint: true });
2021-07-09 15:47:27 +00:00
res.setHeader('Content-Type', 'text/xml');
res.send(xml);
});
2022-04-15 22:14:01 +00:00
/*
* Cache policy for static contents
* Loads up the site faster
*/
2020-09-03 17:07:55 +00:00
app.use(
2022-03-21 21:50:11 +00:00
ExpressStatic(path.join(__dirname, 'public'), {
setHeaders(res: ExpressResponse) {
2020-09-03 17:07:55 +00:00
res.setHeader('Cache-Control', 'public,max-age=31536000,immutable');
},
})
);
2019-08-02 12:56:16 +00:00
2022-03-21 21:50:11 +00:00
app.get('/*', (_req: ExpressRequest, res: ExpressResponse) => {
2020-04-11 21:31:40 +00:00
res.status(404);
2023-01-29 13:23:08 +00:00
res.render('not-found.ejs', {
2020-02-27 11:15:46 +00:00
footerCards: false,
support: false,
cta: false,
blackLogo: false,
requestDemoCta: false,
});
2019-08-02 12:56:16 +00:00
});
2022-06-13 20:23:16 +00:00
2022-06-21 19:35:22 +00:00
App(APP_NAME);