mirror of
https://github.com/fosrl/pangolin.git
synced 2026-01-28 22:00:51 +00:00
remove org settings json
This commit is contained in:
@@ -25,8 +25,7 @@ export const orgs = pgTable("orgs", {
|
||||
orgId: varchar("orgId").primaryKey(),
|
||||
name: varchar("name").notNull(),
|
||||
subnet: varchar("subnet"),
|
||||
createdAt: text("createdAt"),
|
||||
settings: text("settings") // JSON blob of org-specific settings
|
||||
createdAt: text("createdAt")
|
||||
});
|
||||
|
||||
export const orgDomains = pgTable("orgDomains", {
|
||||
|
||||
@@ -18,8 +18,7 @@ export const orgs = sqliteTable("orgs", {
|
||||
orgId: text("orgId").primaryKey(),
|
||||
name: text("name").notNull(),
|
||||
subnet: text("subnet"),
|
||||
createdAt: text("createdAt"),
|
||||
settings: text("settings") // JSON blob of org-specific settings
|
||||
createdAt: text("createdAt")
|
||||
});
|
||||
|
||||
export const userDomains = sqliteTable("userDomains", {
|
||||
|
||||
@@ -17,7 +17,7 @@ const getOrgSchema = z
|
||||
.strict();
|
||||
|
||||
export type GetOrgResponse = {
|
||||
org: Org & { settings: { } | null };
|
||||
org: Org;
|
||||
};
|
||||
|
||||
registry.registerPath({
|
||||
@@ -64,23 +64,9 @@ export async function getOrg(
|
||||
);
|
||||
}
|
||||
|
||||
// Parse settings from JSON string back to object
|
||||
let parsedSettings = null;
|
||||
if (org[0].settings) {
|
||||
try {
|
||||
parsedSettings = JSON.parse(org[0].settings);
|
||||
} catch (error) {
|
||||
// If parsing fails, keep as string for backward compatibility
|
||||
parsedSettings = org[0].settings;
|
||||
}
|
||||
}
|
||||
|
||||
return response<GetOrgResponse>(res, {
|
||||
data: {
|
||||
org: {
|
||||
...org[0],
|
||||
settings: parsedSettings
|
||||
}
|
||||
org: org[0]
|
||||
},
|
||||
success: true,
|
||||
error: false,
|
||||
|
||||
@@ -12,15 +12,13 @@ import { OpenAPITags, registry } from "@server/openApi";
|
||||
|
||||
const updateOrgParamsSchema = z
|
||||
.object({
|
||||
orgId: z.string(),
|
||||
orgId: z.string()
|
||||
})
|
||||
.strict();
|
||||
|
||||
const updateOrgBodySchema = z
|
||||
.object({
|
||||
name: z.string().min(1).max(255).optional(),
|
||||
settings: z.object({
|
||||
}).optional(),
|
||||
name: z.string().min(1).max(255).optional()
|
||||
})
|
||||
.strict()
|
||||
.refine((data) => Object.keys(data).length > 0, {
|
||||
@@ -73,13 +71,10 @@ export async function updateOrg(
|
||||
|
||||
const { orgId } = parsedParams.data;
|
||||
|
||||
const settings = parsedBody.data.settings ? JSON.stringify(parsedBody.data.settings) : undefined;
|
||||
|
||||
const updatedOrg = await db
|
||||
.update(orgs)
|
||||
.set({
|
||||
name: parsedBody.data.name,
|
||||
settings: settings
|
||||
name: parsedBody.data.name
|
||||
})
|
||||
.where(eq(orgs.orgId, orgId))
|
||||
.returning();
|
||||
|
||||
Reference in New Issue
Block a user