From ca10286e1f5aa7b827e90e1d771830cb5a6a981a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Thu, 5 Sep 2024 01:58:24 +0200 Subject: [PATCH] Config fixes --- src/Layers/OpenAIClient.ts | 10 +++++----- src/Layers/express/ExpressApp.ts | 4 ++-- src/Layers/express/ExpressNodeHTTPServer.ts | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Layers/OpenAIClient.ts b/src/Layers/OpenAIClient.ts index cfab980..5e07d87 100644 --- a/src/Layers/OpenAIClient.ts +++ b/src/Layers/OpenAIClient.ts @@ -53,11 +53,11 @@ export const OpenAIClientLive = ( new openai.OpenAI({ apiKey: yield* config.apiKey, - organization: (yield* config.organization || Config.succeed(undefined)) || null, - project: (yield* config.project || Config.succeed(undefined)) || null, - baseURL: (yield* config.baseURL || Config.succeed(undefined)) || "https://api.openai.com/v1", - timeout: yield* config.timeout || Config.succeed(undefined), - maxRetries: yield* config.maxRetries || Config.succeed(undefined), + organization: (yield* config.organization ?? Config.succeed(undefined)) ?? null, + project: (yield* config.project ?? Config.succeed(undefined)) ?? null, + baseURL: (yield* config.baseURL ?? Config.succeed(undefined)) ?? "https://api.openai.com/v1", + timeout: yield* config.timeout ?? Config.succeed(undefined), + maxRetries: yield* config.maxRetries ?? Config.succeed(undefined), httpAgent: config.httpAgent, fetch: config.fetch, diff --git a/src/Layers/express/ExpressApp.ts b/src/Layers/express/ExpressApp.ts index 4548211..8bf7bef 100644 --- a/src/Layers/express/ExpressApp.ts +++ b/src/Layers/express/ExpressApp.ts @@ -12,10 +12,10 @@ const importExpress = Effect.tryPromise({ export const ExpressAppLive = ( config: { - readonly trustProxy?: Config.Config + readonly trustProxy?: Config.Config } = {} ) => Layer.effect(ExpressApp, Effect.gen(function*() { const app = (yield* importExpress).default() - app.set("trust proxy", yield* config.trustProxy || Config.succeed(false)) + app.set("trust proxy", (yield* config.trustProxy ?? Config.succeed(undefined)) ?? false) return app })) diff --git a/src/Layers/express/ExpressNodeHTTPServer.ts b/src/Layers/express/ExpressNodeHTTPServer.ts index 73bc0e7..a28eaf9 100644 --- a/src/Layers/express/ExpressNodeHTTPServer.ts +++ b/src/Layers/express/ExpressNodeHTTPServer.ts @@ -36,15 +36,15 @@ export const ExpressNodeHTTPServerLive = ( const http = yield* importNodeHTTP const options = { - backlog: yield* config.backlog || Config.succeed(undefined), - exclusive: yield* config.exclusive || Config.succeed(undefined), - host: yield* config.host || Config.succeed(undefined), - ipv6Only: yield* config.ipv6Only || Config.succeed(undefined), - path: yield* config.path || Config.succeed(undefined), - port: yield* config.port || Config.succeed(undefined), - readableAll: yield* config.readableAll || Config.succeed(undefined), + backlog: yield* config.backlog ?? Config.succeed(undefined), + exclusive: yield* config.exclusive ?? Config.succeed(undefined), + host: yield* config.host ?? Config.succeed(undefined), + ipv6Only: yield* config.ipv6Only ?? Config.succeed(undefined), + path: yield* config.path ?? Config.succeed(undefined), + port: yield* config.port ?? Config.succeed(undefined), + readableAll: yield* config.readableAll ?? Config.succeed(undefined), signal: config.signal, - writableAll: yield* config.writableAll || Config.succeed(undefined), + writableAll: yield* config.writableAll ?? Config.succeed(undefined), } as const return yield* Effect.async(resume => {