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 module service adapter, unify route handling to handleRequestWithEdgeSpec #23

Merged
merged 9 commits into from
Jan 19, 2024

Conversation

mxsdev
Copy link
Contributor

@mxsdev mxsdev commented Jan 19, 2024

EdgeSpec, once constructed, is almost always used as a function (request: Request, pathname: string) => Response. So I introduced handleRequestWithEdgeSpec, which enables this functionality.

I also introduced the code for module services here, which I wrote as a kind of adapter that takes an EdgeSpec and returns a function for an EdgeSpecRouteFn. I introduced a handle404 function to EdgeSpec in order to exemplify cascading options, so that e.g. 404 configs pass down to child routes.

@mxsdev mxsdev requested a review from codetheweb January 19, 2024 05:56
Base automatically changed from fix-tests to main January 19, 2024 18:41
src/types/edge-spec.ts Outdated Show resolved Hide resolved
src/types/edge-spec.ts Outdated Show resolved Hide resolved
@mxsdev mxsdev requested a review from codetheweb January 19, 2024 22:17

export type ModuleService = (options?: ModuleServiceOptions) => EdgeSpecRouteFn

export const createModuleService: EdgeSpecAdapter<[], ModuleService> = (
Copy link
Contributor

Choose a reason for hiding this comment

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

🐧 I kinda like

Suggested change
export const createModuleService: EdgeSpecAdapter<[], ModuleService> = (
export const createEmbeddedService: EdgeSpecAdapter<[], EmbeddedService> = (

but don't want to bikeshed too much

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@seveibar

will deal with this in follow-up discussions/PRs/RFCs

src/types/edge-spec.ts Outdated Show resolved Hide resolved
src/serve/create-server-from-route-map.ts Outdated Show resolved Hide resolved
@mxsdev mxsdev merged commit 9df17b8 into main Jan 19, 2024
9 checks passed
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.

2 participants