Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tim-smart/effect-http
A HTTP toolkit for Effect-ts
https://github.com/tim-smart/effect-http
effect-ts http-client http-server
Last synced: 13 days ago
JSON representation
A HTTP toolkit for Effect-ts
- Host: GitHub
- URL: https://github.com/tim-smart/effect-http
- Owner: tim-smart
- Created: 2023-01-13T03:00:58.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-04T04:38:02.000Z (over 1 year ago)
- Last Synced: 2024-12-27T17:13:04.355Z (22 days ago)
- Topics: effect-ts, http-client, http-server
- Language: TypeScript
- Homepage:
- Size: 760 KB
- Stars: 33
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# effect-http
A runtime agnostic http library for effect-ts
## node.js example
```ts
import * as Http from "@effect-http/core"
import * as HttpNode from "@effect-http/node"
import { Effect, pipe } from "effect"
import { createServer } from "node:http"const app = pipe(
Http.router
.route("GET", "/", Effect.succeed(Http.response.text("Hello world!")))
.toHttpApp(),Http.httpApp.catchTag("RouteNotFound", () =>
Effect.succeed(response.text("Not found", { status: 404 })),
),
)pipe(
app,
HttpNode.serve(() => createServer(), { port: 3000 }),
Effect.runFork,
)
```## bun example
```ts
import * as Http from "@effect-http/core"
import * as HttpBun from "@effect-http/bun"
import { Effect, pipe } from "effect"const app = pipe(
Http.router
.route("GET", "/", Effect.succeed(Http.response.text("Hello world!")))
.toHttpApp(),Http.httpApp.catchTag("RouteNotFound", () =>
Effect.succeed(Http.response.text("Not found", { status: 404 })),
),
)pipe(app, HttpBun.serve({ port: 3000 }), Effect.runFork)
```