mirror of
https://github.com/documenso/documenso.git
synced 2025-11-15 17:21:41 +10:00
fix: wip
This commit is contained in:
@ -2,12 +2,15 @@
|
||||
import { Hono } from 'hono';
|
||||
import { PDFDocument } from 'pdf-lib';
|
||||
|
||||
import { tsRestHonoApp } from '@documenso/api/hono';
|
||||
import { auth } from '@documenso/auth/server';
|
||||
import { API_V2_BETA_URL } from '@documenso/lib/constants/app';
|
||||
import { AppError } from '@documenso/lib/errors/app-error';
|
||||
import { jobsClient } from '@documenso/lib/jobs/client';
|
||||
import { createDocumentData } from '@documenso/lib/server-only/document-data/create-document-data';
|
||||
import { putFile } from '@documenso/lib/universal/upload/put-file';
|
||||
import { getPresignGetUrl } from '@documenso/lib/universal/upload/server-actions';
|
||||
import { openApiDocument } from '@documenso/trpc/server/open-api';
|
||||
|
||||
import { openApiTrpcServerHandler } from './trpc/hono-trpc-open-api';
|
||||
import { reactRouterTrpcServer } from './trpc/hono-trpc-remix';
|
||||
@ -18,11 +21,14 @@ const app = new Hono();
|
||||
app.route('/api/auth', auth);
|
||||
|
||||
// API servers. Todo: Configure max durations, etc?
|
||||
app.route('/api/v1', tsRestHonoApp);
|
||||
app.use('/api/jobs/*', jobsClient.getHonoApiHandler());
|
||||
app.use('/api/v1/*', reactRouterTrpcServer); // Todo: ts-rest
|
||||
app.use('/api/v2/*', async (c) => openApiTrpcServerHandler(c));
|
||||
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}/*`, async (c) => openApiTrpcServerHandler(c));
|
||||
|
||||
// Temp uploader.
|
||||
app
|
||||
.post('/api/file', async (c) => {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import type { Context } from 'hono';
|
||||
import { createOpenApiFetchHandler } from 'trpc-to-openapi';
|
||||
|
||||
import { API_V2_BETA_URL } from '@documenso/lib/constants/app';
|
||||
import { AppError, genericErrorCodeToTrpcErrorCodeMap } from '@documenso/lib/errors/app-error';
|
||||
import { appRouter } from '@documenso/trpc/server/router';
|
||||
import { handleTrpcRouterError } from '@documenso/trpc/utils/trpc-error-handler';
|
||||
@ -9,7 +10,7 @@ import { createHonoTrpcContext } from './trpc-context';
|
||||
|
||||
export const openApiTrpcServerHandler = async (c: Context) => {
|
||||
return createOpenApiFetchHandler<typeof appRouter>({
|
||||
endpoint: '/v2/api',
|
||||
endpoint: API_V2_BETA_URL,
|
||||
router: appRouter,
|
||||
// Todo: Test this, since it's not using the createContext params.
|
||||
createContext: async () => createHonoTrpcContext({ c, requestSource: 'apiV2' }),
|
||||
|
||||
@ -5,6 +5,7 @@ import { handleTrpcRouterError } from '@documenso/trpc/utils/trpc-error-handler'
|
||||
|
||||
import { createHonoTrpcContext } from './trpc-context';
|
||||
|
||||
// Todo
|
||||
// export const config = {
|
||||
// maxDuration: 120,
|
||||
// api: {
|
||||
|
||||
@ -4,7 +4,7 @@ import { redirect } from 'react-router';
|
||||
/**
|
||||
* Returns the session context or throws a redirect to signin if it is not present.
|
||||
*/
|
||||
export const getRequiredSessionContext = (context: AppLoadContext) => {
|
||||
export const getRequiredLoaderSession = (context: AppLoadContext) => {
|
||||
if (!context.session) {
|
||||
throw redirect('/signin'); // Todo: Maybe add a redirect cookie to come back?
|
||||
}
|
||||
@ -15,7 +15,7 @@ export const getRequiredSessionContext = (context: AppLoadContext) => {
|
||||
/**
|
||||
* Returns the team session context or throws a redirect to signin if it is not present.
|
||||
*/
|
||||
export const getRequiredTeamSessionContext = (context: AppLoadContext) => {
|
||||
export const getRequiredLoaderTeamSession = (context: AppLoadContext) => {
|
||||
if (!context.session) {
|
||||
throw redirect('/signin'); // Todo: Maybe add a redirect cookie to come back?
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user