-
-
Notifications
You must be signed in to change notification settings - Fork 35
Improving methods inheritance #2833
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d148503
Ref: rm AuxMethod, add FamiliarMethod and CORSMethod (unfinished).
RobinTail 56d75b6
Adjusting implementation to use SomeMethod (string) where applicable.
RobinTail b4e5cd3
Ref: naming, fallbackInputSources.
RobinTail 5d47dae
Minor: jsdoc.
RobinTail 1d29db9
More constraints where using comparison to SomeMethod.
RobinTail 67295a9
Ref: minor, shortening.
RobinTail d7b9769
Test for new types.
RobinTail 75aa342
rm redundant import.
RobinTail File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,35 +1,46 @@ | ||
| import type { IRouter } from "express"; | ||
|
|
||
| export type SomeMethod = Lowercase<string>; | ||
|
|
||
| type FamiliarMethod = Exclude< | ||
| keyof IRouter, | ||
| "param" | "use" | "route" | "stack" | ||
| >; | ||
|
|
||
| export const methods = [ | ||
| "get", | ||
| "post", | ||
| "put", | ||
| "delete", | ||
| "patch", | ||
| ] satisfies Array<keyof IRouter>; | ||
| ] satisfies Array<FamiliarMethod>; | ||
|
|
||
| export const clientMethods = [ | ||
| ...methods, | ||
| "head", | ||
| ] satisfies Array<FamiliarMethod>; | ||
|
|
||
| /** | ||
| * @desc Methods supported by the framework API to produce Endpoints on EndpointsFactory. | ||
| * @see BuildProps | ||
| * @example "get" | "post" | "put" | "delete" | "patch" | ||
| * */ | ||
| export type Method = (typeof methods)[number]; | ||
|
|
||
| /** | ||
| * @desc Additional methods having some technical handling in the framework | ||
| * @see makeCorsHeaders | ||
| * @todo consider removing it and introducing CORSMethod = ClientMethod | "options" | ||
| * */ | ||
| export type AuxMethod = Extract<keyof IRouter, "options" | "head">; | ||
|
|
||
| export const clientMethods = [...methods, "head"] satisfies Array< | ||
| Method | Extract<AuxMethod, "head"> | ||
| >; | ||
|
|
||
| /** | ||
| * @desc Methods usable on the client side, available via generated Integration and Documentation | ||
| * @see withHead | ||
| * @example Method | "head" | ||
| * */ | ||
| export type ClientMethod = (typeof clientMethods)[number]; | ||
|
|
||
| /** | ||
| * @desc Methods supported in CORS headers | ||
| * @see makeCorsHeaders | ||
| * @see createWrongMethodHandler | ||
| * @example ClientMethod | "options" | ||
| * */ | ||
| export type CORSMethod = ClientMethod | Extract<FamiliarMethod, "options">; | ||
|
|
||
| export const isMethod = (subject: string): subject is Method => | ||
| (methods as string[]).includes(subject); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RobinTail marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.