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

Payload HTTP Backend Example #225

Closed
eviefp opened this issue Aug 25, 2020 · 4 comments · Fixed by #226
Closed

Payload HTTP Backend Example #225

eviefp opened this issue Aug 25, 2020 · 4 comments · Fixed by #226
Labels
recipe-request Requests for someone to build a recipe for their problem

Comments

@eviefp
Copy link

eviefp commented Aug 25, 2020

Recipe Name

PlayloadHttpApiNode

Each recipe name must be unique. Use PascalCase.

Recipe Description

A simple API example for the strongly typed HTTP backend payload. Ideally, it would show an API that allows for get all, get by id and insert, at least.

I already implemented something using AVar, and I was wondering whether this is too complicated for a single recipe? The alternative would be using files instead (to keep state across calls), but then it would also complicates matters due to encoding/decoding.

Do you think it would be an useful recipe?

PS: I cannot use StateT because it's not currently possible yet (in payload). I added an issue, and am willing to update this when/if it gets resolved.

@eviefp eviefp added the recipe-request Requests for someone to build a recipe for their problem label Aug 25, 2020
@JordanMartinez
Copy link
Owner

I cannot use StateT because it's not currently possible yet (in payload). I added an issue, and am willing to update this when/if it gets resolved.

If you use StateT, it would likely not produce the behavior you want. StateT threads state through a function call. I believe each request-response would start with the original value passed to the StateT computation, not the latest value.

@JordanMartinez
Copy link
Owner

I already implemented something using AVar, and I was wondering whether this is too complicated for a single recipe? The alternative would be using files instead (to keep state across calls), but then it would also complicates matters due to encoding/decoding.

AVar is fine. If we wanted to do this properly, we might use the ReaderT pattern, similar to what I did in the random number game. However, that might get too complicated for little benefit. This recipe highlights how one can build an HTTP server quickly using the library.

@milesfrain
Copy link
Collaborator

PS: I cannot use StateT because it's not currently possible yet (in payload). I added an issue, and am willing to update this when/if it gets resolved.

Issue for reference: hoodunit/purescript-payload#7

@milesfrain
Copy link
Collaborator

milesfrain commented Aug 26, 2020

We're able to get really great insights into cookbook usability by reviewing your stream of submitting a recipe:

Kudos for adding payload to the package set.

Also, feel free to suggest ways that we could make the cookbook more user-friendly. For example with our organization, the instructions we're giving to users, available issue templates, or anything else.

Some comments from reviewing the stream:

  • Github doesn't allow self-assignment without being a collaborator on the repo. Allow assignment of issues to non-collaborators isaacs/github#100
  • If you make a recipe typo, you can simply use scripts/newRecipe.sh to create a new recipe from your misspelled one with the correction, then delete the misspelled directory.
  • The common commands to build+run recipes are printed by running make list (or just make without arguments). They're also listed under Running Recipes and printed after running newRecipe.sh.
  • The non-traditional cookbook directory structure does not play nice with most IDE configurations. Edit: IDE issues with project structure #230. I'll make an issue for this and a note in the docs.

Edit: #228 I'll make a PR with these changes to improve the instructions:

Git Tips:

A note on branch naming:
I notice you're naming branches with a forward slash. This unfortunately confuses TryPureScript github path parsing, and prevents posting a demo link for us to preview before the recipe is merged. This is irrelevant for this particular node-only recipe, but swapping the slash for a hyphen would make it easier to review future TPS-compatible recipes.

JordanMartinez pushed a commit that referenced this issue Aug 29, 2020
)

* Convert template suggestions to table and other contributing edits

Follow-up to #225 (comment)

* Formatting adjustments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe-request Requests for someone to build a recipe for their problem
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants