Skip to content

Http api poc#952

Draft
gcanti wants to merge 2 commits intomainfrom
http-api-poc
Draft

Http api poc#952
gcanti wants to merge 2 commits intomainfrom
http-api-poc

Conversation

@gcanti
Copy link
Contributor

@gcanti gcanti commented Jan 16, 2026

This POC shows that applying toCodecStringTree to the path of an endpoint could allow users to describe the path without worrying about defining explicit transformations. In the example below, the user can simply state that they want an integer, and under the hood we take care of correctly deserializing it from a string:

import { NodeHttpServer, NodeRuntime } from "@effect/platform-node"
import { Effect, Layer, Schema } from "effect"
import { HttpRouter } from "effect/unstable/http"
import { HttpApi, HttpApiBuilder, HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi"
import { createServer } from "node:http"

const getUser = HttpApiEndpoint.get("getUser", "/user/:id", {
  path: {
    id: Schema.Int // The user only needs to express their intent here
  },
  success: Schema.String
})

const Api = HttpApi.make("MyApi").add(
  HttpApiGroup.make("Users").add(
    getUser
  )
)

const GroupLive = HttpApiBuilder.group(
  Api,
  "Users",
  (handlers) =>
    handlers.handle("getUser", ({ path: { id } }) =>
      Effect.succeed(`User ${id}`)
    )
)

const ApiLive = HttpApiBuilder.layer(Api).pipe(
  Layer.provide(GroupLive),
  HttpRouter.serve,
  Layer.provide(NodeHttpServer.layer(createServer, { port: 3000 }))
)

Layer.launch(ApiLive).pipe(NodeRuntime.runMain)

@github-actions
Copy link
Contributor

Bundle Size Analysis

File Name Current Size Previous Size Difference
bundle/basic.ts 6.23 KB 6.23 KB 0.00 KB (0.00%)
bundle/batching.ts 8.48 KB 8.48 KB 0.00 KB (0.00%)
bundle/brand.ts 6.25 KB 6.25 KB 0.00 KB (0.00%)
bundle/cache.ts 9.54 KB 9.54 KB 0.00 KB (0.00%)
bundle/config.ts 16.05 KB 16.05 KB 0.00 KB (0.00%)
bundle/differ.ts 14.28 KB 14.28 KB 0.00 KB (0.00%)
bundle/http-client.ts 18.73 KB 18.73 KB 0.00 KB (0.00%)
bundle/logger.ts 8.82 KB 8.82 KB 0.00 KB (0.00%)
bundle/metric.ts 8.70 KB 8.70 KB 0.00 KB (0.00%)
bundle/optic.ts 7.48 KB 7.48 KB 0.00 KB (0.00%)
bundle/pubsub.ts 13.05 KB 13.05 KB 0.00 KB (0.00%)
bundle/queue.ts 10.92 KB 10.92 KB 0.00 KB (0.00%)
bundle/schedule.ts 9.65 KB 9.65 KB 0.00 KB (0.00%)
bundle/schema-representation-roundtrip.ts 23.77 KB 23.77 KB 0.00 KB (0.00%)
bundle/schema-string-transformation.ts 11.22 KB 11.22 KB 0.00 KB (0.00%)
bundle/schema-string.ts 9.54 KB 9.54 KB 0.00 KB (0.00%)
bundle/schema-template-literal.ts 12.04 KB 12.04 KB 0.00 KB (0.00%)
bundle/schema-toArbitraryLazy.ts 16.27 KB 16.27 KB 0.00 KB (0.00%)
bundle/schema-toCodeDocument.ts 19.15 KB 19.15 KB 0.00 KB (0.00%)
bundle/schema-toCodecJson.ts 15.11 KB 15.11 KB 0.00 KB (0.00%)
bundle/schema-toEquivalence.ts 15.40 KB 15.40 KB 0.00 KB (0.00%)
bundle/schema-toFormatter.ts 15.26 KB 15.26 KB 0.00 KB (0.00%)
bundle/schema-toJsonSchemaDocument.ts 17.85 KB 17.85 KB 0.00 KB (0.00%)
bundle/schema-toRepresentation.ts 16.05 KB 16.05 KB 0.00 KB (0.00%)
bundle/schema.ts 14.89 KB 14.89 KB 0.00 KB (0.00%)
bundle/stm.ts 11.94 KB 11.94 KB 0.00 KB (0.00%)
bundle/stream.ts 8.42 KB 8.42 KB 0.00 KB (0.00%)

@github-actions
Copy link
Contributor

📊 JSDoc Documentation Analysis

📈 Current Analysis Results
Analyzing 123 TypeScript files in packages/effect/src/ (including schema and config subdirectories)...

============================================================
         EFFECT JSDOC ANALYSIS REPORT
============================================================

📊 SUMMARY STATISTICS
------------------------------
Total files analyzed: 123
Total exported members: 3983
Missing @example: 1638 (41.1%)
Missing @category: 510 (12.8%)

🎯 TOP FILES NEEDING ATTENTION
----------------------------------------
1. Schema.ts
   📝 451 missing examples, 🏷️  260 missing categories
   📦 451 total exports
2. SchemaRepresentation.ts
   📝 92 missing examples, 🏷️  91 missing categories
   📦 92 total exports
3. Stream.ts
   📝 136 missing examples, 🏷️  0 missing categories
   📦 225 total exports
4. SchemaAST.ts
   📝 74 missing examples, 🏷️  18 missing categories
   📦 74 total exports
5. Channel.ts
   📝 71 missing examples, 🏷️  0 missing categories
   📦 140 total exports
6. Sink.ts
   📝 64 missing examples, 🏷️  2 missing categories
   📦 81 total exports
7. SchemaGetter.ts
   📝 49 missing examples, 🏷️  0 missing categories
   📦 49 total exports
8. SchemaTransformation.ts
   📝 29 missing examples, 🏷️  18 missing categories
   📦 29 total exports
9. Config.ts
   📝 33 missing examples, 🏷️  5 missing categories
   📦 33 total exports
10. JsonSchema.ts
   📝 17 missing examples, 🏷️  17 missing categories
   📦 17 total exports
11. Effect.ts
   📝 32 missing examples, 🏷️  1 missing categories
   📦 239 total exports
12. Cause.ts
   📝 27 missing examples, 🏷️  2 missing categories
   📦 67 total exports
13. Order.ts
   📝 25 missing examples, 🏷️  0 missing categories
   📦 25 total exports
14. Filter.ts
   📝 24 missing examples, 🏷️  0 missing categories
   📦 35 total exports
15. SchemaIssue.ts
   📝 22 missing examples, 🏷️  2 missing categories
   📦 22 total exports

✅ PERFECTLY DOCUMENTED FILES
-----------------------------------
   Chunk.ts (87 exports)
   Clock.ts (5 exports)
   FiberHandle.ts (15 exports)
   FiberMap.ts (19 exports)
   FiberSet.ts (14 exports)
   HKT.ts (4 exports)
   HashMap.ts (44 exports)
   HashSet.ts (21 exports)
   Match.ts (57 exports)
   MutableHashSet.ts (9 exports)
   MutableRef.ts (17 exports)
   NonEmptyIterable.ts (3 exports)
   Random.ts (7 exports)
   Redacted.ts (9 exports)
   RegExp.ts (3 exports)
   Runtime.ts (3 exports)
   Symbol.ts (1 exports)
   Trie.ts (29 exports)
   TxChunk.ts (22 exports)
   TxHashMap.ts (41 exports)
   TxHashSet.ts (24 exports)
   TxRef.ts (7 exports)
   TxSemaphore.ts (14 exports)
   Unify.ts (8 exports)
   index.ts (0 exports)

🔍 SAMPLE MISSING ITEMS FROM Schema.ts
-----------------------------------
   Optionality (type, line 60): missing example, category
   Mutability (type, line 67): missing example, category
   ConstructorDefault (type, line 74): missing example, category
   MakeOptions (interface, line 82): missing example, category
   Bottom (interface, line 106): missing example, category
   declareConstructor (interface, line 158): missing example, category
   declareConstructor (function, line 182): missing example
   declare (interface, line 206): missing example
   declare (function, line 215): missing example, category
   revealBottom (function, line 235): missing example, category

📋 BREAKDOWN BY EXPORT TYPE
-----------------------------------
const: 815 missing examples, 157 missing categories
function: 298 missing examples, 97 missing categories
type: 169 missing examples, 86 missing categories
interface: 267 missing examples, 150 missing categories
class: 56 missing examples, 1 missing categories
namespace: 33 missing examples, 19 missing categories

📈 DOCUMENTATION PROGRESS
------------------------------
Examples: 2345/3983 (58.9% complete)
Categories: 3473/3983 (87.2% complete)

============================================================
Analysis complete! 2148 items need attention.
============================================================

📄 Detailed results saved to: jsdoc-analysis-results.json

This comment is automatically updated on each push. View the analysis script for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant