Skip to content

Commit

Permalink
Redact a secret
Browse files Browse the repository at this point in the history
Refs #1834
  • Loading branch information
thewilkybarkid committed Dec 20, 2024
1 parent 6761918 commit 407c6ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pipe(
),
),
Effect.provideServiceEffect(GhostApi, Config.all({ key: Config.string('GHOST_API_KEY') })),
Effect.provide(Nodemailer.layerConfig(Config.url('SMTP_URI'))),
Effect.provide(Nodemailer.layerConfig(Config.redacted(Config.url('SMTP_URI')))),
Effect.provide(Redis.layerConfig(Config.redacted(Config.url('REDIS_URI')))),
Effect.provideServiceEffect(
FetchHttpClient.Fetch,
Expand Down
8 changes: 5 additions & 3 deletions src/nodemailer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Config, Context, Effect, Layer } from 'effect'
import { Config, Context, Effect, Layer, Redacted } from 'effect'
import { toError } from 'fp-ts/lib/Either.js'
import * as RTE from 'fp-ts/lib/ReaderTaskEither.js'
import * as TE from 'fp-ts/lib/TaskEither.js'
Expand All @@ -14,8 +14,10 @@ export interface NodemailerEnv {

export class Nodemailer extends Context.Tag('Nodemailer')<Nodemailer, Transporter<unknown>>() {}

export const make = (options: URL | Transporter<unknown>): Effect.Effect<Transporter<unknown>> =>
options instanceof URL ? Effect.sync(() => createTransport(options.href)) : Effect.succeed(options)
export const make = (options: Redacted.Redacted<URL> | Transporter<unknown>): Effect.Effect<Transporter<unknown>> =>
Redacted.isRedacted(options)
? Effect.sync(() => createTransport(Redacted.value(options).href))
: Effect.succeed(options)

export const layer: (options: Parameters<typeof make>[0]) => Layer.Layer<Nodemailer> = flow(
make,
Expand Down

0 comments on commit 407c6ff

Please sign in to comment.