-
Notifications
You must be signed in to change notification settings - Fork 1
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
refactor new api #16
Merged
Merged
refactor new api #16
Conversation
This file contains 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
Member
alimd
commented
Sep 12, 2024
- feat(api-server): Add NanotronUrl class for handling client request URLs
- refactor(api-server): Update HttpResponseHeaders interface properties
- refactor(api-server): Update type.ts with NativeClientRequest and NativeServerResponse types
- refactor(api-server): types
- refactor(api-server): Update main.ts exports with NanotronClientRequest, NanotronServerResponse, and NanotronUrl types
- refactor(api-server): Update NanotronServerResponse class
- refactor(api-server): Update NanotronClientRequest class
- refactor(api-server): Update NanotronClientRequest class and NanotronServerResponse class
This commit adds a new file, `url.ts`, which contains the implementation of the `NanotronUrl` class. This class extends the `URL` class from the `node:url` module and provides additional functionality for handling client request URLs in the Nanotron API server. The `NanotronUrl` class includes a static property `versionPattern_` which is a regular expression used to match and replace the version prefix in the URL. It also has properties `method` and `debugId` which store the HTTP method and the debug ID of the request respectively. The constructor of the `NanotronUrl` class takes a `clientRequest` object of type `IncomingMessage` and a `prefix` parameter which represents the URL prefix. It modifies the URL by removing the prefix and replacing the version prefix with a single `/`. The modified URL is then passed to the `URL` constructor along with a default base URL. This commit enhances the functionality of the Nanotron API server by providing a dedicated class for handling client request URLs. This improves code organization and maintainability.
…iveServerResponse types
…st, NanotronServerResponse, and NanotronUrl types
- Update import statements and types in NanotronServerResponse class - Add NanotronClientRequest and NativeServerResponse types to type imports - Remove unused import of ServerResponse from node:http - Update constructor parameters to store NanotronClientRequest and NativeServerResponse - Update logger method calls with debugId from clientRequest.url - Update replyErrorResponse and replyError methods to use clientRequest instead of config - Update replyJson method to use debugId from clientRequest.url in logger error call - Update reply method to use debugId from clientRequest.url in logger method call - Remove unnecessary error logging in replyJson and reply methods
- Update imports and remove unused dependencies - Add type annotations for properties and parameters - Refactor constructor to accept NanotronUrl, NativeClientRequest, NativeServerResponse, and DefineRouteOption - Create NanotronServerResponse instance in constructor - Update logger method calls
…ServerResponse class - Removed unused imports and updated the imports for NanotronClientRequest and NanotronServerResponse classes in api-server.ts. - Added import for NanotronUrl in api-server.ts. - Updated the type definitions in type.ts to include NativeClientRequest and NativeServerResponse types. - Updated the bodyLimit default value in NanotronApiServer class to 1MiB. - Refactored the handleClientRequest_ method in NanotronApiServer class to use the new NativeClientRequest and NativeServerResponse types. - Updated the getRouteOption_ method in NanotronApiServer class to use the new NanotronUrl class. - Removed unused code and added error handling in the handleClientRequest_ method. - Updated the comments and log messages for better clarity and readability.
alimd
added
refactor
Updating the code with simpler, easier to understand or more efficient syntax or methods.
breaking-change
A change that changes the API or breaks backward compatibility for users.
new-feature
New features or options.
labels
Sep 12, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
breaking-change
A change that changes the API or breaks backward compatibility for users.
new-feature
New features or options.
refactor
Updating the code with simpler, easier to understand or more efficient syntax or methods.
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.