MCPcopy
hub / github.com/Dokploy/dokploy / updateSecurityById

Function updateSecurityById

packages/server/src/services/security.ts:89–131  ·  view source on GitHub ↗
(
	securityId: string,
	data: Partial<Security>,
)

Source from the content-addressed store, hash-verified

87};
88
89export const updateSecurityById = async (
90 securityId: string,
91 data: Partial<Security>,
92) => {
93 try {
94 await db.transaction(async (tx) => {
95 const securityResponse = await findSecurityById(securityId);
96
97 const application = await findApplicationById(
98 securityResponse.applicationId,
99 );
100
101 await removeSecurityMiddleware(application, securityResponse);
102
103 const response = await tx
104 .update(security)
105 .set({
106 ...data,
107 })
108 .where(eq(security.securityId, securityId))
109 .returning()
110 .then((res) => res[0]);
111
112 if (!response) {
113 throw new TRPCError({
114 code: "NOT_FOUND",
115 message: "Security not found",
116 });
117 }
118
119 await createSecurityMiddleware(application, response);
120
121 return response;
122 });
123 } catch (error) {
124 const message =
125 error instanceof Error ? error.message : "Error updating this security";
126 throw new TRPCError({
127 code: "BAD_REQUEST",
128 message,
129 });
130 }
131};

Callers 1

security.tsFile · 0.90

Calls 4

findApplicationByIdFunction · 0.90
removeSecurityMiddlewareFunction · 0.90
createSecurityMiddlewareFunction · 0.90
findSecurityByIdFunction · 0.85

Tested by

no test coverage detected