https://github.com/perongh/funweb
Declarative & Functional Web Backend Framework
https://github.com/perongh/funweb
Last synced: about 2 months ago
JSON representation
Declarative & Functional Web Backend Framework
- Host: GitHub
- URL: https://github.com/perongh/funweb
- Owner: PeronGH
- Created: 2024-04-21T15:37:05.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-07T08:35:51.000Z (10 months ago)
- Last Synced: 2025-01-19T09:42:16.432Z (4 months ago)
- Language: TypeScript
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# funweb
Functional Web Backend Framework
## Example
```typescript
import {
catchError,
get,
internalServerError,
post,
route,
routes,
verbs,
} from "jsr:@pixel/funweb";const handler = routes(
route(
"/api/v1",
verbs(
get((req) => Response.json(Object.fromEntries(req.headers))),
post((req) => new Response(req.body)),
),
),
route(
"/?(*.{html,htm})",
(req) => new Response(new URL(req.url).pathname),
),
route(
"/**/error",
() => {
throw new Error("An error occurred");
},
),
catchError((req) => {
console.error(req.error);
return internalServerError(req);
}),
);Deno.serve(handler);
```