refactor: remove router

This commit is contained in:
Mauricio Siu
2024-09-05 01:06:35 -06:00
parent 4f49a10aef
commit 66cd434839
7 changed files with 3577 additions and 55 deletions

View File

@@ -245,15 +245,13 @@ export const RequestsTable = () => {
colSpan={columns.length}
className="h-24 text-center"
>
{/* {isLoading ? (
{statsLogs?.data.length === 0 && (
<div className="w-full flex-col gap-2 flex items-center justify-center h-[55vh]">
<span className="text-muted-foreground text-lg font-medium">
Loading...
No results.
</span>
</div>
) : (
<>No results.</>
)} */}
)}
</TableCell>
</TableRow>
)}

View File

@@ -0,0 +1 @@
ALTER TABLE "admin" ADD COLUMN "enableLogRotation" boolean DEFAULT false NOT NULL;

File diff suppressed because it is too large Load Diff

View File

@@ -253,6 +253,13 @@
"when": 1725429324584,
"tag": "0035_cool_gravity",
"breakpoints": true
},
{
"idx": 36,
"version": "6",
"when": 1725519351871,
"tag": "0036_tired_ronan",
"breakpoints": true
}
]
}

View File

@@ -29,7 +29,6 @@ import { securityRouter } from "./routers/security";
import { settingsRouter } from "./routers/settings";
import { sshRouter } from "./routers/ssh-key";
import { userRouter } from "./routers/user";
import { licenseRouter } from "./routers/license";
/**
* This is the primary router for your server.
@@ -63,7 +62,6 @@ export const appRouter = createTRPCRouter({
cluster: clusterRouter,
notification: notificationRouter,
sshKey: sshRouter,
license: licenseRouter,
gitProvider: gitProviderRouter,
bitbucket: bitbucketRouter,
gitlab: gitlabRouter,

View File

@@ -1,47 +0,0 @@
import { z } from "zod";
import { findAdmin, updateAdmin } from "../services/admin";
import { adminProcedure, createTRPCRouter } from "../trpc";
import { TRPCError } from "@trpc/server";
export const licenseRouter = createTRPCRouter({
setLicense: adminProcedure.input(z.string()).mutation(async ({ input }) => {
const admin = await findAdmin();
if (!input) {
return await updateAdmin(admin.authId, {
licenseKey: "",
});
}
try {
const result = await fetch("http://127.0.0.1:4000/v1/validate-license", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
licenseKey: input,
}),
});
const data = await result.json();
if (!data.valid) {
throw new TRPCError({
code: "BAD_REQUEST",
message: "License is invalid",
});
}
if (data.valid) {
return await updateAdmin(admin.authId, {
licenseKey: input,
});
}
} catch (err) {
return await updateAdmin(admin.authId, {
licenseKey: "",
});
}
}),
});

View File

@@ -20,7 +20,6 @@ export const admins = pgTable("admin", {
sshPrivateKey: text("sshPrivateKey"),
enableDockerCleanup: boolean("enableDockerCleanup").notNull().default(false),
enableLogRotation: boolean("enableLogRotation").notNull().default(false),
licenseKey: text("licenseKey"),
authId: text("authId")
.notNull()
.references(() => auth.id, { onDelete: "cascade" }),