fp-backend

Featured

Functional programming patterns for Node.js/Deno backend development using fp-ts, ReaderTaskEither, and functional dependency injection

AI & Automation 39,350 stars 6386 forks Updated today MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# fp-ts Backend Patterns Functional programming patterns for building type-safe, testable backend services using fp-ts. ## When to Use - You are building or refactoring a Node.js or Deno backend with fp-ts. - The task involves dependency injection, service composition, or typed backend errors with `ReaderTaskEither`. - You need functional backend architecture patterns rather than isolated utility snippets. ## Core Concepts ### ReaderTaskEither (RTE) The `ReaderTaskEither<R, E, A>` type is the backbone of functional backend development: - **R** (Reader): Dependencies/environment (database, config, logger) - **E** (Either left): Error type - **A** (Either right): Success value ```typescript import * as RTE from 'fp-ts/ReaderTaskEither' import * as TE from 'fp-ts/TaskEither' import { pipe } from 'fp-ts/function' // Define your dependencies type Deps = { db: DatabaseClient logger: Logger config: Config } // Define domain errors type AppError = | { _tag: 'NotFound'; resource: string; id: string } | { _tag: 'ValidationError'; message: string } | { _tag: 'DatabaseError'; cause: unknown } | { _tag: 'Unauthorized'; reason: string } // A service function const getUser = (id: string): RTE.ReaderTaskEither<Deps, AppError, User> => pipe( RTE.ask<Deps>(), RTE.flatMap(({ db, logger }) => pipe( RTE.fromTaskEither(db.users.findById(id)), RTE.mapLeft((e): AppError => ({ _tag: 'DatabaseError', cause: e })), RTE.flatMap(user => ...

Details

Author
sickn33
Repository
sickn33/antigravity-awesome-skills
Created
4 months ago
Last Updated
today
Language
Python
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category