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

Analysis on Hapi usage #904

Open
jenbutongit opened this issue Sep 2, 2022 · 2 comments
Open

Analysis on Hapi usage #904

jenbutongit opened this issue Sep 2, 2022 · 2 comments

Comments

@jenbutongit
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I would like to examine our hapi usage, try to align it closer to expected hapi behaviour. hapi documentation is a lot more comprehensive, so the more I can shift docs/support over the better for everyone..!

Describe the solution you'd like

  • analyse hapi usage
  • plan/design changes that allow xgfb to be more closely aligned to hapi
@jenbutongit jenbutongit moved this to 🆕 New in XGovFormBuilder kanban Sep 2, 2022
@jenbutongit jenbutongit moved this from 🆕 New to 📋 Backlog in XGovFormBuilder kanban Sep 2, 2022
@jenbutongit jenbutongit moved this from 📋 Backlog to Needs triage (discussion or tech design) in XGovFormBuilder kanban Apr 3, 2023
@jenbutongit
Copy link
Contributor Author

#964

@jenbutongit
Copy link
Contributor Author

I had a play around with the prefix option, which is probably nicer than initialising FormModel with it’s request base path.

I’ll leave it in at time of review if you want to see how it works (currently wrapped in an if statement) but I’ll remove it. imho it’s a lot nicer for “production” there’s no lookup step on /{id}/{page} (the routes are initialised on startup). There needs to be some more work/to be able to dynamically update the form model when updating via designer. (I think I just need to use the expose option — exposes a plugin’s properties outside of a plugin)
when setting up a plugin (express middleware) for a single form, I can neat things like per plugin I can set a context, accessible within the plugin. then you can decorate h with methods (express res), something like h.redirectLocal which can take take the route prefix and prefixes it outside of FormModel or PageControllers. so the FormModel and PageControllers only “know”, at most, what is inside the form json.
with per-form plugin it would mean we have access to the vhost option as well, which perhaps is what you were asking for in one of your issues you raised..? 1 instance multiple domains?
On the directory structure, I’m aligning closer to frameworks like next/svelte. which typically wants to keep related routes and functionality closer together.

├── handlers
│   ├── disabled.ts
│   ├── index.ts
│   ├── publish.ts
│   └── published.ts
└── index.ts

//index.ts plugin that registers related routes, a route is defined like so:
import { published, publish } from "./handlers";

    server.route({
      method: ["post", "put"],
      path: "/publish",
      handler: isPreviewMode ? publish.post : disabled,
      options: {
        payload: {
          parse: true,
        },
        description: `${enabledString} Allows a form to be persisted (published) on the runner server. Requires previewMode to be set to true. See runner/README.md for details on environment variables`,
      },
    });

description is displayed on startup, but is also used for doc generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs triage (discussion or tech design)
Development

No branches or pull requests

1 participant