Make private

This commit is contained in:
Owen
2025-11-13 17:45:13 -05:00
committed by Owen Schwartz
parent d3c4688c0f
commit 19f8cda3d9
8 changed files with 1450 additions and 35 deletions

1394
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -16,6 +16,7 @@ import * as auth from "#private/routers/auth";
import * as orgIdp from "#private/routers/orgIdp";
import * as billing from "#private/routers/billing";
import * as license from "#private/routers/license";
import * as resource from "#private/routers/resource";
import { verifySessionUserMiddleware } from "@server/middlewares";
@@ -37,3 +38,5 @@ internalRouter.post(
);
internalRouter.get(`/license/status`, license.getLicenseStatus);
internalRouter.get("/maintenance/info", resource.getMaintenanceInfo);

View File

@@ -1,3 +1,15 @@
/*
* This file is part of a proprietary work.
*
* Copyright (c) 2025 Fossorial, Inc.
* All rights reserved.
*
* This file is licensed under the Fossorial Commercial License.
* You may not use this file except in compliance with the License.
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
*
* This file is not licensed under the AGPLv3.
*/
import { Request, Response, NextFunction } from "express";
import { z } from "zod";
@@ -10,6 +22,7 @@ import createHttpError from "http-errors";
import { fromError } from "zod-validation-error";
import logger from "@server/logger";
import { OpenAPITags, registry } from "@server/openApi";
import { GetMaintenanceInfoResponse } from "@server/routers/resource/types";
const getMaintenanceInfoSchema = z
.object({
@@ -35,10 +48,6 @@ async function query(fullDomain: string) {
return res;
}
export type GetMaintenanceInfoResponse = NonNullable<
Awaited<ReturnType<typeof query>>
>;
registry.registerPath({
method: "get",
path: "/maintenance/info",

View File

@@ -0,0 +1,14 @@
/*
* This file is part of a proprietary work.
*
* Copyright (c) 2025 Fossorial, Inc.
* All rights reserved.
*
* This file is licensed under the Fossorial Commercial License.
* You may not use this file except in compliance with the License.
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
*
* This file is not licensed under the AGPLv3.
*/
export * from "./getMaintenanceInfo";

View File

@@ -48,7 +48,6 @@ import createHttpError from "http-errors";
import { build } from "@server/build";
import { createStore } from "#dynamic/lib/rateLimitStore";
import { logActionAudit } from "#dynamic/middlewares";
import { log } from "console";
// Root routes
export const unauthenticated = Router();
@@ -57,8 +56,6 @@ unauthenticated.get("/", (_, res) => {
res.status(HttpCode.OK).json({ message: "Healthy" });
});
unauthenticated.get("/maintenance/info", resource.getMaintenanceInfo);
// Authenticated Root routes
export const authenticated = Router();
authenticated.use(verifySessionUserMiddleware);

View File

@@ -31,3 +31,4 @@ export * from "./addUserToResource";
export * from "./removeUserFromResource";
export * from "./listAllResourceNames";
export * from "./getMaintenanceInfo";
export * from "./removeEmailFromResourceWhitelist";

View File

@@ -0,0 +1,10 @@
export type GetMaintenanceInfoResponse = {
resourceId: number;
name: string;
fullDomain: string | null;
maintenanceModeEnabled: boolean;
maintenanceModeType: "forced" | "automatic" | null;
maintenanceTitle: string | null;
maintenanceMessage: string | null;
maintenanceEstimatedTime: string | null;
}

View File

@@ -1,8 +1,7 @@
import { headers } from "next/headers";
import { priv } from "@app/lib/api";
import { GetMaintenanceInfoResponse } from "@server/routers/resource";
import { GetMaintenanceInfoResponse } from "@server/routers/resource/types";
export const dynamic = "force-dynamic";
export const revalidate = 0;
@@ -13,32 +12,26 @@ export default async function MaintenanceScreen() {
"We are currently experiencing technical difficulties. Please check back soon.";
let estimatedTime: string | null = null;
// Check if we're in build mode
const isBuildTime = process.env.NEXT_PHASE === 'phase-production-build';
try {
const headersList = await headers();
const host = headersList.get("host") || "";
const hostname = host.split(":")[0];
if (!isBuildTime) {
try {
const headersList = await headers();
const host = headersList.get("host") || "";
const hostname = host.split(":")[0];
const res = await priv.get<GetMaintenanceInfoResponse>(
`/maintenance/info?fullDomain=${encodeURIComponent(hostname)}`
);
const res = await priv.get<GetMaintenanceInfoResponse>(
`/maintenance/info?fullDomain=${encodeURIComponent(hostname)}`
);
if (res && res.status === 200) {
const maintenanceInfo = res.data;
title = maintenanceInfo?.maintenanceTitle || title;
message = maintenanceInfo?.maintenanceMessage || message;
estimatedTime = maintenanceInfo?.maintenanceEstimatedTime || null;
}
} catch (err) {
console.warn(
"Failed to fetch maintenance info",
err instanceof Error ? err.message : String(err)
);
if (res && res.status === 200) {
const maintenanceInfo = res.data;
title = maintenanceInfo?.maintenanceTitle || title;
message = maintenanceInfo?.maintenanceMessage || message;
estimatedTime = maintenanceInfo?.maintenanceEstimatedTime || null;
}
} catch (err) {
console.warn(
"Failed to fetch maintenance info",
err instanceof Error ? err.message : String(err)
);
}
return (