@@ -102,6 +102,9 @@ const makeRelayTraceLayer = (input: {
102102 exportInterval : RELAY_OBSERVABILITY_EXPORT_INTERVAL ,
103103 } ) . pipe ( Layer . provide ( OtlpSerialization . layerJson ) , Layer . provide ( FetchHttpClient . layer ) ) ;
104104
105+ const apnsPrivateKeyConfig = Config . redacted ( "APNS_PRIVATE_KEY" ) ;
106+ const clerkSecretKeyConfig = Config . redacted ( "CLERK_SECRET_KEY" ) ;
107+
105108export default class Api extends Cloudflare . Worker < Api > ( ) (
106109 "Api" ,
107110 {
@@ -111,6 +114,10 @@ export default class Api extends Cloudflare.Worker<Api>()(
111114 flags : [ "nodejs_compat" ] ,
112115 } ,
113116 domain : RELAY_PUBLIC_DOMAIN ,
117+ env : {
118+ APNS_PRIVATE_KEY : apnsPrivateKeyConfig ,
119+ CLERK_SECRET_KEY : clerkSecretKeyConfig ,
120+ } ,
114121 } ,
115122 Effect . gen ( function * ( ) {
116123 const managedEndpointProvisionerToken = yield * Cloudflare . AccountApiToken (
@@ -136,7 +143,7 @@ export default class Api extends Cloudflare.Worker<Api>()(
136143 const apnsTeamId = yield * Config . string ( "APNS_TEAM_ID" ) ;
137144 const apnsKeyId = yield * Config . string ( "APNS_KEY_ID" ) ;
138145 const apnsBundleId = yield * Config . string ( "APNS_BUNDLE_ID" ) ;
139- const apnsPrivateKey = yield * Config . redacted ( "APNS_PRIVATE_KEY" ) ;
146+ const apnsPrivateKey = yield * apnsPrivateKeyConfig ;
140147 const relayObservability = yield * provisionRelayObservability ;
141148 const axiomIngestToken = yield * relayObservability . ingestToken . token ;
142149 const axiomTracesEndpoint = yield * relayObservability . traces . otelTracesEndpoint ;
@@ -154,7 +161,7 @@ export default class Api extends Cloudflare.Worker<Api>()(
154161 { bytes : 32 } ,
155162 ) ;
156163 const apnsDeliveryJobSigningSecret = yield * randomApnsDeliveryJobSigningSecret . text ;
157- const clerkSecretKey = yield * Config . redacted ( "CLERK_SECRET_KEY" ) ;
164+ const clerkSecretKey = yield * clerkSecretKeyConfig ;
158165 const cloudMintPrivateKey = yield * cloudMintKeyPair . privateKey ;
159166 const cloudMintPublicKey = yield * cloudMintKeyPair . publicKey ;
160167 const db = yield * Drizzle . postgres ( hyperdrive . connectionString ) ;
@@ -265,11 +272,14 @@ export default class Api extends Cloudflare.Worker<Api>()(
265272 Layer . provide ( [ Etag . layerWeak , RelayHttpPlatformLayer , relayCors ] ) ,
266273 HttpRouter . toHttpEffect ,
267274 ) ;
268- const tracer = yield * Effect . tracer ;
269- return { handler : traceRelayHttpRequest ( handler , tracer ) } ;
275+ return { handler } ;
270276 } ) ;
271- const getFetch = yield * Effect . cached ( buildFetch ( ) . pipe ( Effect . provide ( relayTraceLayer ) ) ) ;
272- const fetch = getFetch . pipe ( Effect . map ( ( { handler } ) => handler ) ) ;
277+ const getFetch = yield * Effect . cached ( buildFetch ( ) ) ;
278+ const fetch = getFetch . pipe (
279+ Effect . map ( ( { handler } ) =>
280+ traceRelayHttpRequest ( handler ) . pipe ( Effect . provide ( relayTraceLayer ) ) ,
281+ ) ,
282+ ) ;
273283
274284 return { fetch } ;
275285 } ) . pipe (
0 commit comments