refactor(services): update service creation logic and enhance service group schema
- Changed service creation to default `enabled` to true in the database schema. - Updated service group schema to set default values for `icon`, `domain`, and health check parameters. - Refactored service routes to use `await` for fetching service views, ensuring proper asynchronous handling. - Improved error handling in service groups query to provide clearer feedback on response validation. This commit enhances the overall service management experience by ensuring services are enabled by default and improving the robustness of the service group schema.
This commit is contained in:
1 parent
3fb8480f8a
commit
ce8393e0c3
12 files changed
+346
-186
No files matched your search
@@ -20,7 +20,19 @@ export const serviceGroupsQueryOptions = () =>
|
||||
queryKey: serviceGroupKeys.all,
|
||||
queryFn: async () => {
|
||||
const data = await api.get<unknown>('/api/v1/service-groups')
|
||||
return serviceGroupsResponseSchema.parse(data)
|
||||
const parsed = serviceGroupsResponseSchema.safeParse(data)
|
||||
if (!parsed.success) {
|
||||
const detail = parsed.error.issues
|
||||
.slice(0, 3)
|
||||
.map((issue) => `${issue.path.join('.') || '(root)'}: ${issue.message}`)
|
||||
.join('; ')
|
||||
throw new Error(
|
||||
detail
|
||||
? `Некорректный ответ /service-groups: ${detail}`
|
||||
: 'Некорректный ответ /service-groups',
|
||||
)
|
||||
}
|
||||
return parsed.data
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user