-
Notifications
You must be signed in to change notification settings - Fork 6
refactor(profile-editor): rebuild backend on web3-adapter for 2-way sync #985
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
Open
sosweetham
wants to merge
2
commits into
main
Choose a base branch
from
refactor/profile-editor-web3-adapter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "watch": ["src"], | ||
| "ext": "ts,json", | ||
| "ignore": ["src/**/*.spec.ts"], | ||
| "exec": "ts-node src/index.ts" | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import axios from "axios"; | ||
| import { env } from "./env"; | ||
|
|
||
| const USER_ONTOLOGY = "550e8400-e29b-41d4-a716-446655440000"; | ||
| const PROFESSIONAL_PROFILE_ONTOLOGY = "550e8400-e29b-41d4-a716-446655440009"; | ||
|
|
||
| /** | ||
| * Registers our `/api/webhook` as an AaaS subscription for the user and | ||
| * professional-profile ontologies (idempotent — skips if one already targets | ||
| * us). Logs and continues on failure so a down AaaS never blocks startup. | ||
| */ | ||
| export async function registerSubscriptionOnStartup(): Promise<void> { | ||
| if (!env.awarenessApiKey) { | ||
| console.warn( | ||
| "[aaas] AWARENESS_API_KEY not set — skipping subscription registration", | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| const targetUrl = | ||
| env.awarenessWebhookUrl || | ||
| `${env.baseUrl.replace(/\/$/, "")}/api/webhook`; | ||
| const headers = { Authorization: `Bearer ${env.awarenessApiKey}` }; | ||
| const base = env.awarenessServiceUrl.replace(/\/$/, ""); | ||
|
|
||
| try { | ||
| const { data } = await axios.get<{ | ||
| subscriptions: Array<{ targetUrl: string }>; | ||
| }>(`${base}/api/subscriptions`, { headers, timeout: 10000 }); | ||
|
|
||
| if (data.subscriptions?.some((s) => s.targetUrl === targetUrl)) { | ||
| console.log("[aaas] subscription already registered"); | ||
| return; | ||
| } | ||
|
|
||
| await axios.post( | ||
| `${base}/api/subscriptions`, | ||
| { | ||
| targetUrl, | ||
| ontologyFilter: [USER_ONTOLOGY, PROFESSIONAL_PROFILE_ONTOLOGY], | ||
| evaultFilter: [], | ||
| }, | ||
| { headers, timeout: 10000 }, | ||
| ); | ||
| console.log(`[aaas] subscription registered -> ${targetUrl}`); | ||
| } catch (error) { | ||
| const message = axios.isAxiosError(error) | ||
| ? (error.response?.data?.error ?? error.message) | ||
| : (error as Error).message; | ||
| console.error( | ||
| "[aaas] subscription registration failed (continuing):", | ||
| message, | ||
| ); | ||
| } | ||
| } | ||
134 changes: 0 additions & 134 deletions
134
platforms/profile-editor/api/src/controllers/AuthController.ts
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
platforms/profile-editor/api/src/controllers/DiscoveryController.ts
This file was deleted.
Oops, something went wrong.
69 changes: 0 additions & 69 deletions
69
platforms/profile-editor/api/src/controllers/FileProxyController.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing null check for
env.awarenessServiceUrlmay cause runtime TypeError.The function checks
env.awarenessApiKeyon line 13, but proceeds to useenv.awarenessServiceUrl.replace()on line 24 without verifying it's defined. If the API key is set but the service URL is not, this will throw aTypeError: Cannot read properties of undefined (reading 'replace'), bypassing the graceful error handling.Similarly,
env.baseUrlis used on line 22 without a guard whenenv.awarenessWebhookUrlis not set.🛡️ Proposed fix to validate required config
export async function registerSubscriptionOnStartup(): Promise<void> { - if (!env.awarenessApiKey) { + if (!env.awarenessApiKey || !env.awarenessServiceUrl) { console.warn( - "[aaas] AWARENESS_API_KEY not set — skipping subscription registration", + "[aaas] AWARENESS_API_KEY or AWARENESS_SERVICE_URL not set — skipping subscription registration", ); return; } + if (!env.awarenessWebhookUrl && !env.baseUrl) { + console.warn( + "[aaas] Neither AWARENESS_WEBHOOK_URL nor BASE_URL set — skipping subscription registration", + ); + return; + } + const targetUrl = env.awarenessWebhookUrl || `${env.baseUrl.replace(/\/$/, "")}/api/webhook`;🤖 Prompt for AI Agents