@effect/platform 0.57.3 → 0.57.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1819,3 +1819,27 @@ const router = HttpServer.router.empty.pipe(
|
|
|
1819
1819
|
|
|
1820
1820
|
listen(HttpServer.server.serve(router), 3000)
|
|
1821
1821
|
```
|
|
1822
|
+
|
|
1823
|
+
## Conversions
|
|
1824
|
+
|
|
1825
|
+
### toWebHandler
|
|
1826
|
+
|
|
1827
|
+
The `toWebHandler` function converts a `Default` (i.e. a type of `HttpApp` that specifically produces a `ServerResponse` as its output) into a web handler that can process `Request` objects and return `Response` objects.
|
|
1828
|
+
|
|
1829
|
+
```ts
|
|
1830
|
+
import * as HttpServer from "@effect/platform/HttpServer"
|
|
1831
|
+
|
|
1832
|
+
// Define the router with some routes
|
|
1833
|
+
const router = HttpServer.router.empty.pipe(
|
|
1834
|
+
HttpServer.router.get("/", HttpServer.response.text("content 1")),
|
|
1835
|
+
HttpServer.router.get("/foo", HttpServer.response.text("content 2"))
|
|
1836
|
+
)
|
|
1837
|
+
|
|
1838
|
+
// Convert the router to a web handler
|
|
1839
|
+
// const handler: (request: Request) => Promise<Response>
|
|
1840
|
+
const handler = HttpServer.app.toWebHandler(router)
|
|
1841
|
+
|
|
1842
|
+
// Test the handler with a request
|
|
1843
|
+
const response = await handler(new Request("http://localhost:3000/foo"))
|
|
1844
|
+
console.log(await response.text()) // Output: content 2
|
|
1845
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/platform",
|
|
3
|
-
"version": "0.57.
|
|
3
|
+
"version": "0.57.4",
|
|
4
4
|
"description": "Unified interfaces for common platform-specific services",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"path-browserify": "^1.0.1"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@effect/schema": "^0.68.
|
|
19
|
-
"effect": "^3.3.
|
|
18
|
+
"@effect/schema": "^0.68.1",
|
|
19
|
+
"effect": "^3.3.5"
|
|
20
20
|
},
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"provenance": true
|