https://github.com/typicalfence/please-respond
Response Builder for Deno
https://github.com/typicalfence/please-respond
deno
Last synced: about 1 month ago
JSON representation
Response Builder for Deno
- Host: GitHub
- URL: https://github.com/typicalfence/please-respond
- Owner: TypicalFence
- License: mit
- Created: 2022-01-28T20:24:06.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-29T20:14:22.000Z (over 4 years ago)
- Last Synced: 2025-10-20T19:53:41.679Z (8 months ago)
- Topics: deno
- Language: TypeScript
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Please Respond
A Response Builder for Deno with a functional interface that consists of small composable functions, alternativly there is a more OOP style interface.
The basic idea is that there's small functions that change a detail about a given response, the library calls such functions steps. Said steps can then be chained to form the desired response.
There is also a `pipe` function which will apply all steps for a given response, per default an empty response is used.
Internally it represents response as a custom type that holds all data of a response, because you can't easily get the body out of a response.
All steps should copy their input and return a new object.
There is a single tiny dependency for easier currying.
## Examples
### Functional
```ts
import { body, html, pipe } from "https://deno.land/x/please_respond/mod.ts";
import { toResponse } from "https://deno.land/x/please_respond/mod.ts";
toResponse(pipe([html, body("
🦕
")]));
toResponse(pipe([json, body({ simple: "JSON support" })]));
```
### OOP
```ts
import { body, html } from "https://deno.land/x/please_respond/mod.ts";
import { response } from "https://deno.land/x/please_respond/oop.ts";
response().applyAll([
html,
body("
🦕
"),
]).toResponse();
```