From dc37d723e634fa83f747da9a748ac100fca22bd4 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Mon, 16 Sep 2024 07:49:29 -0700 Subject: [PATCH] Initialize Home module with configuration files and update package name --- App/Index.ts | 4 - Home/.dockerignore | 56 ++ Home/.gitattributes | 1 + Home/.gitignore | 30 + Home/Dockerfile.tpl | 66 ++ Home/Index.ts | 1401 ++----------------------------------------- Home/README.md | 29 + Home/Routes.ts | 1367 +++++++++++++++++++++++++++++++++++++++++ Home/nodemon.json | 8 + Home/package.json | 2 +- Home/tsconfig.json | 112 ++++ 11 files changed, 1713 insertions(+), 1363 deletions(-) create mode 100755 Home/.dockerignore create mode 100644 Home/.gitattributes create mode 100755 Home/.gitignore create mode 100644 Home/Dockerfile.tpl mode change 100755 => 100644 Home/Index.ts create mode 100755 Home/README.md create mode 100755 Home/Routes.ts create mode 100644 Home/nodemon.json create mode 100644 Home/tsconfig.json diff --git a/App/Index.ts b/App/Index.ts index ec10c2c9e4..24153513e7 100755 --- a/App/Index.ts +++ b/App/Index.ts @@ -1,7 +1,6 @@ import APIReferenceRoutes from "./FeatureSet/ApiReference/Index"; import BaseAPIRoutes from "./FeatureSet/BaseAPI/Index"; import DocsRoutes from "./FeatureSet/Docs/Index"; -import HomeRoutes from "../Home/Index"; // import FeatureSets. import IdentityRoutes from "./FeatureSet/Identity/Index"; import NotificationRoutes from "./FeatureSet/Notification/Index"; @@ -68,9 +67,6 @@ const init: PromiseVoidFunction = async (): Promise => { await Workers.init(); await Workflow.init(); - // Initialize home routes at the end since it has a catch-all route - await HomeRoutes.init(); - // Add default routes to the app await App.addDefaultRoutes(); } catch (err) { diff --git a/Home/.dockerignore b/Home/.dockerignore new file mode 100755 index 0000000000..3ff05dd7b8 --- /dev/null +++ b/Home/.dockerignore @@ -0,0 +1,56 @@ +.git + +node_modules +# See https://help.github.com/ignore-files/ for more about ignoring files. + +# dependencies +/node_modules +node_modules + +.idea +# testing +/coverage + +# production +/build + +# misc +.DS_Store + +env.js + +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +yarn.lock +Untitled-1 +*.local.sh +*.local.yaml +run +stop + +nohup.out* + +encrypted-credentials.tar +encrypted-credentials/ + +_README.md + +# Important Add production values to gitignore. +values-saas-production.yaml +kubernetes/values-saas-production.yaml + +/private + +/tls_cert.pem +/tls_key.pem +/keys + +temp_readme.md + +tests/coverage + +settings.json + +GoSDK/tester/ \ No newline at end of file diff --git a/Home/.gitattributes b/Home/.gitattributes new file mode 100644 index 0000000000..30ddbbb6cb --- /dev/null +++ b/Home/.gitattributes @@ -0,0 +1 @@ +*.js text eol=lf \ No newline at end of file diff --git a/Home/.gitignore b/Home/.gitignore new file mode 100755 index 0000000000..d69202ec7a --- /dev/null +++ b/Home/.gitignore @@ -0,0 +1,30 @@ +# See https://help.github.com/ignore-files/ for more about ignoring files. + +# dependencies +#/backend/node_modules +/kubernetes +/node_modules +.idea + +# misc +.DS_Store + + +npm-debug.log* +yarn-debug.log* +yarn-error.log* +yarn.lock + +**/*/paymentService.test.js +apiTest.rest + +application_security_dir +container_security_dir + +# coverage +/coverage +/.nyc_output + +/greenlock.d/config.json +/greenlock.d/config.json.bak +/.greenlockrc \ No newline at end of file diff --git a/Home/Dockerfile.tpl b/Home/Dockerfile.tpl new file mode 100644 index 0000000000..bbdd665fd1 --- /dev/null +++ b/Home/Dockerfile.tpl @@ -0,0 +1,66 @@ +# +# OneUptime-App Dockerfile +# + +# Pull base image nodejs image. +FROM node:21.2-alpine3.18 +RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global + +RUN npm config set fetch-retries 5 +RUN npm config set fetch-retry-mintimeout 100000 +RUN npm config set fetch-retry-maxtimeout 600000 + +ARG GIT_SHA +ARG APP_VERSION + +ENV GIT_SHA=${GIT_SHA} +ENV APP_VERSION=${APP_VERSION} + +# IF APP_VERSION is not set, set it to 1.0.0 +RUN if [ -z "$APP_VERSION" ]; then export APP_VERSION=1.0.0; fi + +# Install bash. +RUN apk add bash && apk add curl + + +# Install python +RUN apk update && apk add --no-cache --virtual .gyp python3 make g++ + +#Use bash shell by default +SHELL ["/bin/bash", "-c"] + + +RUN mkdir /usr/src + +WORKDIR /usr/src/Common +COPY ./Common/package*.json /usr/src/Common/ +# Set version in ./Common/package.json to the APP_VERSION +RUN sed -i "s/\"version\": \".*\"/\"version\": \"$APP_VERSION\"/g" /usr/src/Common/package.json +RUN npm install +COPY ./Common /usr/src/Common + +ENV PRODUCTION=true + +WORKDIR /usr/src/app + +# Install app dependencies +COPY ./Home/package*.json /usr/src/app/ +# Set version in ./App/package.json to the APP_VERSION +RUN sed -i "s/\"version\": \".*\"/\"version\": \"$APP_VERSION\"/g" /usr/src/app/package.json +RUN npm install + +# Expose ports. +# - 1444: OneUptime-home +EXPOSE 1444 + +{{ if eq .Env.ENVIRONMENT "development" }} +#Run the app +CMD [ "npm", "run", "dev" ] +{{ else }} +# Copy app source +COPY ./Home /usr/src/app +# Bundle app source +RUN npm run compile +#Run the app +CMD [ "npm", "start" ] +{{ end }} diff --git a/Home/Index.ts b/Home/Index.ts old mode 100755 new mode 100644 index 58fa00cf78..01b3387301 --- a/Home/Index.ts +++ b/Home/Index.ts @@ -1,1367 +1,52 @@ -// improt API -import "./API/BlogAPI"; -import { StaticPath, ViewsPath } from "./Utils/Config"; -import NotFoundUtil from "./Utils/NotFound"; -import ProductCompare, { Product } from "./Utils/ProductCompare"; -import HTTPErrorResponse from "Common/Types/API/HTTPErrorResponse"; -import HTTPResponse from "Common/Types/API/HTTPResponse"; -import URL from "Common/Types/API/URL"; -import OneUptimeDate from "Common/Types/Date"; -import Dictionary from "Common/Types/Dictionary"; -import { JSONObject } from "Common/Types/JSON"; -import API from "Common/Utils/API"; -import FeatureSet from "Common/Server/Types/FeatureSet"; -import Express, { - ExpressApplication, - ExpressRequest, - ExpressResponse, - ExpressStatic, -} from "Common/Server/Utils/Express"; +import HomeRoutes from "./Routes"; +import { PromiseVoidFunction } from "Common/Types/FunctionTypes"; +import InfrastructureStatus from "Common/Server/Infrastructure/Status"; +import logger from "Common/Server/Utils/Logger"; +import App from "Common/Server/Utils/StartServer"; +import Telemetry from "Common/Server/Utils/Telemetry"; import "ejs"; -import builder from "xmlbuilder2"; -import { XMLBuilder } from "xmlbuilder2/lib/interfaces"; -import OSSFriends, { OSSFriend } from "./Utils/OSSFriends"; -import Reviews from "./Utils/Reviews"; -const HomeFeatureSet: FeatureSet = { - init: async (): Promise => { - const app: ExpressApplication = Express.getExpressApp(); +const APP_NAME: string = "home"; - //Routes - app.get("/", (_req: ExpressRequest, res: ExpressResponse) => { - const { reviewsList1, reviewsList2, reviewsList3 } = Reviews; +const init: PromiseVoidFunction = async (): Promise => { + try { + // Initialize telemetry + Telemetry.init({ + serviceName: APP_NAME, + }); - res.render(`${ViewsPath}/index`, { - support: false, - footerCards: true, - cta: true, - blackLogo: false, - requestDemoCta: false, - reviewsList1, - reviewsList2, - reviewsList3, + const statusCheck: PromiseVoidFunction = async (): Promise => { + // Check the status of infrastructure components + return await InfrastructureStatus.checkStatus({ + checkClickhouseStatus: false, + checkPostgresStatus: false, + checkRedisStatus: false, }); + }; + + // Initialize the app with service name and status checks + await App.init({ + appName: APP_NAME, + statusOptions: { + liveCheck: statusCheck, + readyCheck: statusCheck, + }, }); - app.get( - "/infrastructure-agent/install.sh", - (_req: ExpressRequest, res: ExpressResponse) => { - // fetch the file from https://raw.githubusercontent.com/oneuptime/infrastructure-agent/release/Scripts/Install/Linux.sh and send it as response - res.redirect( - "https://raw.githubusercontent.com/OneUptime/oneuptime/release/InfrastructureAgent/Scripts/Install/Linux.sh", - ); - }, - ); - - app.get("/support", async (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/support`); - }); - - app.get( - "/oss-friends", - async (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/oss-friends`, { - ossFriends: OSSFriends.map((friend: OSSFriend) => { - return { - ...friend, - repositoryUrl: friend.repositoryUrl.toString(), - }; - }), - }); - }, - ); - - app.get("/pricing", (_req: ExpressRequest, res: ExpressResponse) => { - const pricing: Array = [ - { - name: "Status Page", - data: [ - { - name: "Public Status Page", - plans: { - free: "1", - growth: "Unlimited", - scale: "Unlimited", - enterprise: "Unlimited", - }, - }, - { - name: "Subscribers", - plans: { - free: "100", - growth: "Unlimited", - scale: "Unlimited", - enterprise: "Unlimited", - }, - }, - { - name: "Custom Branding", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "SSL Certificate", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Custom Domain", - plans: { - free: true, - 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: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "API Monitoring", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Synthetic Monitoring (with Playwright)", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - - { - name: "IPv4 Monitoring", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - - { - name: "IPv6 Monitoring", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Inbound Webhook / Heartbeat Monitoring", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "VM or Server Monitoring", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Network Monitoring", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Container 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", - }, - }, - ], - }, - { - name: "On-Call and Alerts", - data: [ - { - name: "Phone Alerts", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "SMS Alerts", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Email Alerts", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "On-Call Escalation", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Advanced Workflows", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "On-Call Rotation", - 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", - plans: { - free: "Coming Soon", - growth: "Coming Soon", - scale: "Coming Soon", - enterprise: "Coming Soon", - }, - }, - - { - name: "Vacation and OOO Policy", - plans: { - free: "Coming Soon", - growth: "Coming Soon", - scale: "Coming Soon", - enterprise: "Coming Soon", - }, - }, - - { - name: "On-Call Pay", - plans: { - free: "Coming Soon", - growth: "Coming Soon", - scale: "Coming Soon", - enterprise: "Coming Soon", - }, - }, - - { - name: "Reports", - plans: { - free: "Coming Soon", - growth: "Coming Soon", - scale: "Coming Soon", - enterprise: "Coming Soon", - }, - }, - ], - }, - { - name: "Logs Management", - data: [ - { - name: "Ingest with OpenTelemetry", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Ingest with Fluentd", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Ingest +1000 Sources", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Application Logs", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Container Logs", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Data Rentention", - plans: { - free: "15 days", - growth: "Custom", - scale: "Custom", - enterprise: "Custom", - }, - }, - { - name: "Workflows", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Advanced Team Permissions", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - ], - }, - { - name: "Telemetry / APM", - data: [ - { - name: "Metrics", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Traces", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Error Tracking", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Ingest Pricing", - plans: { - free: "$0.10/GB", - growth: "$0.10/GB", - scale: "$0.10/GB", - enterprise: "$0.10/GB", - }, - }, - { - name: "Data Rentention", - plans: { - free: "15 days", - growth: "Custom", - scale: "Custom", - enterprise: "Custom", - }, - }, - { - name: "Workflows", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Advanced Team Permissions", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - ], - }, - { - name: "Error Tracking", - data: [ - { - name: "Track Errors and Exceptions", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Cross Microservice Issues", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Distributed Tracing", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Stack Traces", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Version Management", - plans: { - free: true, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Data Rentention", - plans: { - free: "15 days", - growth: "Custom", - scale: "Custom", - enterprise: "Custom", - }, - }, - { - name: "Workflows", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Advanced Team Permissions", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - ], - }, - { - name: "Reliability Copilot", - data: [ - { - name: "Scan your Codebase", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Fix Errors Automatically", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Fix Performance Issues", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Fix DB Queries Automatically", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Fix Frontend Issues", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Integrate with GitHub, GitLab", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Integrate with CI/CD", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Integrate with Issue Tracker", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Integrates with Slack / Team", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - { - name: "Advanced Workflows", - plans: { - free: false, - growth: true, - scale: true, - enterprise: true, - }, - }, - ], - }, - { - name: "Support and More", - data: [ - { - name: "Support", - plans: { - free: "Email Support", - growth: "Email Support", - scale: "Email and Chat Support", - enterprise: "Email, Chat, Phone Support", - }, - }, - { - name: "Support SLA", - plans: { - free: "5 business day", - growth: "1 business day", - scale: "6 hours", - enterprise: "1 hour priority", - }, - }, - { - name: "Service SLA", - plans: { - free: "99.00%", - 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, - growth: "500 Runs / month", - scale: "2000 Runs /month", - enterprise: "Unlimited Runs", - }, - }, - { - 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, - }, - }, - ], - }, - ]; - - res.render(`${ViewsPath}/pricing`, { - pricing, - }); - }); - - app.get( - "/enterprise/demo", - (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/demo`, { - support: false, - footerCards: false, - cta: false, - blackLogo: true, - requestDemoCta: false, - }); - }, - ); - - app.get( - "/product/status-page", - (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/status-page`); - }, - ); - - app.get( - "/product/logs-management", - (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/logs-management`); - }, - ); - - app.get("/product/apm", (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/apm`); - }); - - app.get("/status-page", (_req: ExpressRequest, res: ExpressResponse) => { - res.redirect("/product/status-page"); - }); - - app.get( - "/logs-manageemnt", - (_req: ExpressRequest, res: ExpressResponse) => { - res.redirect("/product/logs-manageemnt"); - }, - ); - - let gitHubContributors: Array = []; - let gitHubBasicInfo: JSONObject | null = null; - let gitHubCommits: string = "-"; - - app.get("/about", async (_req: ExpressRequest, res: ExpressResponse) => { - if (gitHubContributors.length === 0) { - let contributors: Array = []; - - let hasMoreContributors: boolean = true; - - let pageNumber: number = 1; - - while (hasMoreContributors) { - const response: HTTPResponse> | HTTPErrorResponse = - await API.get>( - URL.fromString( - "https://api.github.com/repos/oneuptime/oneuptime/contributors?page=" + - pageNumber, - ), - ); - pageNumber++; - if ((response.data as Array).length < 30) { - hasMoreContributors = false; - } - - contributors = contributors.concat( - response.data as Array, - ); - } - - //cache it. - gitHubContributors = [...contributors]; - } - - const response: HTTPResponse = await API.get( - URL.fromString( - "https://api.github.com/repos/oneuptime/oneuptime/commits?sha=master&per_page=1&page=1", - ), - ); - - if (gitHubCommits === "-") { - // this is of type: '; rel="next", ; rel="last"', - 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(); - - if (!gitHubBasicInfo) { - const basicInfo: HTTPResponse = await API.get( - URL.fromString("https://api.github.com/repos/oneuptime/oneuptime"), - ); - - gitHubBasicInfo = basicInfo.data as JSONObject; - } - - gitHubCommits = commits; - } - - res.render(`${ViewsPath}/about`, { - contributors: gitHubContributors, - basicInfo: gitHubBasicInfo, - commits: gitHubCommits, - }); - }); - - app.get( - "/product/status-page", - (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/status-page`, { - support: false, - footerCards: true, - cta: true, - blackLogo: false, - requestDemoCta: false, - footerCtaText: - "Start with Status Pages, expand into everything else. Sign up today.", - }); - }, - ); - - app.get("/status-page", (_req: ExpressRequest, res: ExpressResponse) => { - res.redirect("/product/status-page"); - }); - - app.get("/workflows", (_req: ExpressRequest, res: ExpressResponse) => { - res.redirect("/product/workflows"); - }); - - app.get("/on-call", (_req: ExpressRequest, res: ExpressResponse) => { - res.redirect("/product/on-call"); - }); - - app.get( - "/product/monitoring", - (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/monitoring`); - }, - ); - - app.get( - "/product/on-call", - (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/on-call`); - }, - ); - - app.get( - "/product/workflows", - (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/workflows`); - }, - ); - - app.get( - "/product/incident-management", - (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/incident-management`); - }, - ); - - app.get( - "/incident-management", - (_req: ExpressRequest, res: ExpressResponse) => { - res.redirect("/product/incident-management"); - }, - ); - - app.get( - "/enterprise/overview", - (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/enterprise-overview.ejs`, { - support: false, - footerCards: true, - cta: true, - blackLogo: false, - requestDemoCta: true, - }); - }, - ); - - app.get("/legal", (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - support: false, - footerCards: true, - cta: true, - blackLogo: false, - section: "terms", - requestDemoCta: false, - }); - }); - - app.get("/legal/terms", (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - support: false, - footerCards: true, - cta: true, - blackLogo: false, - section: "terms", - requestDemoCta: false, - }); - }); - - app.get("/legal/privacy", (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - support: false, - footerCards: true, - cta: true, - blackLogo: false, - section: "privacy", - requestDemoCta: false, - }); - }); - - app.get("/legal/contact", (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - support: false, - footerCards: true, - cta: true, - blackLogo: false, - section: "contact", - requestDemoCta: false, - }); - }); - - app.get( - "/legal/subprocessors", - (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - support: false, - footerCards: true, - cta: true, - blackLogo: false, - section: "subprocessors", - requestDemoCta: false, - }); - }, - ); - - app.get("/legal/ccpa", (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - support: false, - footerCards: true, - cta: true, - blackLogo: false, - section: "ccpa", - requestDemoCta: false, - }); - }); - - app.get("/legal/hipaa", (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - support: false, - footerCards: true, - cta: true, - blackLogo: false, - section: "hipaa", - requestDemoCta: false, - }); - }); - - app.get("/legal/dmca", (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - support: false, - footerCards: true, - cta: true, - blackLogo: false, - section: "dmca", - requestDemoCta: false, - }); - }); - - app.get("/legal/pci", (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - support: false, - footerCards: true, - cta: true, - blackLogo: false, - section: "pci", - requestDemoCta: false, - }); - }); - - app.get( - "/legal/iso-27001", - (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - support: false, - footerCards: true, - cta: true, - blackLogo: false, - section: "iso-27001", - requestDemoCta: false, - }); - }, - ); - - app.get( - "/legal/iso-27017", - (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - footerCards: true, - support: false, - cta: true, - blackLogo: false, - section: "iso-27017", - requestDemoCta: false, - }); - }, - ); - - app.get( - "/legal/iso-27018", - (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - footerCards: true, - support: false, - cta: true, - blackLogo: false, - section: "iso-27018", - requestDemoCta: false, - }); - }, - ); - - app.get( - "/legal/iso-27017", - (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - footerCards: true, - support: false, - cta: true, - blackLogo: false, - section: "iso-27017", - requestDemoCta: false, - }); - }, - ); - - app.get( - "/legal/iso-27018", - (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - footerCards: true, - support: false, - cta: true, - blackLogo: false, - section: "iso-27018", - requestDemoCta: false, - }); - }, - ); - - app.get("/legal/soc-2", (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - footerCards: true, - support: false, - cta: true, - blackLogo: false, - section: "soc-2", - requestDemoCta: false, - }); - }); - - app.get("/legal/soc-3", (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - footerCards: true, - support: false, - cta: true, - blackLogo: false, - section: "soc-3", - requestDemoCta: false, - }); - }); - - app.get( - "/legal/data-residency", - (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - footerCards: true, - support: false, - cta: true, - blackLogo: false, - section: "data-residency", - requestDemoCta: false, - }); - }, - ); - - app.get("/legal/gdpr", (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - footerCards: true, - support: false, - cta: true, - blackLogo: false, - section: "gdpr", - requestDemoCta: false, - }); - }); - - app.get("/legal/sla", (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/legal.ejs`, { - footerCards: true, - support: false, - cta: true, - blackLogo: false, - section: "sla", - requestDemoCta: false, - }); - }); - - app.get( - "/compare/:product", - (req: ExpressRequest, res: ExpressResponse) => { - const productConfig: Product = ProductCompare( - req.params["product"] as string, - ); - - if (!productConfig) { - return NotFoundUtil.renderNotFound(res); - } - res.render(`${ViewsPath}/product-compare.ejs`, { - support: false, - footerCards: true, - cta: true, - blackLogo: false, - requestDemoCta: false, - productConfig, - onlyShowCompareTable: false, - }); - }, - ); - - // Generate sitemap - app.get( - "/sitemap.xml", - async (_req: ExpressRequest, res: ExpressResponse) => { - const siteUrls: Array = [ - URL.fromString("https://oneuptime.com/"), - URL.fromString("https://oneuptime.com/pricing"), - URL.fromString("https://oneuptime.com/support"), - URL.fromString("https://oneuptime.com/about"), - URL.fromString("https://oneuptime.com/product/status-page"), - URL.fromString("https://oneuptime.com/product/incident-management"), - URL.fromString("https://oneuptime.com/product/on-call"), - 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"), - URL.fromString("https://oneuptime.com/compare/status-page.io"), - URL.fromString("https://oneuptime.com/compare/incident.io"), - 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"), - ]; - - // Build xml - const urlsetAttr: Dictionary = { - 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", - }; - - // Get previous day's date/timestamp - const today: Date = OneUptimeDate.getOneDayAgo(); - const timestamp: string = today.toISOString(); - - const urlset: XMLBuilder = builder.create().ele("urlset"); - - // Apply attributes to root element - for (const key in urlsetAttr) { - urlset.att({ key: urlsetAttr[key] }); - } - - //Append urls to root element - siteUrls.forEach((url: URL) => { - const urlElement: XMLBuilder = urlset.ele("url"); - urlElement.ele("loc").txt(url.toString()); - urlElement.ele("lastmod").txt(timestamp); - }); - - // Generate xml file - const xml: string = urlset.end({ prettyPrint: true }); - - res.setHeader("Content-Type", "text/xml"); - res.send(xml); - }, - ); - - /* - * Cache policy for static contents - * Loads up the site faster - */ - app.use( - ExpressStatic(StaticPath, { - setHeaders(res: ExpressResponse) { - res.setHeader("Cache-Control", "public,max-age=31536000,immutable"); - }, - }), - ); - - app.get("/*", (_req: ExpressRequest, res: ExpressResponse) => { - return NotFoundUtil.renderNotFound(res); - }); - }, + // Initialize home routes at the end since it has a catch-all route + await HomeRoutes.init(); + + // Add default routes to the app + await App.addDefaultRoutes(); + } catch (err) { + logger.error("App Init Failed:"); + logger.error(err); + throw err; + } }; -export default HomeFeatureSet; +init().catch((err: Error) => { + logger.error(err); + logger.error("Exiting node process"); + process.exit(1); +}); diff --git a/Home/README.md b/Home/README.md new file mode 100755 index 0000000000..4430be544c --- /dev/null +++ b/Home/README.md @@ -0,0 +1,29 @@ +# README + +This README would normally document whatever steps are necessary to get your application up and running. + +### What is this repository for? + +- Quick summary +- Version +- [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo) + +### How do I get set up? + +- Summary of set up +- Configuration +- Dependencies +- Database configuration +- How to run tests +- Deployment instructions + +### Contribution guidelines + +- Writing tests +- Code review +- Other guidelines + +### Who do I talk to? + +- Repo owner or admin +- Other community or team contact diff --git a/Home/Routes.ts b/Home/Routes.ts new file mode 100755 index 0000000000..58fa00cf78 --- /dev/null +++ b/Home/Routes.ts @@ -0,0 +1,1367 @@ +// improt API +import "./API/BlogAPI"; +import { StaticPath, ViewsPath } from "./Utils/Config"; +import NotFoundUtil from "./Utils/NotFound"; +import ProductCompare, { Product } from "./Utils/ProductCompare"; +import HTTPErrorResponse from "Common/Types/API/HTTPErrorResponse"; +import HTTPResponse from "Common/Types/API/HTTPResponse"; +import URL from "Common/Types/API/URL"; +import OneUptimeDate from "Common/Types/Date"; +import Dictionary from "Common/Types/Dictionary"; +import { JSONObject } from "Common/Types/JSON"; +import API from "Common/Utils/API"; +import FeatureSet from "Common/Server/Types/FeatureSet"; +import Express, { + ExpressApplication, + ExpressRequest, + ExpressResponse, + ExpressStatic, +} from "Common/Server/Utils/Express"; +import "ejs"; +import builder from "xmlbuilder2"; +import { XMLBuilder } from "xmlbuilder2/lib/interfaces"; +import OSSFriends, { OSSFriend } from "./Utils/OSSFriends"; +import Reviews from "./Utils/Reviews"; + +const HomeFeatureSet: FeatureSet = { + init: async (): Promise => { + const app: ExpressApplication = Express.getExpressApp(); + + //Routes + app.get("/", (_req: ExpressRequest, res: ExpressResponse) => { + const { reviewsList1, reviewsList2, reviewsList3 } = Reviews; + + res.render(`${ViewsPath}/index`, { + support: false, + footerCards: true, + cta: true, + blackLogo: false, + requestDemoCta: false, + reviewsList1, + reviewsList2, + reviewsList3, + }); + }); + + app.get( + "/infrastructure-agent/install.sh", + (_req: ExpressRequest, res: ExpressResponse) => { + // fetch the file from https://raw.githubusercontent.com/oneuptime/infrastructure-agent/release/Scripts/Install/Linux.sh and send it as response + res.redirect( + "https://raw.githubusercontent.com/OneUptime/oneuptime/release/InfrastructureAgent/Scripts/Install/Linux.sh", + ); + }, + ); + + app.get("/support", async (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/support`); + }); + + app.get( + "/oss-friends", + async (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/oss-friends`, { + ossFriends: OSSFriends.map((friend: OSSFriend) => { + return { + ...friend, + repositoryUrl: friend.repositoryUrl.toString(), + }; + }), + }); + }, + ); + + app.get("/pricing", (_req: ExpressRequest, res: ExpressResponse) => { + const pricing: Array = [ + { + name: "Status Page", + data: [ + { + name: "Public Status Page", + plans: { + free: "1", + growth: "Unlimited", + scale: "Unlimited", + enterprise: "Unlimited", + }, + }, + { + name: "Subscribers", + plans: { + free: "100", + growth: "Unlimited", + scale: "Unlimited", + enterprise: "Unlimited", + }, + }, + { + name: "Custom Branding", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "SSL Certificate", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Custom Domain", + plans: { + free: true, + 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: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "API Monitoring", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Synthetic Monitoring (with Playwright)", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + + { + name: "IPv4 Monitoring", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + + { + name: "IPv6 Monitoring", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Inbound Webhook / Heartbeat Monitoring", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "VM or Server Monitoring", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Network Monitoring", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Container 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", + }, + }, + ], + }, + { + name: "On-Call and Alerts", + data: [ + { + name: "Phone Alerts", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "SMS Alerts", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Email Alerts", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "On-Call Escalation", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Advanced Workflows", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "On-Call Rotation", + 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", + plans: { + free: "Coming Soon", + growth: "Coming Soon", + scale: "Coming Soon", + enterprise: "Coming Soon", + }, + }, + + { + name: "Vacation and OOO Policy", + plans: { + free: "Coming Soon", + growth: "Coming Soon", + scale: "Coming Soon", + enterprise: "Coming Soon", + }, + }, + + { + name: "On-Call Pay", + plans: { + free: "Coming Soon", + growth: "Coming Soon", + scale: "Coming Soon", + enterprise: "Coming Soon", + }, + }, + + { + name: "Reports", + plans: { + free: "Coming Soon", + growth: "Coming Soon", + scale: "Coming Soon", + enterprise: "Coming Soon", + }, + }, + ], + }, + { + name: "Logs Management", + data: [ + { + name: "Ingest with OpenTelemetry", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Ingest with Fluentd", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Ingest +1000 Sources", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Application Logs", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Container Logs", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Data Rentention", + plans: { + free: "15 days", + growth: "Custom", + scale: "Custom", + enterprise: "Custom", + }, + }, + { + name: "Workflows", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Advanced Team Permissions", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + ], + }, + { + name: "Telemetry / APM", + data: [ + { + name: "Metrics", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Traces", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Error Tracking", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Ingest Pricing", + plans: { + free: "$0.10/GB", + growth: "$0.10/GB", + scale: "$0.10/GB", + enterprise: "$0.10/GB", + }, + }, + { + name: "Data Rentention", + plans: { + free: "15 days", + growth: "Custom", + scale: "Custom", + enterprise: "Custom", + }, + }, + { + name: "Workflows", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Advanced Team Permissions", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + ], + }, + { + name: "Error Tracking", + data: [ + { + name: "Track Errors and Exceptions", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Cross Microservice Issues", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Distributed Tracing", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Stack Traces", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Version Management", + plans: { + free: true, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Data Rentention", + plans: { + free: "15 days", + growth: "Custom", + scale: "Custom", + enterprise: "Custom", + }, + }, + { + name: "Workflows", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Advanced Team Permissions", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + ], + }, + { + name: "Reliability Copilot", + data: [ + { + name: "Scan your Codebase", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Fix Errors Automatically", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Fix Performance Issues", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Fix DB Queries Automatically", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Fix Frontend Issues", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Integrate with GitHub, GitLab", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Integrate with CI/CD", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Integrate with Issue Tracker", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Integrates with Slack / Team", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + { + name: "Advanced Workflows", + plans: { + free: false, + growth: true, + scale: true, + enterprise: true, + }, + }, + ], + }, + { + name: "Support and More", + data: [ + { + name: "Support", + plans: { + free: "Email Support", + growth: "Email Support", + scale: "Email and Chat Support", + enterprise: "Email, Chat, Phone Support", + }, + }, + { + name: "Support SLA", + plans: { + free: "5 business day", + growth: "1 business day", + scale: "6 hours", + enterprise: "1 hour priority", + }, + }, + { + name: "Service SLA", + plans: { + free: "99.00%", + 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, + growth: "500 Runs / month", + scale: "2000 Runs /month", + enterprise: "Unlimited Runs", + }, + }, + { + 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, + }, + }, + ], + }, + ]; + + res.render(`${ViewsPath}/pricing`, { + pricing, + }); + }); + + app.get( + "/enterprise/demo", + (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/demo`, { + support: false, + footerCards: false, + cta: false, + blackLogo: true, + requestDemoCta: false, + }); + }, + ); + + app.get( + "/product/status-page", + (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/status-page`); + }, + ); + + app.get( + "/product/logs-management", + (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/logs-management`); + }, + ); + + app.get("/product/apm", (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/apm`); + }); + + app.get("/status-page", (_req: ExpressRequest, res: ExpressResponse) => { + res.redirect("/product/status-page"); + }); + + app.get( + "/logs-manageemnt", + (_req: ExpressRequest, res: ExpressResponse) => { + res.redirect("/product/logs-manageemnt"); + }, + ); + + let gitHubContributors: Array = []; + let gitHubBasicInfo: JSONObject | null = null; + let gitHubCommits: string = "-"; + + app.get("/about", async (_req: ExpressRequest, res: ExpressResponse) => { + if (gitHubContributors.length === 0) { + let contributors: Array = []; + + let hasMoreContributors: boolean = true; + + let pageNumber: number = 1; + + while (hasMoreContributors) { + const response: HTTPResponse> | HTTPErrorResponse = + await API.get>( + URL.fromString( + "https://api.github.com/repos/oneuptime/oneuptime/contributors?page=" + + pageNumber, + ), + ); + pageNumber++; + if ((response.data as Array).length < 30) { + hasMoreContributors = false; + } + + contributors = contributors.concat( + response.data as Array, + ); + } + + //cache it. + gitHubContributors = [...contributors]; + } + + const response: HTTPResponse = await API.get( + URL.fromString( + "https://api.github.com/repos/oneuptime/oneuptime/commits?sha=master&per_page=1&page=1", + ), + ); + + if (gitHubCommits === "-") { + // this is of type: '; rel="next", ; rel="last"', + 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(); + + if (!gitHubBasicInfo) { + const basicInfo: HTTPResponse = await API.get( + URL.fromString("https://api.github.com/repos/oneuptime/oneuptime"), + ); + + gitHubBasicInfo = basicInfo.data as JSONObject; + } + + gitHubCommits = commits; + } + + res.render(`${ViewsPath}/about`, { + contributors: gitHubContributors, + basicInfo: gitHubBasicInfo, + commits: gitHubCommits, + }); + }); + + app.get( + "/product/status-page", + (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/status-page`, { + support: false, + footerCards: true, + cta: true, + blackLogo: false, + requestDemoCta: false, + footerCtaText: + "Start with Status Pages, expand into everything else. Sign up today.", + }); + }, + ); + + app.get("/status-page", (_req: ExpressRequest, res: ExpressResponse) => { + res.redirect("/product/status-page"); + }); + + app.get("/workflows", (_req: ExpressRequest, res: ExpressResponse) => { + res.redirect("/product/workflows"); + }); + + app.get("/on-call", (_req: ExpressRequest, res: ExpressResponse) => { + res.redirect("/product/on-call"); + }); + + app.get( + "/product/monitoring", + (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/monitoring`); + }, + ); + + app.get( + "/product/on-call", + (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/on-call`); + }, + ); + + app.get( + "/product/workflows", + (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/workflows`); + }, + ); + + app.get( + "/product/incident-management", + (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/incident-management`); + }, + ); + + app.get( + "/incident-management", + (_req: ExpressRequest, res: ExpressResponse) => { + res.redirect("/product/incident-management"); + }, + ); + + app.get( + "/enterprise/overview", + (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/enterprise-overview.ejs`, { + support: false, + footerCards: true, + cta: true, + blackLogo: false, + requestDemoCta: true, + }); + }, + ); + + app.get("/legal", (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + support: false, + footerCards: true, + cta: true, + blackLogo: false, + section: "terms", + requestDemoCta: false, + }); + }); + + app.get("/legal/terms", (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + support: false, + footerCards: true, + cta: true, + blackLogo: false, + section: "terms", + requestDemoCta: false, + }); + }); + + app.get("/legal/privacy", (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + support: false, + footerCards: true, + cta: true, + blackLogo: false, + section: "privacy", + requestDemoCta: false, + }); + }); + + app.get("/legal/contact", (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + support: false, + footerCards: true, + cta: true, + blackLogo: false, + section: "contact", + requestDemoCta: false, + }); + }); + + app.get( + "/legal/subprocessors", + (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + support: false, + footerCards: true, + cta: true, + blackLogo: false, + section: "subprocessors", + requestDemoCta: false, + }); + }, + ); + + app.get("/legal/ccpa", (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + support: false, + footerCards: true, + cta: true, + blackLogo: false, + section: "ccpa", + requestDemoCta: false, + }); + }); + + app.get("/legal/hipaa", (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + support: false, + footerCards: true, + cta: true, + blackLogo: false, + section: "hipaa", + requestDemoCta: false, + }); + }); + + app.get("/legal/dmca", (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + support: false, + footerCards: true, + cta: true, + blackLogo: false, + section: "dmca", + requestDemoCta: false, + }); + }); + + app.get("/legal/pci", (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + support: false, + footerCards: true, + cta: true, + blackLogo: false, + section: "pci", + requestDemoCta: false, + }); + }); + + app.get( + "/legal/iso-27001", + (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + support: false, + footerCards: true, + cta: true, + blackLogo: false, + section: "iso-27001", + requestDemoCta: false, + }); + }, + ); + + app.get( + "/legal/iso-27017", + (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + footerCards: true, + support: false, + cta: true, + blackLogo: false, + section: "iso-27017", + requestDemoCta: false, + }); + }, + ); + + app.get( + "/legal/iso-27018", + (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + footerCards: true, + support: false, + cta: true, + blackLogo: false, + section: "iso-27018", + requestDemoCta: false, + }); + }, + ); + + app.get( + "/legal/iso-27017", + (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + footerCards: true, + support: false, + cta: true, + blackLogo: false, + section: "iso-27017", + requestDemoCta: false, + }); + }, + ); + + app.get( + "/legal/iso-27018", + (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + footerCards: true, + support: false, + cta: true, + blackLogo: false, + section: "iso-27018", + requestDemoCta: false, + }); + }, + ); + + app.get("/legal/soc-2", (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + footerCards: true, + support: false, + cta: true, + blackLogo: false, + section: "soc-2", + requestDemoCta: false, + }); + }); + + app.get("/legal/soc-3", (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + footerCards: true, + support: false, + cta: true, + blackLogo: false, + section: "soc-3", + requestDemoCta: false, + }); + }); + + app.get( + "/legal/data-residency", + (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + footerCards: true, + support: false, + cta: true, + blackLogo: false, + section: "data-residency", + requestDemoCta: false, + }); + }, + ); + + app.get("/legal/gdpr", (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + footerCards: true, + support: false, + cta: true, + blackLogo: false, + section: "gdpr", + requestDemoCta: false, + }); + }); + + app.get("/legal/sla", (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/legal.ejs`, { + footerCards: true, + support: false, + cta: true, + blackLogo: false, + section: "sla", + requestDemoCta: false, + }); + }); + + app.get( + "/compare/:product", + (req: ExpressRequest, res: ExpressResponse) => { + const productConfig: Product = ProductCompare( + req.params["product"] as string, + ); + + if (!productConfig) { + return NotFoundUtil.renderNotFound(res); + } + res.render(`${ViewsPath}/product-compare.ejs`, { + support: false, + footerCards: true, + cta: true, + blackLogo: false, + requestDemoCta: false, + productConfig, + onlyShowCompareTable: false, + }); + }, + ); + + // Generate sitemap + app.get( + "/sitemap.xml", + async (_req: ExpressRequest, res: ExpressResponse) => { + const siteUrls: Array = [ + URL.fromString("https://oneuptime.com/"), + URL.fromString("https://oneuptime.com/pricing"), + URL.fromString("https://oneuptime.com/support"), + URL.fromString("https://oneuptime.com/about"), + URL.fromString("https://oneuptime.com/product/status-page"), + URL.fromString("https://oneuptime.com/product/incident-management"), + URL.fromString("https://oneuptime.com/product/on-call"), + 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"), + URL.fromString("https://oneuptime.com/compare/status-page.io"), + URL.fromString("https://oneuptime.com/compare/incident.io"), + 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"), + ]; + + // Build xml + const urlsetAttr: Dictionary = { + 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", + }; + + // Get previous day's date/timestamp + const today: Date = OneUptimeDate.getOneDayAgo(); + const timestamp: string = today.toISOString(); + + const urlset: XMLBuilder = builder.create().ele("urlset"); + + // Apply attributes to root element + for (const key in urlsetAttr) { + urlset.att({ key: urlsetAttr[key] }); + } + + //Append urls to root element + siteUrls.forEach((url: URL) => { + const urlElement: XMLBuilder = urlset.ele("url"); + urlElement.ele("loc").txt(url.toString()); + urlElement.ele("lastmod").txt(timestamp); + }); + + // Generate xml file + const xml: string = urlset.end({ prettyPrint: true }); + + res.setHeader("Content-Type", "text/xml"); + res.send(xml); + }, + ); + + /* + * Cache policy for static contents + * Loads up the site faster + */ + app.use( + ExpressStatic(StaticPath, { + setHeaders(res: ExpressResponse) { + res.setHeader("Cache-Control", "public,max-age=31536000,immutable"); + }, + }), + ); + + app.get("/*", (_req: ExpressRequest, res: ExpressResponse) => { + return NotFoundUtil.renderNotFound(res); + }); + }, +}; + +export default HomeFeatureSet; diff --git a/Home/nodemon.json b/Home/nodemon.json new file mode 100644 index 0000000000..d077702261 --- /dev/null +++ b/Home/nodemon.json @@ -0,0 +1,8 @@ +{ + "watch": ["./","../Common/Server", "../Common/Types", "../Common/Utils", "../Common/Models"], + "ext": "ts,json,tsx,env,js,jsx,hbs", + "ignore": [ + "greenlock.d/*" + ], + "exec": "node --inspect=0.0.0.0:9229 --require ts-node/register Index.ts" +} \ No newline at end of file diff --git a/Home/package.json b/Home/package.json index c0be5db442..cc2f03896e 100644 --- a/Home/package.json +++ b/Home/package.json @@ -1,5 +1,5 @@ { - "name": "@oneuptime/app", + "name": "@oneuptime/home", "version": "1.0.0", "description": "", "main": "index.js", diff --git a/Home/tsconfig.json b/Home/tsconfig.json new file mode 100644 index 0000000000..547cf100a3 --- /dev/null +++ b/Home/tsconfig.json @@ -0,0 +1,112 @@ +{ + "ts-node": { + // these options are overrides used only by ts-node + // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable + "compilerOptions": { + "module": "commonjs", + "resolveJsonModule": true, + } + }, + "compilerOptions": { + /* Visit https://aka.ms/tsconfig.json to read more about this file */ + + /* Projects */ + // "incremental": true, /* Enable incremental compilation */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2017" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + "jsx": "react" /* Specify what JSX code is generated. */, + "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ + // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + + /* Modules */ + // "module": "es2022" /* Specify what module code is generated. */, + // "rootDir": "./", /* Specify the root folder within your source files. */ + "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + "typeRoots": [ + "./node_modules/@types" + ], /* Specify multiple folders that act like `./node_modules/@types`. */ + "types": ["node", "jest"], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "resolveJsonModule": true, /* Enable importing .json files */ + // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ + "outDir": "./build/dist", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */, + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, + + /* Type Checking */ + "strict": true /* Enable all strict type-checking options. */, + "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ + "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ + "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ + "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ + "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ + "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ + "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ + "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true, /* Skip type checking all .d.ts files. */ + "resolveJsonModule": true + } +}