pogo
pogo copied to clipboard
Add more advanced examples
The examples contained with pogo are very basic.
-
[ ] working with request objects should be demonstrated
-
[ ] working with path parameters should be demonstrated
import pogo from 'https://deno.land/x/pogo/main.js'; server.router.put('/path/{id}', async (request:pogo.Request) => { var id:String = request.route.params.id; });
-
[ ] working with request body should be demonstrated
import pogo from 'https://deno.land/x/pogo/main.js'; import { bodyReader } from "https://deno.land/std/http/io.ts"; server.router.put('/path', async (request:pogo.Request) => { const reader = bodyReader(request.raw.contentLength, request.raw.r); const bufferContent = await Deno.readAll(reader); const bodyText = new TextDecoder().decode(bufferContent); const body = JSON.parse(bodyText); });
-
[ ] etc. (file upload, headers, content types, ..)
Agreed. Another example I want to have soon is using React to render a small website using JSX syntax.
In terms of priority, the examples that are most important to add, in my opinion, are for the areas where Pogo is unique or diverges from hapi. So usage of the request body is definitely important. Path parameters would be nice to show as it's a commonly used feature, but they work the same as in hapi, so people can at least be referred elsewhere for that until we have our own example.
PRs welcome for any of these. At the moment, most of my time is going towards the TypeScript conversion and improvements to the router.
excellent, when my experiments progress into a more complete understanding, i will make PRs, thanks for the answer!
Another example just landed in PR #69 .
There are now four examples. All of them are still fairly basic, but they do include serving static files and two different modes of rendering React.
It would be nice for the next example to show body parsing with the new web standard request
methods. I'm also thinking it should use a deno.json
and an import-map.json
as a real app would.