Skip to content

Instantly share code, notes, and snippets.

View titouancreach's full-sized avatar

Titouan CREACH titouancreach

  • Lorient, France
  • 10:15 (UTC +02:00)
View GitHub Profile
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";
}
"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"
},
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
import {
FetchHttpClient,
HttpRouter,
HttpServer,
HttpServerResponse,
} from "@effect/platform";
import { BunHttpServer, BunRuntime } from "@effect/platform-bun";
import {
Rpc,
RpcClient,
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(
{
"egen": {
"prefix": "egen",
"body": [
"Effect.gen(function* () {",
" $0",
"})"
],
"description": "Effect.gen"
},
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(
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,
import {
CreateQueueCommand,
DeleteMessageCommand,
ReceiveMessageCommand,
SendMessageCommand,
type CreateQueueCommandInput,
} from '@aws-sdk/client-sqs'
import { Schema } from '@effect/schema'
import {
Array,
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'),
)