Skip to content

Commit d8db183

Browse files
committed
refactor: error handling to use statusinstead of statusCode
1 parent e81ceeb commit d8db183

23 files changed

+25
-25
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export default defineEventHandler(async (event) => {
113113
const isValidWebhook = await isValidGitHubWebhook(event)
114114

115115
if (!isValidWebhook) {
116-
throw createError({ statusCode: 401, message: 'Unauthorized: webhook is not valid' })
116+
throw createError({ status: 401, message: 'Unauthorized: webhook is not valid' })
117117
}
118118

119119
// Some logic...
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default defineEventHandler(async (event) => {
22
const isValidWebhook = await isValidBrevoWebhook(event)
33

4-
if (!isValidWebhook) throw createError({ statusCode: 401, message: 'Unauthorized: webhook is not valid' })
4+
if (!isValidWebhook) throw createError({ status: 401, message: 'Unauthorized: webhook is not valid' })
55

66
return { isValidWebhook }
77
})

playground/server/api/webhooks/discord.post.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default defineEventHandler(async (event) => {
22
const isValidWebhook = await isValidDiscordWebhook(event)
3-
if (!isValidWebhook) throw createError({ statusCode: 401, message: 'Unauthorized: webhook is not valid' })
3+
if (!isValidWebhook) throw createError({ status: 401, message: 'Unauthorized: webhook is not valid' })
44

55
const body = await readBody(event)
66

playground/server/api/webhooks/dropbox.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ export default defineEventHandler(async (event) => {
44
return query['challenge']
55
}
66

7-
if (event.method !== 'POST') throw createError({ statusCode: 405, message: 'Method Not Allowed' })
7+
if (event.method !== 'POST') throw createError({ status: 405, message: 'Method Not Allowed' })
88

99
const isValidWebhook = await isValidDropboxWebhook(event)
1010

11-
if (!isValidWebhook) throw createError({ statusCode: 401, message: 'Unauthorized: webhook is not valid' })
11+
if (!isValidWebhook) throw createError({ status: 401, message: 'Unauthorized: webhook is not valid' })
1212

1313
return { isValidWebhook }
1414
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default defineEventHandler(async (event) => {
22
const isValidWebhook = await isValidFourthwallWebhook(event)
33

4-
if (!isValidWebhook) throw createError({ statusCode: 401, message: 'Unauthorized: webhook is not valid' })
4+
if (!isValidWebhook) throw createError({ status: 401, message: 'Unauthorized: webhook is not valid' })
55

66
return { isValidWebhook }
77
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default defineEventHandler(async (event) => {
22
const isValidWebhook = await isValidGitHubWebhook(event)
33

4-
if (!isValidWebhook) throw createError({ statusCode: 401, message: 'Unauthorized: webhook is not valid' })
4+
if (!isValidWebhook) throw createError({ status: 401, message: 'Unauthorized: webhook is not valid' })
55

66
return { isValidWebhook }
77
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default defineEventHandler(async (event) => {
22
const isValidWebhook = await isValidGitLabWebhook(event)
33

4-
if (!isValidWebhook) throw createError({ statusCode: 401, message: 'Unauthorized: webhook is not valid' })
4+
if (!isValidWebhook) throw createError({ status: 401, message: 'Unauthorized: webhook is not valid' })
55

66
return { isValidWebhook }
77
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default defineEventHandler(async (event) => {
22
const isValidWebhook = await isValidHerokuWebhook(event)
33

4-
if (!isValidWebhook) throw createError({ statusCode: 401, message: 'Unauthorized: webhook is not valid' })
4+
if (!isValidWebhook) throw createError({ status: 401, message: 'Unauthorized: webhook is not valid' })
55

66
return { isValidWebhook }
77
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default defineEventHandler(async (event) => {
22
const isValidWebhook = await isValidHygraphWebhook(event)
33

4-
if (!isValidWebhook) throw createError({ statusCode: 401, message: 'Unauthorized: webhook is not valid' })
4+
if (!isValidWebhook) throw createError({ status: 401, message: 'Unauthorized: webhook is not valid' })
55

66
return { isValidWebhook }
77
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default defineEventHandler(async (event) => {
22
const isValidWebhook = await isValidKickWebhook(event)
33

4-
if (!isValidWebhook) throw createError({ statusCode: 401, message: 'Unauthorized: webhook is not valid' })
4+
if (!isValidWebhook) throw createError({ status: 401, message: 'Unauthorized: webhook is not valid' })
55

66
return { isValidWebhook }
77
})

0 commit comments

Comments
 (0)