66 AuthorizationClient ,
77 createMCPToolsStub ,
88 EMAIL_TOOLS ,
9- Entrypoint ,
109 getPresignedReadUrl_WITHOUT_CHECKING_AUTHORIZATION ,
1110 getWorkspaceBucketName ,
1211 GLOBAL_TOOLS ,
@@ -24,16 +23,15 @@ import { logger } from "hono/logger";
2423import { endTime , startTime } from "hono/timing" ;
2524import type { ContentfulStatusCode } from "hono/utils/http-status" ;
2625import { z } from "zod" ;
27- import { fetchScript } from "./apps.ts" ;
2826import { ROUTES as loginRoutes } from "./auth/index.ts" ;
2927import { withActorsStubMiddleware } from "./middlewares/actors-stub.ts" ;
3028import { withActorsMiddleware } from "./middlewares/actors.ts" ;
3129import { withContextMiddleware } from "./middlewares/context.ts" ;
3230import { setUserMiddleware } from "./middlewares/user.ts" ;
31+ import { handleCodeExchange } from "./oauth/code.ts" ;
3332import { type AppContext , type AppEnv , State } from "./utils/context.ts" ;
3433import { handleStripeWebhook } from "./webhooks/stripe.ts" ;
3534import { handleTrigger } from "./webhooks/trigger.ts" ;
36- import { handleCodeExchange } from "./oauth/code.ts" ;
3735
3836export const app = new Hono < AppEnv > ( ) ;
3937export const honoCtxToAppCtx = ( c : Context < AppEnv > ) : AppContext => {
@@ -332,51 +330,6 @@ app.get("/apps/oauth", (c) => {
332330// Health check endpoint
333331app . get ( "/health" , ( c : Context ) => c . json ( { status : "ok" } ) ) ;
334332
335- const DECO_WORKSPACE_HEADER = "x-deco-workspace" ;
336- const SENSITIVE_HEADERS = [ "Cookie" , "Authorization" ] ;
337- app . on ( [
338- "GET" ,
339- "POST" ,
340- "PUT" ,
341- "DELETE" ,
342- "PATCH" ,
343- "OPTIONS" ,
344- ] , [
345- "/:root/:slug/views/:script/:path{.+}?" ,
346- "/views/:script/:path{.+}?" ,
347- ] , ( c : Context ) => {
348- const script = c . req . param ( "script" ) ;
349- const path = c . req . param ( "path" ) ;
350- const root = c . req . param ( "root" ) ;
351- const slug = c . req . param ( "slug" ) ;
352- const workspace = root && slug
353- ? `/${ root } /${ slug } `
354- : c . req . header ( DECO_WORKSPACE_HEADER ) ;
355-
356- const url = new URL ( c . req . raw . url ) ;
357- url . protocol = "https:" ;
358- url . port = "443" ;
359- url . host = Entrypoint . host ( script ) ;
360- url . pathname = `/${ path || "" } ` ;
361-
362- const headers = new Headers ( c . req . header ( ) ) ;
363- SENSITIVE_HEADERS . forEach ( ( header ) => {
364- headers . delete ( header ) ;
365- } ) ;
366-
367- workspace && headers . set ( DECO_WORKSPACE_HEADER , workspace ) ;
368- return fetchScript (
369- c ,
370- script ,
371- new Request ( url , {
372- redirect : c . req . raw . redirect ,
373- body : c . req . raw . body ,
374- method : c . req . raw . method ,
375- headers,
376- } ) ,
377- ) ;
378- } ) ;
379-
380333app . onError ( ( err , c ) => {
381334 console . error ( err ) ;
382335
0 commit comments