Nano Banana Pro
Agent skill for nano-banana-pro
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Sign in to like and favorite skills
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
universal-rest is a Scala library for rapidly building CRUD REST APIs with http4s. It provides a composable architecture with tagless final patterns, supporting both open (unauthenticated) and authenticated endpoints.
sbt compile # Compile the project sbt test # Run all tests sbt "testOnly *UniversalServiceSpec" # Run a single test class sbt run # Run the example server (port 8080) sbt scalafmtAll # Format all Scala files sbt "scalafixAll" # Run scalafix linting/refactoring sbt publish # Publish to GitHub Packages
The library follows a layered architecture with clear separation of concerns:
CrudEndpoint (HTTP routing) ↓ CrudService (business logic) ↓ CrudRepository (data access)
Repository Layer (
CrudRepository[F, K, T, Error, SessionType])
F, key type K, entity type T, error type, session/context typeEitherT[F, Error, T] for all operations enabling functional error handlingcollection(isCount: Boolean) returns DataResult[T] (either ItrResult or CountResult)Service Layer (
CrudService, UniversalService)
UniversalService is a pass-through implementation delegating to repositoryMonad[F] and SessionTypeEndpoint Layer
open.UniversalEndpoint - unauthenticated routes using HttpRoutes[F]auth.AuthUniversalEndpoint - authenticated routes using http4s AuthMiddlewareCrudEndpoint trait providing: create, get, list, update, delete, countRouteBuilder - Convenience wrapper combining endpoint creation with CORS policy
Throughout the codebase:
F[_] - Effect type (typically IO)K - Entity key/ID typeT - Entity typeError - Application error type (sealed trait recommended)SessionType/Context - Request context (user session, auth info)ParamName/ParamValue - Request parameter typesImplement
ErrorHandler[F, E] trait to map domain errors to HTTP responses:
trait ErrorHandler[F[_], E] { def handle(e: E)(implicit m: Monad[F]): F[Response[F]] }
The
auth package provides:
AuthEndpoint[F, Context] type alias for authenticated partial functionsasAuthed extractor for pattern matching in route definitionsAuthMiddleware for authentication-Xfatal-warnings enabled - all warnings are errors