diff --git a/App/FeatureSet/ApiReference/Index.ts b/App/FeatureSet/ApiReference/Index.ts index 6da16b133d..e8b13b8b61 100755 --- a/App/FeatureSet/ApiReference/Index.ts +++ b/App/FeatureSet/ApiReference/Index.ts @@ -16,65 +16,74 @@ import StatusServiceHandler from './Service/Status'; import DataTypeServiceHandler from './Service/DataType'; import Dictionary from 'Common/Types/Dictionary'; import { StaticPath } from './Utils/Config'; +import FeatureSet from 'CommonServer/Types/FeatureSet'; -const init: VoidFunction = () => { - const ResourceDictionary: Dictionary = - ResourceUtil.getResourceDictionaryByPath(); +const APIReferenceFeatureSet: FeatureSet = { + init: async (): Promise => { + const ResourceDictionary: Dictionary = + ResourceUtil.getResourceDictionaryByPath(); - const app: ExpressApplication = Express.getExpressApp(); + const app: ExpressApplication = Express.getExpressApp(); - app.use('/reference', ExpressStatic(StaticPath, { maxAge: 2592000 })); + app.use('/reference', ExpressStatic(StaticPath, { maxAge: 2592000 })); - // Index page - app.get(['/reference'], (_req: ExpressRequest, res: ExpressResponse) => { - return res.redirect('/reference/introduction'); - }); + // Index page + app.get( + ['/reference'], + (_req: ExpressRequest, res: ExpressResponse) => { + return res.redirect('/reference/introduction'); + } + ); - app.get( - ['/reference/page-not-found'], - (req: ExpressRequest, res: ExpressResponse) => { - return PageNotFoundServiceHandler.executeResponse(req, res); - } - ); - - // All Pages - app.get( - ['/reference/:page'], - (req: ExpressRequest, res: ExpressResponse) => { - const page: string | undefined = req.params['page']; - - if (!page) { + app.get( + ['/reference/page-not-found'], + (req: ExpressRequest, res: ExpressResponse) => { return PageNotFoundServiceHandler.executeResponse(req, res); } + ); - const currentResource: ModelDocumentation | undefined = - ResourceDictionary[page]; + // All Pages + app.get( + ['/reference/:page'], + (req: ExpressRequest, res: ExpressResponse) => { + const page: string | undefined = req.params['page']; - if (req.params['page'] === 'permissions') { - return PermissionServiceHandler.executeResponse(req, res); - } else if (req.params['page'] === 'authentication') { - return AuthenticationServiceHandler.executeResponse(req, res); - } else if (req.params['page'] === 'pagination') { - return PaginationServiceHandler.executeResponse(req, res); - } else if (req.params['page'] === 'errors') { - return ErrorServiceHandler.executeResponse(req, res); - } else if (req.params['page'] === 'introduction') { - return IntroductionServiceHandler.executeResponse(req, res); - } else if (req.params['page'] === 'status') { - return StatusServiceHandler.executeResponse(req, res); - } else if (req.params['page'] === 'data-types') { - return DataTypeServiceHandler.executeResponse(req, res); - } else if (currentResource) { - return ModelServiceHandler.executeResponse(req, res); + if (!page) { + return PageNotFoundServiceHandler.executeResponse(req, res); + } + + const currentResource: ModelDocumentation | undefined = + ResourceDictionary[page]; + + if (req.params['page'] === 'permissions') { + return PermissionServiceHandler.executeResponse(req, res); + } else if (req.params['page'] === 'authentication') { + return AuthenticationServiceHandler.executeResponse( + req, + res + ); + } else if (req.params['page'] === 'pagination') { + return PaginationServiceHandler.executeResponse(req, res); + } else if (req.params['page'] === 'errors') { + return ErrorServiceHandler.executeResponse(req, res); + } else if (req.params['page'] === 'introduction') { + return IntroductionServiceHandler.executeResponse(req, res); + } else if (req.params['page'] === 'status') { + return StatusServiceHandler.executeResponse(req, res); + } else if (req.params['page'] === 'data-types') { + return DataTypeServiceHandler.executeResponse(req, res); + } else if (currentResource) { + return ModelServiceHandler.executeResponse(req, res); + } + // page not found + return PageNotFoundServiceHandler.executeResponse(req, res); } - // page not found - return PageNotFoundServiceHandler.executeResponse(req, res); - } - ); + ); - app.get('/reference/*', (req: ExpressRequest, res: ExpressResponse) => { - return PageNotFoundServiceHandler.executeResponse(req, res); - }); + app.get('/reference/*', (req: ExpressRequest, res: ExpressResponse) => { + return PageNotFoundServiceHandler.executeResponse(req, res); + }); + }, }; -export default { init }; +export default APIReferenceFeatureSet; diff --git a/App/FeatureSet/BaseAPI/Index.ts b/App/FeatureSet/BaseAPI/Index.ts index 5f0f05fdc5..eabac55f4c 100644 --- a/App/FeatureSet/BaseAPI/Index.ts +++ b/App/FeatureSet/BaseAPI/Index.ts @@ -447,789 +447,819 @@ import ProjectCallSMSConfig from 'Model/Models/ProjectCallSMSConfig'; import ProjectCallSMSConfigService, { Service as ProjectCallSMSConfigServiceType, } from 'CommonServer/Services/ProjectCallSMSConfigService'; - -const init: VoidFunction = () => { - const app: ExpressApplication = Express.getExpressApp(); - - const APP_NAME: string = 'api'; - - //attach api's - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI(User, UserService).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAnalyticsAPI(Log, LogService).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAnalyticsAPI< - MonitorMetricsByMinute, - MonitorMetricsByMinuteServiceType - >(MonitorMetricsByMinute, MonitorMetricsByMinuteService).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAnalyticsAPI( - Span, - SpanService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - TelemetryUsageBilling, - TelemetryUsageBillingService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - ShortLink, - ShortLinkService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - StatusPageHistoryChartBarColorRule, - StatusPageHistoryChartBarColorRuleServiceType - >( - StatusPageHistoryChartBarColorRule, - StatusPageHistoryChartBarColorRuleService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - MonitorProbe, - MonitorProbeService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - StatusPageAnnouncement, - StatusPageAnnouncementService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI(Team, TeamService).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - MonitorGroupOwnerUser, - MonitorGroupOwnerUserService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - OnCallDutyPolicySchedule, - OnCallDutyPolicyScheduleServiceType - >(OnCallDutyPolicySchedule, OnCallDutyPolicyScheduleService).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - OnCallDutyPolicyScheduleLayer, - OnCallDutyPolicyScheduleLayerServiceType - >( - OnCallDutyPolicyScheduleLayer, - OnCallDutyPolicyScheduleLayerService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - OnCallDutyPolicyScheduleLayerUser, - OnCallDutyPolicyScheduleLayerUserServiceType - >( - OnCallDutyPolicyScheduleLayerUser, - OnCallDutyPolicyScheduleLayerUserService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - MonitorGroupOwnerTeam, - MonitorGroupOwnerTeamService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - ProjectCallSMSConfig, - ProjectCallSMSConfigService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - MonitorGroupResource, - MonitorGroupResourceService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - TeamMember, - TeamMemberService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - TeamPermission, - TeamPermissionService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - MonitorStatus, - MonitorStatusService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - IncidentState, - IncidentStateService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - ScheduledMaintenanceState, - ScheduledMaintenanceStateServiceType - >( - ScheduledMaintenanceState, - ScheduledMaintenanceStateService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - StatusPageResource, - StatusPageResourceService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - Workflow, - WorkflowService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - TelemetryService, - TelemetryServiceService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - WorkflowVariable, - WorkflowVariableService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - WorkflowLog, - WorkflowLogService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - Domain, - DomainService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - StatusPageGroup, - StatusPageGroupService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - StatusPageDomain, - StatusPageDomainService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - IncidentStateTimeline, - IncidentStateTimelineService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - ScheduledMaintenanceStateTimeline, - ScheduledMaintenanceStateTimelineServiceType - >( - ScheduledMaintenanceStateTimeline, - ScheduledMaintenanceStateTimelineService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - StatusPagePrivateUser, - StatusPagePrivateUserService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - Incident, - IncidentService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - ScheduledMaintenance, - ScheduledMaintenanceService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - ApiKey, - ApiKeyService - ).getRouter() - ); - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - ApiKeyPermission, - ApiKeyPermissionService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - StatusPageHeaderLink, - StatusPageHeaderLinkService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - UserNotificationRule, - UserNotificationRuleService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - StatusPageFooterLink, - StatusPageFooterLinkService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - ApiKey, - ApiKeyService - ).getRouter() - ); - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - ApiKeyPermission, - ApiKeyPermissionService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - IncidentSeverity, - IncidentSeverityService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - IncidentOwnerUser, - IncidentOwnerUserService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - IncidentOwnerTeam, - IncidentOwnerTeamService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - IncidentTemplate, - IncidentTemplateService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - IncidentNoteTemplate, - IncidentNoteTemplateService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - ScheduledMaintenanceNoteTemplate, - ScheduledMaintenanceNoteTemplateServiceType - >( - ScheduledMaintenanceNoteTemplate, - ScheduledMaintenanceNoteTemplateService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - IncidentTemplateOwnerTeam, - IncidentTemplateOwnerTeamServiceType - >( - IncidentTemplateOwnerTeam, - IncidentTemplateOwnerTeamService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - IncidentTemplateOwnerUser, - IncidentTemplateOwnerUserServiceType - >( - IncidentTemplateOwnerUser, - IncidentTemplateOwnerUserService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - MonitorOwnerUser, - MonitorOwnerUserService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - MonitorOwnerTeam, - MonitorOwnerTeamService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - ScheduledMaintenanceOwnerUser, - ScheduledMaintenanceOwnerUserServiceType - >( - ScheduledMaintenanceOwnerUser, - ScheduledMaintenanceOwnerUserService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - ScheduledMaintenanceOwnerTeam, - ScheduledMaintenanceOwnerTeamServiceType - >( - ScheduledMaintenanceOwnerTeam, - ScheduledMaintenanceOwnerTeamService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - StatusPageOwnerUser, - StatusPageOwnerUserService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - StatusPageOwnerTeam, - StatusPageOwnerTeamService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI(Label, LabelService).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - EmailVerificationToken, - EmailVerificationTokenService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - UserOnCallLog, - UserOnCallLogService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - UserNotificationSetting, - UserNotificationSettingServiceType - >(UserNotificationSetting, UserNotificationSettingService).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - OnCallDutyPolicyCustomField, - OnCallDutyPolicyCustomFieldServiceType - >( - OnCallDutyPolicyCustomField, - OnCallDutyPolicyCustomFieldService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - ProjectSmtpConfig, - ProjectSmtpConfigService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - Monitor, - MonitorService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - SmsLog, - SmsLogService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - EmailLog, - EmailLogService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - Reseller, - ResellerService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - CallLog, - CallLogService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - StatusPageSSO, - StatusPageSSOService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - MonitorTimelineStatus, - MonitorTimelineStatusService - ).getRouter() - ); - - app.use(`/${APP_NAME.toLocaleLowerCase()}`, new ShortLinkAPI().getRouter()); - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new StatusPageAPI().getRouter() - ); - app.use(`/${APP_NAME.toLocaleLowerCase()}`, new FileAPI().getRouter()); - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new MonitorGroupAPI().getRouter() - ); - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new ProjectSsoAPI().getRouter() - ); - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new ResellerPlanAPI().getRouter() - ); - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new GlobalConfigAPI().getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new UserNotificationLogTimelineAPI().getRouter() - ); - app.use(`/${APP_NAME.toLocaleLowerCase()}`, new UserCallAPI().getRouter()); - app.use(`/${APP_NAME.toLocaleLowerCase()}`, new UserEmailAPI().getRouter()); - app.use(`/${APP_NAME.toLocaleLowerCase()}`, new UserSMSAPI().getRouter()); - app.use(`/${APP_NAME.toLocaleLowerCase()}`, new Ingestor().getRouter()); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new StatusPageSubscriberAPI().getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BillingPaymentMethodAPI().getRouter() - ); - - app.use(`/${APP_NAME.toLocaleLowerCase()}`, new ProjectAPI().getRouter()); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BillingInvoiceAPI().getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - ScheduledMaintenancePublicNote, - ScheduledMaintenancePublicNoteServiceType - >( - ScheduledMaintenancePublicNote, - ScheduledMaintenancePublicNoteService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - ScheduledMaintenanceInternalNote, - ScheduledMaintenanceInternalNoteServiceType - >( - ScheduledMaintenanceInternalNote, - ScheduledMaintenanceInternalNoteService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - IncidentPublicNote, - IncidentPublicNoteService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - IncidentInternalNote, - IncidentInternalNoteService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - OnCallDutyPolicy, - OnCallDutyPolicyService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - ScheduledMaintenanceCustomField, - ScheduledMaintenanceCustomFieldServiceType - >( - ScheduledMaintenanceCustomField, - ScheduledMaintenanceCustomFieldService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - OnCallDutyPolicyEscalationRuleUser, - OnCallDutyPolicyEscalationRuleUserServiceType - >( - OnCallDutyPolicyEscalationRuleUser, - OnCallDutyPolicyEscalationRuleUserService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - OnCallDutyPolicyEscalationRuleTeam, - OnCallDutyPolicyEscalationRuleTeamServiceType - >( - OnCallDutyPolicyEscalationRuleTeam, - OnCallDutyPolicyEscalationRuleTeamService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - OnCallDutyPolicyEscalationRuleSchedule, - OnCallDutyPolicyEscalationRuleScheduleServiceType - >( - OnCallDutyPolicyEscalationRuleSchedule, - OnCallDutyPolicyEscalationRuleScheduleService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - OnCallDutyPolicyExecutionLog, - OnCallDutyPolicyExecutionLogServiceType - >( - OnCallDutyPolicyExecutionLog, - OnCallDutyPolicyExecutionLogService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - PromoCode, - PromoCodeService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - OnCallDutyPolicyExecutionLogTimeline, - OnCallDutyPolicyExecutionLogTimelineServiceType - >( - OnCallDutyPolicyExecutionLogTimeline, - OnCallDutyPolicyExecutionLogTimelineService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - IncidentCustomField, - IncidentCustomFieldService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI< - OnCallDutyPolicyEscalationRule, - OnCallDutyPolicyEscalationRuleServiceType - >( - OnCallDutyPolicyEscalationRule, - OnCallDutyPolicyEscalationRuleService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - MonitorCustomField, - MonitorCustomFieldService - ).getRouter() - ); - - app.use( - `/${APP_NAME.toLocaleLowerCase()}`, - new BaseAPI( - StatusPageCustomField, - StatusPageCustomFieldService - ).getRouter() - ); - - app.use(`/${APP_NAME.toLocaleLowerCase()}`, NotificationAPI); +import FeatureSet from 'CommonServer/Types/FeatureSet'; + +const BaseAPIFeatureSet: FeatureSet = { + init: async (): Promise => { + const app: ExpressApplication = Express.getExpressApp(); + + const APP_NAME: string = 'api'; + + //attach api's + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI(User, UserService).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAnalyticsAPI( + Log, + LogService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAnalyticsAPI< + MonitorMetricsByMinute, + MonitorMetricsByMinuteServiceType + >(MonitorMetricsByMinute, MonitorMetricsByMinuteService).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAnalyticsAPI( + Span, + SpanService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + TelemetryUsageBilling, + TelemetryUsageBillingServiceType + >(TelemetryUsageBilling, TelemetryUsageBillingService).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + ShortLink, + ShortLinkService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + StatusPageHistoryChartBarColorRule, + StatusPageHistoryChartBarColorRuleServiceType + >( + StatusPageHistoryChartBarColorRule, + StatusPageHistoryChartBarColorRuleService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + MonitorProbe, + MonitorProbeService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + StatusPageAnnouncement, + StatusPageAnnouncementServiceType + >(StatusPageAnnouncement, StatusPageAnnouncementService).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI(Team, TeamService).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + MonitorGroupOwnerUser, + MonitorGroupOwnerUserServiceType + >(MonitorGroupOwnerUser, MonitorGroupOwnerUserService).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + OnCallDutyPolicySchedule, + OnCallDutyPolicyScheduleServiceType + >( + OnCallDutyPolicySchedule, + OnCallDutyPolicyScheduleService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + OnCallDutyPolicyScheduleLayer, + OnCallDutyPolicyScheduleLayerServiceType + >( + OnCallDutyPolicyScheduleLayer, + OnCallDutyPolicyScheduleLayerService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + OnCallDutyPolicyScheduleLayerUser, + OnCallDutyPolicyScheduleLayerUserServiceType + >( + OnCallDutyPolicyScheduleLayerUser, + OnCallDutyPolicyScheduleLayerUserService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + MonitorGroupOwnerTeam, + MonitorGroupOwnerTeamServiceType + >(MonitorGroupOwnerTeam, MonitorGroupOwnerTeamService).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + ProjectCallSMSConfig, + ProjectCallSMSConfigService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + MonitorGroupResource, + MonitorGroupResourceService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + TeamMember, + TeamMemberService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + TeamPermission, + TeamPermissionService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + MonitorStatus, + MonitorStatusService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + IncidentState, + IncidentStateService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + ScheduledMaintenanceState, + ScheduledMaintenanceStateServiceType + >( + ScheduledMaintenanceState, + ScheduledMaintenanceStateService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + StatusPageResource, + StatusPageResourceService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + Workflow, + WorkflowService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + TelemetryService, + TelemetryServiceService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + WorkflowVariable, + WorkflowVariableService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + WorkflowLog, + WorkflowLogService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + Domain, + DomainService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + StatusPageGroup, + StatusPageGroupService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + StatusPageDomain, + StatusPageDomainService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + IncidentStateTimeline, + IncidentStateTimelineServiceType + >(IncidentStateTimeline, IncidentStateTimelineService).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + ScheduledMaintenanceStateTimeline, + ScheduledMaintenanceStateTimelineServiceType + >( + ScheduledMaintenanceStateTimeline, + ScheduledMaintenanceStateTimelineService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + StatusPagePrivateUser, + StatusPagePrivateUserServiceType + >(StatusPagePrivateUser, StatusPagePrivateUserService).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + Incident, + IncidentService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + ScheduledMaintenance, + ScheduledMaintenanceService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + ApiKey, + ApiKeyService + ).getRouter() + ); + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + ApiKeyPermission, + ApiKeyPermissionService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + StatusPageHeaderLink, + StatusPageHeaderLinkService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + UserNotificationRule, + UserNotificationRuleService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + StatusPageFooterLink, + StatusPageFooterLinkService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + ApiKey, + ApiKeyService + ).getRouter() + ); + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + ApiKeyPermission, + ApiKeyPermissionService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + IncidentSeverity, + IncidentSeverityService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + IncidentOwnerUser, + IncidentOwnerUserService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + IncidentOwnerTeam, + IncidentOwnerTeamService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + IncidentTemplate, + IncidentTemplateService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + IncidentNoteTemplate, + IncidentNoteTemplateService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + ScheduledMaintenanceNoteTemplate, + ScheduledMaintenanceNoteTemplateServiceType + >( + ScheduledMaintenanceNoteTemplate, + ScheduledMaintenanceNoteTemplateService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + IncidentTemplateOwnerTeam, + IncidentTemplateOwnerTeamServiceType + >( + IncidentTemplateOwnerTeam, + IncidentTemplateOwnerTeamService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + IncidentTemplateOwnerUser, + IncidentTemplateOwnerUserServiceType + >( + IncidentTemplateOwnerUser, + IncidentTemplateOwnerUserService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + MonitorOwnerUser, + MonitorOwnerUserService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + MonitorOwnerTeam, + MonitorOwnerTeamService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + ScheduledMaintenanceOwnerUser, + ScheduledMaintenanceOwnerUserServiceType + >( + ScheduledMaintenanceOwnerUser, + ScheduledMaintenanceOwnerUserService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + ScheduledMaintenanceOwnerTeam, + ScheduledMaintenanceOwnerTeamServiceType + >( + ScheduledMaintenanceOwnerTeam, + ScheduledMaintenanceOwnerTeamService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + StatusPageOwnerUser, + StatusPageOwnerUserService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + StatusPageOwnerTeam, + StatusPageOwnerTeamService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + Label, + LabelService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + EmailVerificationToken, + EmailVerificationTokenServiceType + >(EmailVerificationToken, EmailVerificationTokenService).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + UserOnCallLog, + UserOnCallLogService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + UserNotificationSetting, + UserNotificationSettingServiceType + >( + UserNotificationSetting, + UserNotificationSettingService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + OnCallDutyPolicyCustomField, + OnCallDutyPolicyCustomFieldServiceType + >( + OnCallDutyPolicyCustomField, + OnCallDutyPolicyCustomFieldService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + ProjectSmtpConfig, + ProjectSmtpConfigService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + Monitor, + MonitorService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + SmsLog, + SmsLogService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + EmailLog, + EmailLogService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + Reseller, + ResellerService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + CallLog, + CallLogService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + StatusPageSSO, + StatusPageSSOService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + MonitorTimelineStatus, + MonitorTimelineStatusServiceType + >(MonitorTimelineStatus, MonitorTimelineStatusService).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new ShortLinkAPI().getRouter() + ); + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new StatusPageAPI().getRouter() + ); + app.use(`/${APP_NAME.toLocaleLowerCase()}`, new FileAPI().getRouter()); + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new MonitorGroupAPI().getRouter() + ); + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new ProjectSsoAPI().getRouter() + ); + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new ResellerPlanAPI().getRouter() + ); + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new GlobalConfigAPI().getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new UserNotificationLogTimelineAPI().getRouter() + ); + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new UserCallAPI().getRouter() + ); + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new UserEmailAPI().getRouter() + ); + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new UserSMSAPI().getRouter() + ); + app.use(`/${APP_NAME.toLocaleLowerCase()}`, new Ingestor().getRouter()); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new StatusPageSubscriberAPI().getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BillingPaymentMethodAPI().getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new ProjectAPI().getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BillingInvoiceAPI().getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + ScheduledMaintenancePublicNote, + ScheduledMaintenancePublicNoteServiceType + >( + ScheduledMaintenancePublicNote, + ScheduledMaintenancePublicNoteService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + ScheduledMaintenanceInternalNote, + ScheduledMaintenanceInternalNoteServiceType + >( + ScheduledMaintenanceInternalNote, + ScheduledMaintenanceInternalNoteService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + IncidentPublicNote, + IncidentPublicNoteService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + IncidentInternalNote, + IncidentInternalNoteService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + OnCallDutyPolicy, + OnCallDutyPolicyService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + ScheduledMaintenanceCustomField, + ScheduledMaintenanceCustomFieldServiceType + >( + ScheduledMaintenanceCustomField, + ScheduledMaintenanceCustomFieldService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + OnCallDutyPolicyEscalationRuleUser, + OnCallDutyPolicyEscalationRuleUserServiceType + >( + OnCallDutyPolicyEscalationRuleUser, + OnCallDutyPolicyEscalationRuleUserService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + OnCallDutyPolicyEscalationRuleTeam, + OnCallDutyPolicyEscalationRuleTeamServiceType + >( + OnCallDutyPolicyEscalationRuleTeam, + OnCallDutyPolicyEscalationRuleTeamService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + OnCallDutyPolicyEscalationRuleSchedule, + OnCallDutyPolicyEscalationRuleScheduleServiceType + >( + OnCallDutyPolicyEscalationRuleSchedule, + OnCallDutyPolicyEscalationRuleScheduleService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + OnCallDutyPolicyExecutionLog, + OnCallDutyPolicyExecutionLogServiceType + >( + OnCallDutyPolicyExecutionLog, + OnCallDutyPolicyExecutionLogService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + PromoCode, + PromoCodeService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + OnCallDutyPolicyExecutionLogTimeline, + OnCallDutyPolicyExecutionLogTimelineServiceType + >( + OnCallDutyPolicyExecutionLogTimeline, + OnCallDutyPolicyExecutionLogTimelineService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + IncidentCustomField, + IncidentCustomFieldService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + OnCallDutyPolicyEscalationRule, + OnCallDutyPolicyEscalationRuleServiceType + >( + OnCallDutyPolicyEscalationRule, + OnCallDutyPolicyEscalationRuleService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI( + MonitorCustomField, + MonitorCustomFieldService + ).getRouter() + ); + + app.use( + `/${APP_NAME.toLocaleLowerCase()}`, + new BaseAPI< + StatusPageCustomField, + StatusPageCustomFieldServiceType + >(StatusPageCustomField, StatusPageCustomFieldService).getRouter() + ); + + app.use(`/${APP_NAME.toLocaleLowerCase()}`, NotificationAPI); + }, }; -export default { init }; +export default BaseAPIFeatureSet; diff --git a/App/FeatureSet/Docs/Index.ts b/App/FeatureSet/Docs/Index.ts index 1da6cba64c..a1dc851c1a 100755 --- a/App/FeatureSet/Docs/Index.ts +++ b/App/FeatureSet/Docs/Index.ts @@ -10,79 +10,84 @@ import DocsNav, { NavGroup, NavLink } from './Utils/Nav'; import LocalFile from 'CommonServer/Utils/LocalFile'; import DocsRender from './Utils/Render'; import logger from 'CommonServer/Utils/Logger'; +import FeatureSet from 'CommonServer/Types/FeatureSet'; -const init: VoidFunction = (): void => { - const app: ExpressApplication = Express.getExpressApp(); +const DocsFeatureSet: FeatureSet = { + init: async (): Promise => { + const app: ExpressApplication = Express.getExpressApp(); - app.get('/docs', (_req: ExpressRequest, res: ExpressResponse) => { - res.redirect('/docs/introduction/getting-started'); - }); + app.get('/docs', (_req: ExpressRequest, res: ExpressResponse) => { + res.redirect('/docs/introduction/getting-started'); + }); - app.get( - '/docs/:categorypath/:pagepath', - async (_req: ExpressRequest, res: ExpressResponse) => { - try { - const fullPath: string = - `${_req.params['categorypath']}/${_req.params['pagepath']}`.toLowerCase(); + app.get( + '/docs/:categorypath/:pagepath', + async (_req: ExpressRequest, res: ExpressResponse) => { + try { + const fullPath: string = + `${_req.params['categorypath']}/${_req.params['pagepath']}`.toLowerCase(); - // read file from Content folder. - let contentInMarkdown: string = await LocalFile.read( - `${ContentPath}/${fullPath}.md` - ); + // read file from Content folder. + let contentInMarkdown: string = await LocalFile.read( + `${ContentPath}/${fullPath}.md` + ); - // remove first line from content because we dont want to show title in content. Title is already in nav. + // remove first line from content because we dont want to show title in content. Title is already in nav. - contentInMarkdown = contentInMarkdown - .split('\n') - .slice(1) - .join('\n'); + contentInMarkdown = contentInMarkdown + .split('\n') + .slice(1) + .join('\n'); - const renderedContent: string = await DocsRender.render( - contentInMarkdown - ); + const renderedContent: string = await DocsRender.render( + contentInMarkdown + ); - const currentCategory: NavGroup | undefined = DocsNav.find( - (category: NavGroup) => { - return category.links.find((link: NavLink) => { + const currentCategory: NavGroup | undefined = DocsNav.find( + (category: NavGroup) => { + return category.links.find((link: NavLink) => { + return link.url + .toLocaleLowerCase() + .includes(fullPath); + }); + } + ); + + const currrentNavLink: NavLink | undefined = + currentCategory?.links.find((link: NavLink) => { return link.url .toLocaleLowerCase() .includes(fullPath); }); + + if (!currentCategory || !currrentNavLink) { + // render not found. + + res.status(404); + return res.render(`${ViewsPath}/NotFound`, { + nav: DocsNav, + }); } - ); - const currrentNavLink: NavLink | undefined = - currentCategory?.links.find((link: NavLink) => { - return link.url.toLocaleLowerCase().includes(fullPath); + res.render(`${ViewsPath}/Index`, { + nav: DocsNav, + content: renderedContent, + category: currentCategory, + link: currrentNavLink, + githubPath: fullPath, }); - - if (!currentCategory || !currrentNavLink) { - // render not found. - - res.status(404); - return res.render(`${ViewsPath}/NotFound`, { + } catch (err) { + logger.error(err); + res.status(500); + return res.render(`${ViewsPath}/ServerError`, { nav: DocsNav, }); } - - res.render(`${ViewsPath}/Index`, { - nav: DocsNav, - content: renderedContent, - category: currentCategory, - link: currrentNavLink, - githubPath: fullPath, - }); - } catch (err) { - logger.error(err); - res.status(500); - return res.render(`${ViewsPath}/ServerError`, { - nav: DocsNav, - }); } - } - ); + ); - app.use('/docs/static', ExpressStatic(StaticPath)); + app.use('/docs/static', ExpressStatic(StaticPath)); + }, }; -export default { init }; +export default DocsFeatureSet; diff --git a/App/FeatureSet/Home/Index.ts b/App/FeatureSet/Home/Index.ts index fcfce74b51..5d6add93e1 100755 --- a/App/FeatureSet/Home/Index.ts +++ b/App/FeatureSet/Home/Index.ts @@ -21,1011 +21,1057 @@ import ServerErrorUtil from './Utils/ServerError'; // improt API import './API/BlogAPI'; +import FeatureSet from 'CommonServer/Types/FeatureSet'; -const init: VoidFunction = () => { - const app: ExpressApplication = Express.getExpressApp(); +const HomeFeatureSet: FeatureSet = { + init: async (): Promise => { + const app: ExpressApplication = Express.getExpressApp(); - //Routes - app.get('/', (_req: ExpressRequest, res: ExpressResponse) => { - res.render(`${ViewsPath}/index`, { - support: false, - footerCards: true, - cta: true, - blackLogo: false, - requestDemoCta: false, - }); - }); - - 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('/pricing', (_req: ExpressRequest, res: ExpressResponse) => { - const pricing: Array = [ - { - 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', - }, - }, - { - 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: '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: 'Container 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', - }, - }, - ], - }, - { - 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: '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, - 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`, { + //Routes + app.get('/', (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/index`, { support: false, - footerCards: false, - cta: false, - blackLogo: true, + footerCards: true, + cta: true, + blackLogo: false, 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 + 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' ); } - - //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(); + app.get( + '/support', + async (_req: ExpressRequest, res: ExpressResponse) => { + res.render(`${ViewsPath}/support`); + } + ); - if (!gitHubBasicInfo) { - const basicInfo: HTTPResponse = await API.get( + app.get('/pricing', (_req: ExpressRequest, res: ExpressResponse) => { + const pricing: Array = [ + { + 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', + }, + }, + { + 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: '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: 'Container 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', + }, + }, + ], + }, + { + 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: '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, + 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< + Array + >( + 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' + 'https://api.github.com/repos/oneuptime/oneuptime/commits?sha=master&per_page=1&page=1' ) ); - gitHubBasicInfo = basicInfo.data as JSONObject; + 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, + }); } + ); - 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); + 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.', + }); } - res.render(`${ViewsPath}/product-compare.ejs`, { + ); + + 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, - 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] }); + 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, + }); } + ); - //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); + 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, }); + }); - // Generate xml file - const xml: string = urlset.end({ prettyPrint: true }); + 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, + }); + } + ); - res.setHeader('Content-Type', 'text/xml'); - res.send(xml); - } - ); + 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, + }); + }); - /* - * 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('/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 ); - }, - }) - ); - app.get('/*', (_req: ExpressRequest, res: ExpressResponse) => { - return NotFoundUtil.renderNotFound(res); - }); + 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, + }); + } + ); - app.get('/server-error', (_req: ExpressRequest, res: ExpressResponse) => { - return ServerErrorUtil.renderServerError(res); - }); + // 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); + }); + + app.get( + '/server-error', + (_req: ExpressRequest, res: ExpressResponse) => { + return ServerErrorUtil.renderServerError(res); + } + ); + }, }; -export default { init }; +export default HomeFeatureSet; diff --git a/App/FeatureSet/Identity/Index.ts b/App/FeatureSet/Identity/Index.ts index eaac289380..fcdc352639 100644 --- a/App/FeatureSet/Identity/Index.ts +++ b/App/FeatureSet/Identity/Index.ts @@ -5,25 +5,27 @@ import SsoAPI from './API/SSO'; import ResellerAPI from './API/Reseller'; import StatusPageSsoAPI from './API/StatusPageSSO'; import StatusPageAuthenticationAPI from './API/StatusPageAuthentication'; -import { VoidFunction } from 'Common/Types/FunctionTypes'; +import FeatureSet from 'CommonServer/Types/FeatureSet'; -const init: VoidFunction = () => { - const app: ExpressApplication = Express.getExpressApp(); +const IdentityFeatureSet: FeatureSet = { + init: async (): Promise => { + const app: ExpressApplication = Express.getExpressApp(); - const APP_NAME: string = 'api/identity'; + const APP_NAME: string = 'api/identity'; - app.use([`/${APP_NAME}`, '/'], AuthenticationAPI); + app.use([`/${APP_NAME}`, '/'], AuthenticationAPI); - app.use([`/${APP_NAME}`, '/'], ResellerAPI); + app.use([`/${APP_NAME}`, '/'], ResellerAPI); - app.use([`/${APP_NAME}`, '/'], SsoAPI); + app.use([`/${APP_NAME}`, '/'], SsoAPI); - app.use([`/${APP_NAME}`, '/'], StatusPageSsoAPI); + app.use([`/${APP_NAME}`, '/'], StatusPageSsoAPI); - app.use( - [`/${APP_NAME}/status-page`, '/status-page'], - StatusPageAuthenticationAPI - ); + app.use( + [`/${APP_NAME}/status-page`, '/status-page'], + StatusPageAuthenticationAPI + ); + }, }; -export default { init }; +export default IdentityFeatureSet; diff --git a/App/FeatureSet/Notification/Index.ts b/App/FeatureSet/Notification/Index.ts index c451bff1a7..8e4a8afcaf 100644 --- a/App/FeatureSet/Notification/Index.ts +++ b/App/FeatureSet/Notification/Index.ts @@ -7,15 +7,18 @@ import SmsAPI from './API/SMS'; import CallAPI from './API/Call'; import SMTPConfigAPI from './API/SMTPConfig'; import './Utils/Handlebars'; +import FeatureSet from 'CommonServer/Types/FeatureSet'; -const init: VoidFunction = () => { - const APP_NAME: string = 'api/notification'; - const app: ExpressApplication = Express.getExpressApp(); +const NotificationFeatureSet: FeatureSet = { + init: async (): Promise => { + const APP_NAME: string = 'api/notification'; + const app: ExpressApplication = Express.getExpressApp(); - app.use([`/${APP_NAME}/email`, '/email'], MailAPI); - app.use([`/${APP_NAME}/sms`, '/sms'], SmsAPI); - app.use([`/${APP_NAME}/call`, '/call'], CallAPI); - app.use([`/${APP_NAME}/smtp-config`, '/smtp-config'], SMTPConfigAPI); + app.use([`/${APP_NAME}/email`, '/email'], MailAPI); + app.use([`/${APP_NAME}/sms`, '/sms'], SmsAPI); + app.use([`/${APP_NAME}/call`, '/call'], CallAPI); + app.use([`/${APP_NAME}/smtp-config`, '/smtp-config'], SMTPConfigAPI); + }, }; -export default { init }; +export default NotificationFeatureSet; diff --git a/App/FeatureSet/Workflow/API/ComponentCode.ts b/App/FeatureSet/Workflow/API/ComponentCode.ts index 25ba1b9009..f3d6214ee1 100644 --- a/App/FeatureSet/Workflow/API/ComponentCode.ts +++ b/App/FeatureSet/Workflow/API/ComponentCode.ts @@ -13,11 +13,14 @@ export default class ComponentCodeAPI { public constructor() { this.router = Express.getRouter(); + } + public init(): void { // init all component code. /// Get all the components. for (const key in Components) { const ComponentCode: ComponentCode | undefined = Components[key]; + if (ComponentCode instanceof TriggerCode) { const instance: TriggerCode = ComponentCode; instance diff --git a/App/FeatureSet/Workflow/Index.ts b/App/FeatureSet/Workflow/Index.ts index 41c532aad7..d9c8978ff8 100644 --- a/App/FeatureSet/Workflow/Index.ts +++ b/App/FeatureSet/Workflow/Index.ts @@ -5,7 +5,7 @@ import Express, { } from 'CommonServer/Utils/Express'; import logger from 'CommonServer/Utils/Logger'; import ManualAPI from './API/Manual'; -import ComponentCode from './API/ComponentCode'; +import ComponentCodeAPI from './API/ComponentCode'; import { QueueJob, QueueName } from 'CommonServer/Infrastructure/Queue'; import QueueWorker from 'CommonServer/Infrastructure/QueueWorker'; import RunWorkflow from './Services/RunWorkflow'; @@ -16,27 +16,30 @@ import FeatureSet from 'CommonServer/Types/FeatureSet'; const APP_NAME: string = 'api/workflow'; -const app: ExpressApplication = Express.getExpressApp(); - -app.use(`/${APP_NAME}/manual`, new ManualAPI().router); - -app.use(`/${APP_NAME}`, new WorkflowAPI().router); - -app.get( - `/${APP_NAME}/docs/:componentName`, - (req: ExpressRequest, res: ExpressResponse) => { - res.sendFile( - '/usr/src/app/FeatureSet/Workflow/Docs/ComponentDocumentation/' + - req.params['componentName'] - ); - } -); - -app.use(`/${APP_NAME}`, new ComponentCode().router); - const WorkflowFeatureSet: FeatureSet = { init: async (): Promise => { try { + const componentCodeAPI: ComponentCodeAPI = new ComponentCodeAPI(); + componentCodeAPI.init(); + + const app: ExpressApplication = Express.getExpressApp(); + + app.use(`/${APP_NAME}/manual`, new ManualAPI().router); + + app.use(`/${APP_NAME}`, new WorkflowAPI().router); + + app.get( + `/${APP_NAME}/docs/:componentName`, + (req: ExpressRequest, res: ExpressResponse) => { + res.sendFile( + '/usr/src/app/FeatureSet/Workflow/Docs/ComponentDocumentation/' + + req.params['componentName'] + ); + } + ); + + app.use(`/${APP_NAME}`, componentCodeAPI.router); + // Job process. QueueWorker.getWorker( QueueName.Workflow, diff --git a/CommonServer/Infrastructure/ClickhouseDatabase.ts b/CommonServer/Infrastructure/ClickhouseDatabase.ts index 0e4a107b55..c532b13a07 100644 --- a/CommonServer/Infrastructure/ClickhouseDatabase.ts +++ b/CommonServer/Infrastructure/ClickhouseDatabase.ts @@ -98,6 +98,32 @@ export default class ClickhouseDatabase { this.dataSource = null; } } + + public async checkConnnectionStatus(): Promise { + // Ping clickhouse to check if the connection is still alive + try { + const result: PingResult | undefined = + await this.getDataSource()?.ping(); + + if (!result) { + throw new DatabaseNotConnectedException( + 'Clickhouse Database is not connected' + ); + } + + if (result?.success === false) { + throw new DatabaseNotConnectedException( + 'Clickhouse Database is not connected' + ); + } + + return true; + } catch (err) { + logger.error('Clickhouse Connection Lost'); + logger.error(err); + return false; + } + } } export const ClickhouseAppInstance: ClickhouseDatabase = diff --git a/CommonServer/Infrastructure/PostgresDatabase.ts b/CommonServer/Infrastructure/PostgresDatabase.ts index 8f413e0f26..2906fe8a4f 100644 --- a/CommonServer/Infrastructure/PostgresDatabase.ts +++ b/CommonServer/Infrastructure/PostgresDatabase.ts @@ -71,6 +71,23 @@ export default class Database { this.dataSource = null; } } + + public async checkConnnectionStatus(): Promise { + // check popstgres connection to see if it is still alive + + try { + await this.dataSource?.query( + `SELECT COUNT(key) FROM ${ + this.getDatasourceOptions().database + }.GreenlockChallenge` + ); // this is a dummy query to check if the connection is still alive + return true; + } catch (err) { + logger.error('Postgres Connection Lost'); + logger.error(err); + return false; + } + } } export const PostgresAppInstance: Database = new Database(); diff --git a/CommonServer/Infrastructure/Redis.ts b/CommonServer/Infrastructure/Redis.ts index b1c9503668..5b5fca55a8 100644 --- a/CommonServer/Infrastructure/Redis.ts +++ b/CommonServer/Infrastructure/Redis.ts @@ -122,4 +122,16 @@ export default abstract class Redis { this.client = null; } } + + public static async checkConnnectionStatus(): Promise { + // Ping redis to check if the connection is still alive + try { + await this.client?.ping(); + return true; + } catch (err) { + logger.error('Redis Connection Lost'); + logger.error(err); + return false; + } + } }