This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Effect, Function } from "effect"; | |
import { Pipeable, pipeArguments } from "effect/Pipeable"; | |
import { Predicate, Refinement } from "effect/Predicate"; | |
import { Profil, UnAuthorized } from "../Profil"; | |
import { UserSessionService } from "../UserSession/UserSessionServiceTag"; | |
export interface Policy<A, E = never, R = never> extends Pipeable { | |
run: (a: A) => Effect.Effect<boolean, E, R>; | |
readonly _tag: "Policy"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"dev": "dotenv -e config/.env.development -- tsx --watch ./index.ts", | |
"build": "esbuild ./index.ts --bundle --platform=node --target=node22 --outfile=dist/index.cjs --format=cjs && cp ./node_modules/@repo/prisma/node_modules/prisma/libquery* ./", | |
"start": "dotenv -e config/.env.production -- node ./dist/index.cjs", | |
"staging": "dotenv -e config/.env.staging -- node ./dist/index.cjs" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:22-alpine as base | |
# Install pnpm with corepack | |
RUN corepack enable && corepack prepare pnpm@latest --activate | |
# Enable `pnpm add --global` on Alpine Linux by setting | |
# home location environment variable to a location already in $PATH | |
# https://github.com/pnpm/pnpm/issues/784#issuecomment-1518582235 | |
ENV PNPM_HOME=/usr/local/bin | |
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
FetchHttpClient, | |
HttpRouter, | |
HttpServer, | |
HttpServerResponse, | |
} from "@effect/platform"; | |
import { BunHttpServer, BunRuntime } from "@effect/platform-bun"; | |
import { | |
Rpc, | |
RpcClient, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Free<F, A> = Pure<A> | FreeF<F, A>; | |
export class Pure<A> { | |
readonly _tag = "Pure" as const; | |
constructor(public readonly value: A) {} | |
} | |
export class FreeF<F, A> { | |
readonly _tag = "FreeF" as const; | |
constructor( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"egen": { | |
"prefix": "egen", | |
"body": [ | |
"Effect.gen(function* () {", | |
" $0", | |
"})" | |
], | |
"description": "Effect.gen" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NodeRuntime } from '@effect/platform-node' | |
import { Database } from '@repo/shared/Database' | |
import { SqsService } from '@repo/shared/SqsService' | |
import { Config, Effect, Layer, LogLevel, Logger } from 'effect' | |
import { withMinimumLogLevel } from 'effect/Logger' | |
import * as DemoMessageConsumer from './Features/Demo/DemoMessageConsumer' | |
const consumers = [DemoMessageConsumer.consumer] | |
const dependencies = Layer.mergeAll( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Schema } from '@effect/schema' | |
import { SqsService, type QueueMessage } from '@repo/shared/SqsService' | |
import { Duration, Effect, Schedule } from 'effect' | |
const defaultAwsRetryPolicy = Schedule.intersect( | |
Schedule.exponential(Duration.seconds(1)), | |
Schedule.recurs(5), | |
) | |
export const makeConsumer = <A, I, E, R>({ | |
queueName, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
CreateQueueCommand, | |
DeleteMessageCommand, | |
ReceiveMessageCommand, | |
SendMessageCommand, | |
type CreateQueueCommandInput, | |
} from '@aws-sdk/client-sqs' | |
import { Schema } from '@effect/schema' | |
import { | |
Array, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { SQSClient } from '@aws-sdk/client-sqs' | |
import { Config, Context, Effect, Layer } from 'effect' | |
const makeSqsClient = Effect.gen(function* () { | |
const awsAccessKeyId = yield* Config.string('AWS_ACCESS_KEY_ID').pipe( | |
Config.withDescription('AWS Access Key ID'), | |
) | |
const awsSecretAccessKey = yield* Config.string('AWS_SECRET_ACCESS_KEY').pipe( | |
Config.withDescription('AWS Secret'), | |
) |
NewerOlder