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

Support for ExtractRouteQueries #17

Open
haejunejung opened this issue Aug 19, 2024 · 0 comments
Open

Support for ExtractRouteQueries #17

haejunejung opened this issue Aug 19, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@haejunejung
Copy link
Owner

haejunejung commented Aug 19, 2024

It supports for ExtractRouteQueries.

Query strings are one of the most popular methods for passing data, providing input data along with a URL. It mainly consists of data in key and value format. I thought about automatically creating this into a type such as ExtractRouteParams in #14.

However, since query strings can handle a large number of cases, here it will proceed with a method of processing a total of 8 patterns.

  1. Handle simple key-value pairs.
  2. Processes arrays represented by repeated keys.
  3. Processes arrays expressed as comma-separated values.
  4. Handle object and array expressions using bracket notation.
  5. Handle JSON strings.
  6. Boolean value
  7. Numeric value
  8. Date and Time Format (ISO 8601)

It can parse looks like below.

type Query = "user[name]=John&user[age]=30&tags[]=red,tags[]=blue&startDate=2024-08-19T15:00:00Z&enabled=true&complexData={\"key\":\"value\"}";

type QueryParams = ExtractRouteQueries<Query>;

// Result will be:
type QueryParams = {
    user: {
        name: string;
        age: number;
    };
    tags: string[];
    startDate: Date;
    enabled: boolean;
    complexData: { key: string }; 
}
@haejunejung haejunejung added the enhancement New feature or request label Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant