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

feat: script API route configuration options #266

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Blckbrry-Pi
Copy link
Collaborator

@Blckbrry-Pi Blckbrry-Pi commented May 7, 2024

Resolves OGBE-3

Copy link
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @Blckbrry-Pi and the rest of your teammates on Graphite Graphite

@Blckbrry-Pi Blckbrry-Pi force-pushed the 05-07-feat_script_api_route_configuration_options branch from 143fb32 to ed6b983 Compare May 7, 2024 11:38
@Blckbrry-Pi Blckbrry-Pi marked this pull request as ready for review May 7, 2024 11:40
Copy link

linear bot commented May 7, 2024

Copy link
Contributor

@MasterPtato MasterPtato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this add the chosen method and input data to the generated openapi spec anywhere?

src/runtime/server.ts Outdated Show resolved Hide resolved
Copy link
Collaborator Author

Does this add the chosen method and input data to the generated openapi spec anywhere?

Is there a reason we need to clone the request here? I could imagine this being expensive for requests with large payloads

It does not, thank you for reminding me to fix that!

Copy link
Member

@NathanFlurry NathanFlurry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the idea of where this is going is good, but i don't think it's quite the right approach

if we're exposing raw rest api endpoints, we should give full control.

we should let have access to the arbritrary request and return an arbitrary response themselves. tbd on how to impelment those types; i think we'll just type it as the DOM request type and pass whatever vanilla object we have to the request (wether it's a cloudflare request or http server request).

in terms of actually running it, i think we need to split this out from scripts and make it a separate script-like file. basically:

files:

  • api/login_callback.ts
  • api/login_link.ts

in the module.yaml:

api:
  login_callback:
    method: GET
    path: /a/b/{param}

tbd on what route matching we use, but we do need to be able to support wildcards (e.g. for serving dynamic http files).

so it needs to:

  • validate there is no conflict in paths
  • implement a very basic router
  • pass a raw Request and accept a raw Response

this should end up looking sort of similar to Cloudflare workers in the sense of getitng a raw req & res: https://developers.cloudflare.com/workers/runtime-apis/request/

example use cases:

  • oauth callbacks
  • webhooks
  • serving static webpages (we'll be hosting the admin portal this way)

@Blckbrry-Pi Blckbrry-Pi force-pushed the 05-07-feat_script_api_route_configuration_options branch 4 times, most recently from e097634 to 9441fd0 Compare May 24, 2024 23:20
src/project/api.ts Outdated Show resolved Hide resolved
src/runtime/path_resolver.ts Outdated Show resolved Hide resolved
src/project/module.ts Outdated Show resolved Hide resolved
src/project/module.ts Outdated Show resolved Hide resolved
src/project/module.ts Outdated Show resolved Hide resolved
src/runtime/path_resolver.ts Outdated Show resolved Hide resolved
src/runtime/server.ts Outdated Show resolved Hide resolved
src/runtime/server.ts Outdated Show resolved Hide resolved
src/project/module.ts Outdated Show resolved Hide resolved
src/runtime/server.ts Outdated Show resolved Hide resolved
src/runtime/server.ts Outdated Show resolved Hide resolved
Copy link
Member

@NathanFlurry NathanFlurry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs a test module in the tests/basic/ too

@Blckbrry-Pi Blckbrry-Pi force-pushed the 05-07-feat_script_api_route_configuration_options branch from 9441fd0 to 7279884 Compare May 25, 2024 01:02
src/runtime/server.ts Outdated Show resolved Hide resolved
src/project/module.ts Outdated Show resolved Hide resolved
src/runtime/path_resolver.ts Outdated Show resolved Hide resolved
src/runtime/responses.ts Outdated Show resolved Hide resolved
@Blckbrry-Pi Blckbrry-Pi force-pushed the 05-07-feat_script_api_route_configuration_options branch from 7279884 to d6a0cf1 Compare May 25, 2024 02:46
Copy link
Member

@NathanFlurry NathanFlurry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment on thread.

also waiting on resolution of naming of api -> ? in the thread on slack.

@Blckbrry-Pi Blckbrry-Pi force-pushed the 05-07-feat_script_api_route_configuration_options branch 4 times, most recently from 598b05e to fbfcf4f Compare May 29, 2024 16:31
@Blckbrry-Pi Blckbrry-Pi requested a review from ABCxFF May 29, 2024 16:32
src/error/mod.ts Outdated Show resolved Hide resolved
@Blckbrry-Pi Blckbrry-Pi force-pushed the 05-07-feat_script_api_route_configuration_options branch from fbfcf4f to 62642e0 Compare May 30, 2024 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants