chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:34:48 +08:00
commit 77bb5bf71f
3762 changed files with 353249 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import { Result } from './types'
export const safeParseJson = (json: string): Result<object> => {
try {
return {
success: true,
data: JSON.parse(json),
} as const
} catch (thrown: unknown) {
return {
success: false,
error: thrown instanceof Error ? thrown : new Error(String(thrown)),
} as const
}
}
export const safeParseRequestBody = (body: string | undefined): Result<object> => {
if (!body?.trim()) {
return {
success: false,
error: new Error('Request body is empty'),
}
}
return safeParseJson(body)
}