Add sentry capture exception to apiWrapper (#47804)

## Context

As per PR title - also adjusts the imports for files consuming
`apiWrapper` to remove the default export for `apiWrapper`

Have tested locally by throwing an error in one of the API routes -
verified that the event shows up on Sentry

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* API errors are now captured in Sentry before returning server error
responses, improving production visibility while keeping endpoint
behavior the same.
* **Tests**
* Added coverage to confirm rejected handler executions are reported to
Sentry and return the expected HTTP 500 JSON payload.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Joshen Lim authored and GitHub committed 2026-07-10 16:28:42 +08:00
1 parent 66bfc5fdc3
commit dc23320e43
89 files changed
+107 -93

No files matched your search

+4 -5
View File
@@ -1,3 +1,4 @@
import * as Sentry from '@sentry/nextjs'
import type { JwtPayload } from '@supabase/supabase-js'
import type { NextApiRequest, NextApiResponse } from 'next'
@@ -24,7 +25,7 @@ export function isResponseOk<T>(response: T | ResponseFailure | undefined): resp
// Purpose of this apiWrapper is to function like a global catchall for ANY errors
// It's a safety net as the API service should never drop, nor fail
async function apiWrapper(
export async function apiWrapper(
req: NextApiRequest,
res: NextApiResponse,
handler: (
@@ -50,11 +51,9 @@ async function apiWrapper(
claims = response
}
return handler(req, res, claims)
return await handler(req, res, claims)
} catch (error) {
Sentry.captureException(error)
return res.status(500).json({ error })
}
}
export { apiWrapper }
export default apiWrapper
+16 -1
View File
@@ -1,9 +1,10 @@
import * as Sentry from '@sentry/nextjs'
import type { JwtPayload } from '@supabase/supabase-js'
import type { NextApiRequest, NextApiResponse } from 'next'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { apiAuthenticate } from './apiAuthenticate'
import apiWrapper from './apiWrapper'
import { apiWrapper } from './apiWrapper'
import { ResponseError } from '@/types'
vi.mock('@/lib/constants', () => ({
@@ -15,6 +16,10 @@ vi.mock('./apiAuthenticate', () => ({
apiAuthenticate: vi.fn(),
}))
vi.mock('@sentry/nextjs', () => ({
captureException: vi.fn(),
}))
describe('apiWrapper', () => {
const mockReq = {} as NextApiRequest
const mockRes = {
@@ -59,4 +64,14 @@ describe('apiWrapper', () => {
expect(mockRes.status).toHaveBeenCalledWith(401)
expect(mockHandler).not.toHaveBeenCalled()
})
it('should report to Sentry and return 500 when the handler throws', async () => {
const mockError = new Error('boom')
mockHandler.mockRejectedValue(mockError)
await apiWrapper(mockReq, mockRes, mockHandler, { withAuth: false })
expect(Sentry.captureException).toHaveBeenCalledWith(mockError)
expect(mockRes.status).toHaveBeenCalledWith(500)
expect(mockRes.json).toHaveBeenCalledWith({ error: mockError })
})
})
+1 -1
View File
@@ -18,7 +18,7 @@ import {
SECURITY_PROMPT,
SQL_COMPLETION_INSTRUCTIONS,
} from '@/lib/ai/prompts'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { executeQuery } from '@/lib/api/self-hosted/query'
export const maxDuration = 60
@@ -4,7 +4,7 @@ import { z } from 'zod'
import { getModel } from '@/lib/ai/model'
import { DEFAULT_COMPLETION_MODEL } from '@/lib/ai/model.utils'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
async function handler(req: NextApiRequest, res: NextApiResponse) {
const { method } = req
+1 -1
View File
@@ -11,7 +11,7 @@ import { IS_TRACING_ENABLED, isTracingAllowed } from '@/lib/ai/braintrust-logger
import { getModel } from '@/lib/ai/model'
import { DEFAULT_COMPLETION_MODEL } from '@/lib/ai/model.utils'
import { sanitizeMessagePart } from '@/lib/ai/tools/tool-sanitizer'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export const maxDuration = 30
@@ -5,7 +5,7 @@ import { z } from 'zod'
import { getModel } from '@/lib/ai/model'
import { DEFAULT_COMPLETION_MODEL } from '@/lib/ai/model.utils'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export const maxDuration = 60
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
const wrapper = (req: NextApiRequest, res: NextApiResponse) =>
apiWrapper(req, res, handler, { withAuth: true })
+1 -1
View File
@@ -5,7 +5,7 @@ import { z } from 'zod'
import { getModel } from '@/lib/ai/model'
import { DEFAULT_COMPLETION_MODEL } from '@/lib/ai/model.utils'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
const cronSchema = z.object({
cron_expression: z.string().describe('The generated cron expression.'),
+1 -1
View File
@@ -4,7 +4,7 @@ import { NextApiRequest, NextApiResponse } from 'next'
import { getModel } from '@/lib/ai/model'
import { DEFAULT_COMPLETION_MODEL } from '@/lib/ai/model.utils'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import {
filterGroupSchemaForAI,
requestSchema,
+1 -1
View File
@@ -20,7 +20,7 @@ import {
type AssistantModelId,
} from '@/lib/ai/model.utils'
import { getTools } from '@/lib/ai/tools'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { executeQuery } from '@/lib/api/self-hosted/query'
import { getURL } from '@/lib/helpers'
@@ -5,7 +5,7 @@ import { z } from 'zod'
import { getModel } from '@/lib/ai/model'
import { DEFAULT_COMPLETION_MODEL } from '@/lib/ai/model.utils'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
const codeSchema = z.object({
sql: z
+1 -1
View File
@@ -10,7 +10,7 @@ import { getModel } from '@/lib/ai/model'
import { DEFAULT_COMPLETION_MODEL } from '@/lib/ai/model.utils'
import { RLS_PROMPT } from '@/lib/ai/prompts'
import { getTools } from '@/lib/ai/tools'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
const policySchema = z.object({
sql: z.string().describe('The generated Postgres CREATE POLICY statement.'),
+1 -1
View File
@@ -5,7 +5,7 @@ import { z } from 'zod'
import { getModel } from '@/lib/ai/model'
import { DEFAULT_COMPLETION_MODEL } from '@/lib/ai/model.utils'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
const titleSchema = z.object({
title: z
@@ -3,7 +3,7 @@ import type { NextApiRequest, NextApiResponse } from 'next'
import z from 'zod'
import { DASHBOARD_LOG_BUCKET } from '@/components/interfaces/Support/dashboard-logs'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { getUserClaims } from '@/lib/gotrue'
export const maxDuration = 120
@@ -2,7 +2,7 @@ import { NextApiRequest, NextApiResponse } from 'next'
import { fetchPost } from '@/data/fetchers'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -2,7 +2,7 @@ import { NextApiRequest, NextApiResponse } from 'next'
import { fetchPost } from '@/data/fetchers'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -2,7 +2,7 @@ import { NextApiRequest, NextApiResponse } from 'next'
import { fetchPost } from '@/data/fetchers'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -2,7 +2,7 @@ import { NextApiRequest, NextApiResponse } from 'next'
import { fetchPost } from '@/data/fetchers'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { selfHostedSupabaseAdmin as supabase } from '@/lib/api/self-hosted-admin'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { selfHostedSupabaseAdmin as supabase } from '@/lib/api/self-hosted-admin'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { selfHostedSupabaseAdmin as supabase } from '@/lib/api/self-hosted-admin'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,7 +1,7 @@
import { NextApiRequest, NextApiResponse } from 'next'
import type { DeploymentModeResponse } from '@/data/config/deployment-mode-query'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { IS_CLI } from '@/lib/constants'
export default function deploymentMode(req: NextApiRequest, res: NextApiResponse) {
@@ -1,7 +1,7 @@
import { paths } from 'api-types'
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,7 +1,7 @@
import { paths } from 'api-types'
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,7 +1,7 @@
import { paths } from 'api-types'
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,7 +1,7 @@
import { paths } from 'api-types'
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,7 +1,7 @@
import { paths } from 'api-types'
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -3,7 +3,7 @@ import { NextApiRequest, NextApiResponse } from 'next'
import { getPgMetaRedirectUrl } from './tables'
import { fetchGet } from '@/data/fetchers'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) =>
apiWrapper(req, res, handler, { withAuth: true })
@@ -2,7 +2,7 @@ import { NextApiRequest, NextApiResponse } from 'next'
import { fetchGet } from '@/data/fetchers'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { PG_META_URL } from '@/lib/constants'
export default (req: NextApiRequest, res: NextApiResponse) =>
@@ -3,7 +3,7 @@ import { NextApiRequest, NextApiResponse } from 'next'
import { getPgMetaRedirectUrl } from './tables'
import { fetchGet } from '@/data/fetchers'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) =>
apiWrapper(req, res, handler, { withAuth: true })
@@ -3,7 +3,7 @@ import { NextApiRequest, NextApiResponse } from 'next'
import { getPgMetaRedirectUrl } from './tables'
import { fetchGet } from '@/data/fetchers'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) =>
apiWrapper(req, res, handler, { withAuth: true })
@@ -2,7 +2,7 @@ import { NextApiRequest, NextApiResponse } from 'next'
import { fetchGet } from '@/data/fetchers'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { PG_META_URL } from '@/lib/constants'
export default (req: NextApiRequest, res: NextApiResponse) =>
@@ -2,7 +2,7 @@ import { NextApiRequest, NextApiResponse } from 'next'
import { fetchGet } from '@/data/fetchers'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { PG_META_URL } from '@/lib/constants'
export default (req: NextApiRequest, res: NextApiResponse) =>
@@ -1,7 +1,7 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { executeQuery } from '@/lib/api/self-hosted/query'
import { PgMetaDatabaseError } from '@/lib/api/self-hosted/types'
@@ -2,7 +2,7 @@ import { NextApiRequest, NextApiResponse } from 'next'
import { fetchGet } from '@/data/fetchers'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { PG_META_URL } from '@/lib/constants'
export default (req: NextApiRequest, res: NextApiResponse) =>
@@ -2,7 +2,7 @@ import { NextApiRequest, NextApiResponse } from 'next'
import { fetchGet } from '@/data/fetchers'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { PG_META_URL } from '@/lib/constants'
export default (req: NextApiRequest, res: NextApiResponse) =>
@@ -2,7 +2,7 @@ import { NextApiRequest, NextApiResponse } from 'next'
import { fetchGet } from '@/data/fetchers'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { PG_META_URL } from '@/lib/constants'
export default (req: NextApiRequest, res: NextApiResponse) =>
@@ -3,7 +3,7 @@ import { NextApiRequest, NextApiResponse } from 'next'
import { getPgMetaRedirectUrl } from './tables'
import { fetchGet } from '@/data/fetchers'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) =>
apiWrapper(req, res, handler, { withAuth: true })
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { DEFAULT_PROJECT } from '@/lib/constants/api'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,7 +1,7 @@
import assert from 'node:assert'
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { retrieveAnalyticsData } from '@/lib/api/self-hosted/logs'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { PROJECT_ANALYTICS_URL } from '@/lib/constants/api'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { PROJECT_ANALYTICS_URL } from '@/lib/constants/api'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,7 +1,7 @@
import { components } from 'api-types'
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
type ProjectAppConfig = components['schemas']['ProjectSettingsResponse']['app_config'] & {
protocol?: string
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,7 +1,7 @@
import { paths } from 'api-types'
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,7 +1,7 @@
import { components } from 'api-types'
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { DEFAULT_EXPOSED_SCHEMAS } from '@/lib/api/self-hosted/constants'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default function updateStatus(req: NextApiRequest, res: NextApiResponse) {
return apiWrapper(req, res, handler)
@@ -1,7 +1,7 @@
import { paths } from 'api-types'
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { getSnippets } from '@/lib/api/snippets.utils'
const wrappedHandler = (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,7 +1,7 @@
import { paths } from 'api-types'
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { getFolders, getSnippets } from '@/lib/api/snippets.utils'
const wrappedHandler = (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,7 +1,7 @@
import { paths } from 'api-types'
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { createFolder, deleteFolder, getFolders, getSnippets } from '@/lib/api/snippets.utils'
const wrappedHandler = (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -3,7 +3,7 @@ import { compact } from 'lodash'
import { NextApiRequest, NextApiResponse } from 'next'
import { z } from 'zod'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import {
deleteSnippet,
getSnippets,
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { getSnippet } from '@/lib/api/snippets.utils'
const wrappedHandler = (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,7 +1,7 @@
import { paths } from 'api-types'
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { POSTGRES_PORT } from '@/lib/api/self-hosted/constants'
import { PROJECT_DB_HOST, PROJECT_REST_URL } from '@/lib/constants/api'
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { DEFAULT_PROJECT, PROJECT_REST_URL } from '@/lib/constants/api'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,7 +1,7 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { DEFAULT_EXPOSED_SCHEMAS } from '@/lib/api/self-hosted/constants'
import { getLints } from '@/lib/api/self-hosted/lints'
@@ -1,7 +1,7 @@
import { components } from 'api-types'
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { getProjectSettings } from '@/lib/api/self-hosted/settings'
type ProjectAppConfig = components['schemas']['ProjectSettingsResponse']['app_config'] & {
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { DEFAULT_PROJECT } from '@/lib/constants/api'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { POSTGRES_PORT } from '@/lib/api/self-hosted/constants'
import {
DEFAULT_PROJECT,
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { DEFAULT_PROJECT } from '@/lib/constants/api'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { selfHostedSupabaseAdmin as supabase } from '@/lib/api/self-hosted-admin'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { selfHostedSupabaseAdmin as supabase } from '@/lib/api/self-hosted-admin'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { selfHostedSupabaseAdmin as supabase } from '@/lib/api/self-hosted-admin'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { selfHostedSupabaseAdmin as supabase } from '@/lib/api/self-hosted-admin'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { selfHostedSupabaseAdmin as supabase } from '@/lib/api/self-hosted-admin'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { selfHostedSupabaseAdmin as supabase } from '@/lib/api/self-hosted-admin'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { selfHostedSupabaseAdmin as supabase } from '@/lib/api/self-hosted-admin'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { selfHostedSupabaseAdmin as supabase } from '@/lib/api/self-hosted-admin'
const wrappedHandler = (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { selfHostedSupabaseAdmin as supabase } from '@/lib/api/self-hosted-admin'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { selfHostedSupabaseAdmin as supabase } from '@/lib/api/self-hosted-admin'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { selfHostedSupabaseAdmin as supabase } from '@/lib/api/self-hosted-admin'
// eslint-disable-next-line import/no-anonymous-default-export
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { selfHostedSupabaseAdmin as supabase } from '@/lib/api/self-hosted-admin'
// eslint-disable-next-line import/no-anonymous-default-export
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { selfHostedSupabaseAdmin as supabase } from '@/lib/api/self-hosted-admin'
// eslint-disable-next-line import/no-anonymous-default-export
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { selfHostedSupabaseAdmin as supabase } from '@/lib/api/self-hosted-admin'
// eslint-disable-next-line import/no-anonymous-default-export
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import {
applyRevealToApiKey,
getNonPlatformApiKeys,
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { getNonPlatformApiKeyById, parseRevealQuery } from '@/lib/api/self-hosted/api-keys'
const apiKeyByIdRoute = (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { getLegacySigningKey } from '@/lib/api/self-hosted/signing-keys'
export default function signingKeys(req: NextApiRequest, res: NextApiResponse) {
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { getLegacySigningKey } from '@/lib/api/self-hosted/signing-keys'
export default function legacySigningKey(req: NextApiRequest, res: NextApiResponse) {
@@ -1,7 +1,7 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { applyAndTrackMigrations, listMigrationVersions } from '@/lib/api/self-hosted/migrations'
import { PgMetaDatabaseError } from '@/lib/api/self-hosted/types'
@@ -2,7 +2,7 @@ import { createReadStream } from 'node:fs'
import { pipeline } from 'node:stream/promises'
import { type NextApiRequest, type NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { getFunctionsArtifactStore } from '@/lib/api/self-hosted/functions'
import { uuidv4 } from '@/lib/helpers'
@@ -1,7 +1,7 @@
import type { components } from 'api-types'
import { type NextApiRequest, type NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { getFunctionsArtifactStore } from '@/lib/api/self-hosted/functions'
import { uuidv4 } from '@/lib/helpers'
@@ -1,7 +1,7 @@
import type { components } from 'api-types'
import { type NextApiRequest, type NextApiResponse } from 'next'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { getFunctionsArtifactStore } from '@/lib/api/self-hosted/functions'
import { uuidv4 } from '@/lib/helpers'
@@ -1,7 +1,7 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { constructHeaders } from '@/lib/api/apiHelpers'
import apiWrapper from '@/lib/api/apiWrapper'
import { apiWrapper } from '@/lib/api/apiWrapper'
import { generateTypescriptTypes } from '@/lib/api/self-hosted/generate-types'
import { ResponseError } from '@/types'