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

Implement http registry #464

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

Implement http registry #464

wants to merge 10 commits into from

Conversation

yorhodes
Copy link
Member

@yorhodes yorhodes commented Jan 7, 2025

Description

  • Implements HttpServer REST API wrapper around IRegistry
  • Implements HttpClientRegistry which implements IRegistry for use in clients like the CLI or warp UI

Backward compatibility

Yes

Testing

Manual

Copy link

changeset-bot bot commented Jan 7, 2025

🦋 Changeset detected

Latest commit: e4c6c85

The changes in this PR will be included in the next version bump.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@yorhodes yorhodes changed the title Implement http registry using cursor Implement http registry Jan 7, 2025
Comment on lines 2 to +6
"name": "@hyperlane-xyz/registry",
"description": "A collection of configs, artifacts, and schemas for Hyperlane",
"version": "6.11.0",
"version": "6.12.0-http.2",
"dependencies": {
"express": "^4.21.2",
Copy link
Contributor

Choose a reason for hiding this comment

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

wonder if it makes sense to spin this off to a side-package so it doesn't add to the normal registry size

Copy link
Member Author

@yorhodes yorhodes Jan 8, 2025

Choose a reason for hiding this comment

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

alternatively we can do something similar to the FileSystemRegistry for tree shaking
#34
defer to @jmrossy, I know he hates bundle bloat

Copy link
Collaborator

Choose a reason for hiding this comment

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

Putting it in it's own export path like I did for index.fs is a good idea. Not just for bundle bloat but also because express isn't meant to be run in the browser so its inclusion could cause errors.

Copy link
Collaborator

@jmrossy jmrossy left a comment

Choose a reason for hiding this comment

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

This is cool!

@@ -1,5 +1,23 @@
# @hyperlane-xyz/registry

## 6.12.0-http.2
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why has the changelog changed as part of your PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

this was before I figured out how to get yarn link working I needed to publish some beta versions for the monorepo PR to use

@@ -1,15 +1,17 @@
{
"name": "@hyperlane-xyz/registry",
"description": "A collection of configs, artifacts, and schemas for Hyperlane",
"version": "6.11.0",
"version": "6.12.0-http.2",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you mean to merge this?

Comment on lines 2 to +6
"name": "@hyperlane-xyz/registry",
"description": "A collection of configs, artifacts, and schemas for Hyperlane",
"version": "6.11.0",
"version": "6.12.0-http.2",
"dependencies": {
"express": "^4.21.2",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Putting it in it's own export path like I did for index.fs is a good idea. Not just for bundle bloat but also because express isn't meant to be run in the browser so its inclusion could cause errors.

});
}

get type(): RegistryType {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Avoid get proxy methods. They have pitfalls. Use simple methods/members instead.

}

get type(): RegistryType {
throw new Error('Method not implemented.');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not set a RegistryType?

throw new Error('Method not implemented.');
}

get uri(): string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

this.app.get('/metadata', async (req, res) => {
try {
const metadata = await registry.getMetadata();
if (!metadata) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nbd but I don't think getMetadata can ever return a falsy value. Maybe you meant to check that Object.keys().length > 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

this was AI generated lol
will clean this up before setting ready for review

}

start(port = process.env.PORT || 3000) {
return new Promise<void>((resolve, reject) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this method get awaited somewhere? Returning a process for a long-lived job like a server seems odd to me

Copy link
Member Author

Choose a reason for hiding this comment

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

also AI generated 😅

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.

3 participants