mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
Refactor config overrides CRUD handlers by simplifying paramsSchema and removing unused exports in route.tsx
This commit is contained in:
parent
40db4e2ff0
commit
7862a3ef65
13
apps/backend/src/app/api/latest/internal/configs/crud.tsx
Normal file
13
apps/backend/src/app/api/latest/internal/configs/crud.tsx
Normal file
@ -0,0 +1,13 @@
|
||||
import { createCrudHandlers } from "@/route-handlers/crud-handler";
|
||||
import { configCrud } from "@stackframe/stack-shared/dist/interface/crud/config";
|
||||
import { yupObject } from "@stackframe/stack-shared/dist/schema-fields";
|
||||
import { createLazyProxy } from "@stackframe/stack-shared/dist/utils/proxies";
|
||||
|
||||
export const configCrudHandlers = createLazyProxy(() => createCrudHandlers(configCrud, {
|
||||
paramsSchema: yupObject({}),
|
||||
onRead: async ({ auth }) => {
|
||||
return {
|
||||
configString: JSON.stringify(auth.tenancy.config),
|
||||
};
|
||||
},
|
||||
}));
|
||||
@ -2,14 +2,12 @@ import { getRenderedEnvironmentConfigQuery, overrideEnvironmentConfigOverride }
|
||||
import { globalPrismaClient, rawQuery } from "@/prisma-client";
|
||||
import { createCrudHandlers } from "@/route-handlers/crud-handler";
|
||||
import { configOverrideCrud } from "@stackframe/stack-shared/dist/interface/crud/config";
|
||||
import { yupObject, yupString } from "@stackframe/stack-shared/dist/schema-fields";
|
||||
import { yupObject } from "@stackframe/stack-shared/dist/schema-fields";
|
||||
import { StatusError } from "@stackframe/stack-shared/dist/utils/errors";
|
||||
import { createLazyProxy } from "@stackframe/stack-shared/dist/utils/proxies";
|
||||
|
||||
export const configOverridesCrudHandlers = createLazyProxy(() => createCrudHandlers(configOverrideCrud, {
|
||||
paramsSchema: yupObject({
|
||||
emailId: yupString().optional(),
|
||||
}),
|
||||
paramsSchema: yupObject({}),
|
||||
onUpdate: async ({ auth, data }) => {
|
||||
if (data.configOverrideString) {
|
||||
let parsedConfig;
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
import { configOverridesCrudHandlers } from "./crud";
|
||||
|
||||
export const PATCH = configOverridesCrudHandlers.updateHandler;
|
||||
@ -1,4 +0,0 @@
|
||||
import { configOverridesCrudHandlers } from "./overrides/crud";
|
||||
|
||||
export const GET = configOverridesCrudHandlers.readHandler;
|
||||
export const PATCH = configOverridesCrudHandlers.updateHandler;
|
||||
Loading…
Reference in New Issue
Block a user