Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more advanced examples #19

Open
4 tasks
ZPiDER666 opened this issue Apr 17, 2020 · 3 comments
Open
4 tasks

Add more advanced examples #19

ZPiDER666 opened this issue Apr 17, 2020 · 3 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed housekeeping Cleanup and paying beck technical debt

Comments

@ZPiDER666
Copy link
Contributor

ZPiDER666 commented Apr 17, 2020

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, ..)

@sholladay
Copy link
Owner

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.

@ZPiDER666
Copy link
Contributor Author

excellent, when my experiments progress into a more complete understanding, i will make PRs, thanks for the answer!

@sholladay sholladay added good first issue Good for newcomers help wanted Extra attention is needed housekeeping Cleanup and paying beck technical debt labels Apr 17, 2020
This was referenced Jun 25, 2020
@sholladay
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed housekeeping Cleanup and paying beck technical debt
Projects
None yet
Development

No branches or pull requests

2 participants