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} colSpan={columns.length}
className="h-24 text-center" 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]"> <div className="w-full flex-col gap-2 flex items-center justify-center h-[55vh]">
<span className="text-muted-foreground text-lg font-medium"> <span className="text-muted-foreground text-lg font-medium">
Loading... No results.
</span> </span>
</div> </div>
) : ( )}
<>No results.</>
)} */}
</TableCell> </TableCell>
</TableRow> </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, "when": 1725429324584,
"tag": "0035_cool_gravity", "tag": "0035_cool_gravity",
"breakpoints": true "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 { settingsRouter } from "./routers/settings";
import { sshRouter } from "./routers/ssh-key"; import { sshRouter } from "./routers/ssh-key";
import { userRouter } from "./routers/user"; import { userRouter } from "./routers/user";
import { licenseRouter } from "./routers/license";
/** /**
* This is the primary router for your server. * This is the primary router for your server.
@@ -63,7 +62,6 @@ export const appRouter = createTRPCRouter({
cluster: clusterRouter, cluster: clusterRouter,
notification: notificationRouter, notification: notificationRouter,
sshKey: sshRouter, sshKey: sshRouter,
license: licenseRouter,
gitProvider: gitProviderRouter, gitProvider: gitProviderRouter,
bitbucket: bitbucketRouter, bitbucket: bitbucketRouter,
gitlab: gitlabRouter, 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"), sshPrivateKey: text("sshPrivateKey"),
enableDockerCleanup: boolean("enableDockerCleanup").notNull().default(false), enableDockerCleanup: boolean("enableDockerCleanup").notNull().default(false),
enableLogRotation: boolean("enableLogRotation").notNull().default(false), enableLogRotation: boolean("enableLogRotation").notNull().default(false),
licenseKey: text("licenseKey"),
authId: text("authId") authId: text("authId")
.notNull() .notNull()
.references(() => auth.id, { onDelete: "cascade" }), .references(() => auth.id, { onDelete: "cascade" }),