npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aletso/effect-route

v0.1.4

Published

Effect-native RPC route contract definitions

Readme

@aletso/effect-route

Typed route contracts for Effect RPC.

Use this package to define payload, success, and error schemas once, group routes with a prefix, and expose a typed RpcGroup for server wiring.

Install

pnpm add @aletso/effect-route @effect/rpc effect

Define routes with schemas and middleware

Example domain contract setup.

import * as Route from "@aletso/effect-route/Route";
import * as RouteGroup from "@aletso/effect-route/RouteGroup";
import * as Schema from "effect/Schema";
import { AuthMiddleware } from "../Policy";

export const SurveyListItem = Schema.Struct({
  id: Schema.String,
  title: Schema.String,
});

export const SurveyPublished = Schema.Struct({
  id: Schema.String,
  title: Schema.String,
  status: Schema.Literal("published"),
});

export class SurveyNotFound extends Schema.TaggedError<SurveyNotFound>()(
  "SurveyNotFound",
  {
    id: Schema.String,
  },
) {}

export class Group extends RouteGroup.make(
  Route.make("find_many", {
    success: Schema.Array(SurveyListItem),
  }).middleware(AuthMiddleware),

  Route.make("find_by_id", {
    success: SurveyListItem,
    error: SurveyNotFound,
    payload: Schema.Struct({ id: Schema.String }),
  }).middleware(AuthMiddleware),

  Route.make("publish", {
    success: SurveyPublished,
    error: SurveyNotFound,
    payload: Schema.Struct({ id: Schema.String }),
  }).middleware(AuthMiddleware),
).prefix("survey_") {}

After prefixing:

  • Group.find_by_id._tag is survey_find_by_id
  • Group.find_by_id.key is @aletso/effect-route/Route/survey_find_by_id

Merge route groups into one RPC domain

Example domain-level RpcGroup merge.

import * as RpcGroup from "@effect/rpc/RpcGroup";
import * as Health from "./api/Health";
import * as Identity from "./api/Identity";
import * as Survey from "./api/Survey";

export class DomainRpc extends RpcGroup.make().merge(
  Health.Group.RpcGroup,
  Identity.Group.RpcGroup,
  Survey.Group.RpcGroup,
) {}

Bind handlers on the server

RouteGroup.RpcGroup gives a ready to use Effect RPC group.

import { Group as SurveyRoutes } from "../domain/api/Survey";
import { SurveyService } from "../server/public/survey/service";
import * as Effect from "effect/Effect";

export const SurveyRpcLive = SurveyRoutes.RpcGroup.toLayer({
  survey_find_many: () => Effect.flatMap(SurveyService, (s) => s.findMany),
  survey_find_by_id: ({ id }) =>
    Effect.flatMap(SurveyService, (s) => s.findById(id)),
  survey_publish: ({ id }) =>
    Effect.flatMap(SurveyService, (s) => s.publish(id)),
});

Use the same contracts in the data layer

These contracts are designed to be consumed by @aletso/atom-query.

import * as Query from "@aletso/atom-query/Query";
import { Group as SurveyRoutes } from "../domain/api/Survey";

export const surveyFindById = Query.familyFromRoute(SurveyRoutes.find_by_id, {
  effect: ({ id }) => api.findById(id),
  runtime,
});

API surface

  • Route.make(...)
  • route.middleware(...)
  • route.prefix(...)
  • RouteGroup.make(...)
  • routeGroup.prefix(...)
  • routeGroup.merge(...)
  • routeGroup.middleware(...)
  • routeGroup.RpcGroup