mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
fix: redirect v2 beta url
This commit is contained in:
@ -8,7 +8,7 @@ import type { Logger } from 'pino';
|
||||
|
||||
import { tsRestHonoApp } from '@documenso/api/hono';
|
||||
import { auth } from '@documenso/auth/server';
|
||||
import { API_V2_BETA_URL } from '@documenso/lib/constants/app';
|
||||
import { API_V2_BETA_URL, API_V2_URL } from '@documenso/lib/constants/app';
|
||||
import { jobsClient } from '@documenso/lib/jobs/client';
|
||||
import { getIpAddress } from '@documenso/lib/universal/get-ip-address';
|
||||
import { logger } from '@documenso/lib/utils/logger';
|
||||
@ -90,8 +90,14 @@ app.use('/api/jobs/*', jobsClient.getApiHandler());
|
||||
app.use('/api/trpc/*', reactRouterTrpcServer);
|
||||
|
||||
// Unstable API server routes. Order matters for these two.
|
||||
app.get(`${API_V2_BETA_URL}/openapi.json`, (c) => c.json(openApiDocument));
|
||||
app.use(`${API_V2_BETA_URL}/*`, cors());
|
||||
app.use(`${API_V2_BETA_URL}/*`, async (c) => openApiTrpcServerHandler(c));
|
||||
app.get(`${API_V2_URL}/openapi.json`, (c) => c.json(openApiDocument));
|
||||
app.use(`${API_V2_URL}/*`, cors());
|
||||
app.use(`${API_V2_URL}/*`, async (c) => openApiTrpcServerHandler(c));
|
||||
|
||||
// Redirect /api/v2-beta to /api/v2.
|
||||
app.all('/api/v2-beta/*', (c) => {
|
||||
const newPath = c.req.path.replace(API_V2_BETA_URL, API_V2_URL);
|
||||
return c.redirect(newPath, 301);
|
||||
});
|
||||
|
||||
export default app;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import type { Context } from 'hono';
|
||||
|
||||
import { API_V2_BETA_URL } from '@documenso/lib/constants/app';
|
||||
import { API_V2_URL } from '@documenso/lib/constants/app';
|
||||
import { AppError, genericErrorCodeToTrpcErrorCodeMap } from '@documenso/lib/errors/app-error';
|
||||
import { createTrpcContext } from '@documenso/trpc/server/context';
|
||||
import { appRouter } from '@documenso/trpc/server/router';
|
||||
@ -9,7 +9,7 @@ import { handleTrpcRouterError } from '@documenso/trpc/utils/trpc-error-handler'
|
||||
|
||||
export const openApiTrpcServerHandler = async (c: Context) => {
|
||||
return createOpenApiFetchHandler<typeof appRouter>({
|
||||
endpoint: API_V2_BETA_URL,
|
||||
endpoint: API_V2_URL,
|
||||
router: appRouter,
|
||||
createContext: async () => createTrpcContext({ c, requestSource: 'apiV2' }),
|
||||
req: c.req.raw,
|
||||
|
||||
@ -12,6 +12,7 @@ export const NEXT_PRIVATE_INTERNAL_WEBAPP_URL =
|
||||
export const IS_BILLING_ENABLED = () => env('NEXT_PUBLIC_FEATURE_BILLING_ENABLED') === 'true';
|
||||
|
||||
export const API_V2_BETA_URL = '/api/v2-beta';
|
||||
export const API_V2_URL = '/api/v2';
|
||||
|
||||
export const SUPPORT_EMAIL = env('NEXT_PUBLIC_SUPPORT_EMAIL') ?? 'support@documenso.com';
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ export const createAttachmentRoute = authenticatedProcedure
|
||||
path: '/envelope/attachment/create',
|
||||
summary: 'Create attachment',
|
||||
description: 'Create a new attachment for an envelope',
|
||||
tags: ['Envelope Attachment'],
|
||||
tags: ['Envelope Attachments'],
|
||||
},
|
||||
})
|
||||
.input(ZCreateAttachmentRequestSchema)
|
||||
|
||||
@ -13,7 +13,7 @@ export const deleteAttachmentRoute = authenticatedProcedure
|
||||
path: '/envelope/attachment/delete',
|
||||
summary: 'Delete attachment',
|
||||
description: 'Delete an attachment from an envelope',
|
||||
tags: ['Envelope Attachment'],
|
||||
tags: ['Envelope Attachments'],
|
||||
},
|
||||
})
|
||||
.input(ZDeleteAttachmentRequestSchema)
|
||||
|
||||
@ -15,7 +15,7 @@ export const findAttachmentsRoute = maybeAuthenticatedProcedure
|
||||
path: '/envelope/attachment',
|
||||
summary: 'Find attachments',
|
||||
description: 'Find all attachments for an envelope',
|
||||
tags: ['Envelope Attachment'],
|
||||
tags: ['Envelope Attachments'],
|
||||
},
|
||||
})
|
||||
.input(ZFindAttachmentsRequestSchema)
|
||||
|
||||
@ -13,7 +13,7 @@ export const updateAttachmentRoute = authenticatedProcedure
|
||||
path: '/envelope/attachment/update',
|
||||
summary: 'Update attachment',
|
||||
description: 'Update an existing attachment',
|
||||
tags: ['Envelope Attachment'],
|
||||
tags: ['Envelope Attachments'],
|
||||
},
|
||||
})
|
||||
.input(ZUpdateAttachmentRequestSchema)
|
||||
|
||||
@ -20,7 +20,7 @@ export const createEnvelopeItemsRoute = authenticatedProcedure
|
||||
path: '/envelope/item/create-many',
|
||||
summary: 'Create envelope items',
|
||||
description: 'Create multiple envelope items for an envelope',
|
||||
tags: ['Envelope Item'],
|
||||
tags: ['Envelope Items'],
|
||||
},
|
||||
})
|
||||
.input(ZCreateEnvelopeItemsRequestSchema)
|
||||
|
||||
@ -18,7 +18,7 @@ export const deleteEnvelopeItemRoute = authenticatedProcedure
|
||||
path: '/envelope/item/delete',
|
||||
summary: 'Delete envelope item',
|
||||
description: 'Delete an envelope item from an envelope',
|
||||
tags: ['Envelope Item'],
|
||||
tags: ['Envelope Items'],
|
||||
},
|
||||
})
|
||||
.input(ZDeleteEnvelopeItemRequestSchema)
|
||||
|
||||
@ -20,7 +20,7 @@ export const deleteEnvelopeFieldRoute = authenticatedProcedure
|
||||
path: '/envelope/field/delete',
|
||||
summary: 'Delete envelope field',
|
||||
description: 'Delete an envelope field',
|
||||
tags: ['Envelope Field'],
|
||||
tags: ['Envelope Fields'],
|
||||
},
|
||||
})
|
||||
.input(ZDeleteEnvelopeFieldRequestSchema)
|
||||
|
||||
@ -13,7 +13,7 @@ export const getEnvelopeFieldRoute = authenticatedProcedure
|
||||
path: '/envelope/field/{fieldId}',
|
||||
summary: 'Get envelope field',
|
||||
description: 'Returns an envelope field given an ID',
|
||||
tags: ['Envelope Field'],
|
||||
tags: ['Envelope Fields'],
|
||||
},
|
||||
})
|
||||
.input(ZGetEnvelopeFieldRequestSchema)
|
||||
|
||||
@ -13,7 +13,7 @@ export const updateEnvelopeFieldsRoute = authenticatedProcedure
|
||||
path: '/envelope/field/update-many',
|
||||
summary: 'Update envelope fields',
|
||||
description: 'Update multiple envelope fields for an envelope',
|
||||
tags: ['Envelope Field'],
|
||||
tags: ['Envelope Fields'],
|
||||
},
|
||||
})
|
||||
.input(ZUpdateEnvelopeFieldsRequestSchema)
|
||||
|
||||
@ -13,7 +13,7 @@ export const deleteEnvelopeRecipientRoute = authenticatedProcedure
|
||||
path: '/envelope/recipient/delete',
|
||||
summary: 'Delete envelope recipient',
|
||||
description: 'Delete an envelope recipient',
|
||||
tags: ['Envelope Recipient'],
|
||||
tags: ['Envelope Recipients'],
|
||||
},
|
||||
})
|
||||
.input(ZDeleteEnvelopeRecipientRequestSchema)
|
||||
|
||||
@ -15,7 +15,7 @@ export const getEnvelopeRecipientRoute = authenticatedProcedure
|
||||
path: '/envelope/recipient/{recipientId}',
|
||||
summary: 'Get envelope recipient',
|
||||
description: 'Returns an envelope recipient given an ID',
|
||||
tags: ['Envelope Recipient'],
|
||||
tags: ['Envelope Recipients'],
|
||||
},
|
||||
})
|
||||
.input(ZGetEnvelopeRecipientRequestSchema)
|
||||
|
||||
@ -13,7 +13,7 @@ export const updateEnvelopeRecipientsRoute = authenticatedProcedure
|
||||
path: '/envelope/recipient/update-many',
|
||||
summary: 'Update envelope recipients',
|
||||
description: 'Update multiple recipients for an envelope',
|
||||
tags: ['Envelope Recipient'],
|
||||
tags: ['Envelope Recipients'],
|
||||
},
|
||||
})
|
||||
.input(ZUpdateEnvelopeRecipientsRequestSchema)
|
||||
|
||||
@ -16,7 +16,7 @@ export const updateEnvelopeItemsRoute = authenticatedProcedure
|
||||
path: '/envelope/item/update-many',
|
||||
summary: 'Update envelope items',
|
||||
description: 'Update multiple envelope items for an envelope',
|
||||
tags: ['Envelope Item'],
|
||||
tags: ['Envelope Items'],
|
||||
},
|
||||
})
|
||||
.input(ZUpdateEnvelopeItemsRequestSchema)
|
||||
|
||||
@ -6,10 +6,11 @@ import { appRouter } from './router';
|
||||
|
||||
export const openApiDocument = {
|
||||
...generateOpenApiDocument(appRouter, {
|
||||
title: 'Documenso v2 beta API',
|
||||
description: 'Subject to breaking changes until v2 is fully released.',
|
||||
version: '0.0.0',
|
||||
baseUrl: `${NEXT_PUBLIC_WEBAPP_URL()}/api/v2-beta`,
|
||||
title: 'Documenso v2 API',
|
||||
description:
|
||||
'Welcome to the Documenso v2 API.\n\nThis API provides access to our system, which you can use to integrate applications, automate workflows, or build custom tools.',
|
||||
version: '1.0.0',
|
||||
baseUrl: `${NEXT_PUBLIC_WEBAPP_URL()}/api/v2`,
|
||||
securitySchemes: {
|
||||
apiKey: {
|
||||
type: 'apiKey',
|
||||
|
||||
Reference in New Issue
Block a user