Skip to content

refactor(api): nearbuilders.org projects over a contract+proxy attachment - #126

Open
adenarc wants to merge 2 commits into
NEARBuilders:mainfrom
adenarc:feat/124-projects-contract-proxy
Open

adenarc wants to merge 2 commits into
NEARBuilders:mainfrom
adenarc:feat/124-projects-contract-proxy

Conversation

@adenarc

@adenarc adenarc commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Closes #124

Stacked on #125 (the rc.44 upgrade). Please merge that first; until then this diff includes its commit.

api/src/services/nearbuilders-projects.ts no longer fetches nearbuilders.org's REST API with a hand-written NearbuildersProject interface. It now goes through a plugins.projects contract+proxy attachment:

projects: {
  contract: "bos://nearbuilding.near/nearbuilders.org#plugins.projects",
  proxy: "https://nearbuilders.org",
},
  • Calls getProjectBySlug, getProject and listProjects, typed by bos types gen. NearbuildersProject is now picked from the deployed contract's types.
  • These are unchanged: link/slug/id parsing, the host allowlist, slug regexes, the 8-result search cap, the 5s timeout, and the user-facing messages. NOT_FOUND still means "no such project". Unreachable stays "could not be reached". A reply without data still says "unexpected response". Other upstream errors are still SERVICE_UNAVAILABLE, but the text now shows the oRPC code instead of the HTTP status.
  • The nearbuildersApiUrl variable is removed. bos.lock.json is refreshed.
  • Tests: unit tests use a fake typed client. Integration tests pass a stub projects attachment to the test runtime instead of mocking fetch.

Tested: pnpm run typecheck, pnpm run lint and pnpm run test are green (api 205, ui 110). I also called nearbuilders.org's live /api/rpc/projects/{getProjectBySlug,getProject,listProjects}. All three return the expected shapes, and an unknown slug comes back as a 404 NOT_FOUND.

Browser check (local stack, Brave, signed out and signed in): signed out, the home page renders and /activity-sources and /binding redirect to sign-in. Signed in, project search lists live nearbuilders.org results. Picking one fills in the Source ID, display name and owner account. Pasting a link to a missing project shows "No nearbuilders.org project exists at …". An agent binding session created from a project link opens /binding prefilled. There's no visual change: the pages look the same as on main, and only the transport underneath moved. The account switcher is blurred in the screenshots.

project search project picked, details prefilled missing project link binding session prefilled from a project link

Template sync applied with --force; activity's own edits to api/plugin.dev.ts,
api/tsconfig.json and the biome ignore list are kept. The UI client now goes
through everything-dev/ui/api, since every-plugin's createRpcClient is a bare
client from rc.44 (everything-dev #849). Records bos.lock.json.
…ttachment

Replace the hand-rolled REST fetch in nearbuilders-projects.ts with the
plugins.projects attachment (nearbuilders.org#plugins.projects, proxy
https://nearbuilders.org), typed by bos types gen. NearbuildersProject is
now picked from the deployed contract instead of a local interface. The
link/slug/id parsing, host allowlist, search limits and error messages are
unchanged; NOT_FOUND still maps to a missing project, other upstream errors
to SERVICE_UNAVAILABLE. The nearbuildersApiUrl variable is gone.

Closes NEARBuilders#124
@adenarc
adenarc marked this pull request as ready for review November 12, 2026 07:44

This branch has not been deployed

No deployments
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.

Replace nearbuilders-projects.ts with a contract+proxy attachment

1 participant