const posthogConfig = PosthogConfig.of({
apiKey: env.NEXT_PUBLIC_POSTHOG_API_KEY,
hostUrl: env.NEXT_PUBLIC_POSTHOG_API_ENDPOINT,
distinctId: 'abc-d123' // <- I NEED THIS FROM THE BELOW LAYER
})
export const ApiAuthenticationLive = Layer.effect(
ApiAuthentication,
Effect.gen(function* () {
const authorization = yield* Authorization
return ApiAuthentication.of({
bearer: (token) => authorization.assertApiKey(token).pipe(
Effect.mapError((error) => new Unauthorized({
success: false,
message: error.message,
reason: "invalid-api-key",
}))
)
})
}),
).pipe(
Layer.provide(Authorization.Default),
)
const posthogConfig = PosthogConfig.of({
apiKey: env.NEXT_PUBLIC_POSTHOG_API_KEY,
hostUrl: env.NEXT_PUBLIC_POSTHOG_API_ENDPOINT,
distinctId: 'abc-d123' // <- I NEED THIS FROM THE BELOW LAYER
})
export const ApiAuthenticationLive = Layer.effect(
ApiAuthentication,
Effect.gen(function* () {
const authorization = yield* Authorization
return ApiAuthentication.of({
bearer: (token) => authorization.assertApiKey(token).pipe(
Effect.mapError((error) => new Unauthorized({
success: false,
message: error.message,
reason: "invalid-api-key",
}))
)
})
}),
).pipe(
Layer.provide(Authorization.Default),
)