OneUptime Copilot: Improve Comments on /App/Index.ts

This commit is contained in:
simlarsen
2024-06-23 19:43:27 +01:00
parent a906713f6e
commit a25e2ddcc2

View File

@@ -1,27 +1,28 @@
import APIReferenceRoutes from "./FeatureSet/ApiReference/Index";
import BaseAPIRoutes from "./FeatureSet/BaseAPI/Index";
import DocsRoutes from "./FeatureSet/Docs/Index";
import HomeRoutes from "./FeatureSet/Home/Index";
import APIReferenceRoutes from ./FeatureSet/ApiReference/Index;
import BaseAPIRoutes from ./FeatureSet/BaseAPI/Index;
import DocsRoutes from ./FeatureSet/Docs/Index;
import HomeRoutes from ./FeatureSet/Home/Index;
// import FeatureSets.
import IdentityRoutes from "./FeatureSet/Identity/Index";
import NotificationRoutes from "./FeatureSet/Notification/Index";
import Workers from "./FeatureSet/Workers/Index";
import Workflow from "./FeatureSet/Workflow/Index";
import { PromiseVoidFunction } from "Common/Types/FunctionTypes";
import { ClickhouseAppInstance } from "CommonServer/Infrastructure/ClickhouseDatabase";
import { PostgresAppInstance } from "CommonServer/Infrastructure/PostgresDatabase";
import Redis from "CommonServer/Infrastructure/Redis";
import InfrastructureStatus from "CommonServer/Infrastructure/Status";
import logger from "CommonServer/Utils/Logger";
import Realtime from "CommonServer/Utils/Realtime";
import App from "CommonServer/Utils/StartServer";
import "CommonServer/Utils/Telemetry";
import "ejs";
import IdentityRoutes from ./FeatureSet/Identity/Index;
import NotificationRoutes from ./FeatureSet/Notification/Index;
import Workers from ./FeatureSet/Workers/Index;
import Workflow from ./FeatureSet/Workflow/Index;
import { PromiseVoidFunction } from Common/Types/FunctionTypes;
import { ClickhouseAppInstance } from CommonServer/Infrastructure/ClickhouseDatabase;
import { PostgresAppInstance } from CommonServer/Infrastructure/PostgresDatabase;
import Redis from CommonServer/Infrastructure/Redis;
import InfrastructureStatus from CommonServer/Infrastructure/Status;
import logger from CommonServer/Utils/Logger;
import Realtime from CommonServer/Utils/Realtime;
import App from CommonServer/Utils/StartServer;
import CommonServer/Utils/Telemetry;
import ejs;
process.env["SERVICE_NAME"] = "app";
process.env[SERVICE_NAME] = app;
const init: PromiseVoidFunction = async (): Promise<void> => {
try {
// Check the status of the infrastructure
const statusCheck: PromiseVoidFunction = async (): Promise<void> => {
return await InfrastructureStatus.checkStatus({
checkClickhouseStatus: true,
@@ -30,30 +31,30 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
});
};
// init the app
// Initialize the app
await App.init({
appName: process.env["SERVICE_NAME"] || "app",
appName: process.env[SERVICE_NAME] || app,
statusOptions: {
liveCheck: statusCheck,
readyCheck: statusCheck,
},
});
// connect to the database.
// Connect to the databases
await PostgresAppInstance.connect(
PostgresAppInstance.getDatasourceOptions(),
);
// connect redis
await Redis.connect();
await ClickhouseAppInstance.connect(
ClickhouseAppInstance.getDatasourceOptions(),
);
// Connect to Redis
await Redis.connect();
// Initialize Realtime
await Realtime.init();
// init featuresets
// Initialize feature sets
await IdentityRoutes.init();
await NotificationRoutes.init();
await DocsRoutes.init();
@@ -62,13 +63,14 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
await Workers.init();
await Workflow.init();
// home should be in the end because it has the catch all route.
// Initialize home routes (last as it has the catch all route)
await HomeRoutes.init();
// add default routes
// Add default routes
await App.addDefaultRoutes();
} catch (err) {
logger.error("App Init Failed:");
// Log error and exit the node process
logger.error(App Init Failed:);
logger.error(err);
throw err;
}
@@ -76,6 +78,7 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
init().catch((err: Error) => {
logger.error(err);
logger.error("Exiting node process");
logger.error(Exiting node process);
process.exit(1);
});