Skip to content

Commit e38a7a5

Browse files
author
hywax
committed
chore: provide safely config
1 parent 05cb0ea commit e38a7a5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: server/api/settings.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ import type { CompleteConfig } from '~/types'
22

33
export default defineEventHandler(async () => {
44
const storage = useStorage('main')
5+
const config = await storage.getItem<CompleteConfig>('config')
56

6-
return await storage.getItem<CompleteConfig>('config')
7+
if (!config) {
8+
throw createError({
9+
statusCode: 500,
10+
statusMessage: 'Bad loading config',
11+
})
12+
}
13+
14+
return extractSafelyConfig(config)
715
})

0 commit comments

Comments
 (0)