Skip to main content
NetScriptdocs Search docs ⌘K v0.0.9
Browse documentation
View as Markdown

Run the team workspace under Aspire

In this chapter you run the whole team workspace as one system. A single aspire start brings up Postgres, the Redis cache, your workspace service, the auth-api service at its allocated endpoint, the Workers API and every background processor, wired together and visible in one dashboard. netscript init generated the AppHost in chapter 1, and each plugin you installed since (auth, then workers) added its own service and processor to the resource graph, so there is no orchestration wiring to maintain by hand.

  1. 1 · Scaffold
  2. 2 · Auth
  3. 3 · Workspace data
  4. 4 · Provision job
  5. 5 · Route authz
  6. 6 · Deploy

What you will build

Your complete my-workspace/ running under one Aspire AppHost: every service, plugin API, background processor and backing container in a single resource graph, observable from the dashboard at the URL Aspire prints, including the auth service from chapter 2. At the end you can read the running topology, with the exact port each resource bound, from one pane.

Before you begin

You need everything from chapters 1–5: the scaffolded workspace, the auth plugin, the second database, the workers plugin and provision-member job, and the guarded workspace service. netscript init scaffolded the AppHost in chapter 1 (you didn't pass --no-aspire). Confirm the orchestration entry point is on disk and the workspace type-checks:

Shell
# From the workspace root
ls aspire/apphost.mts aspire/aspire.config.json
deno task check

Step 1 — Restore the AppHost SDK (once)

The AppHost runs on its own isolated Node runtime inside aspire/, so its dependencies never leak into your Deno workspace. Restore that runtime once per machine, and again after an SDK bump:

Shell
cd aspire
aspire restore

Step 2 — Start the whole graph

aspire start turns appsettings.json and your plugin contributions into a resource graph and boots all of it: infrastructure first, then services, plugin APIs and background processors, with cross-references resolved into injected environment variables.

Shell
# Still inside aspire/. Boots the whole graph; prints the dashboard URL.
aspire start

When boot finishes, aspire start prints the allocated dashboard address. The graph it brings up:

The local resource graph aspire start brings up
Name · TypeDescription
aspire (dashboard)the URL Aspire prints The Aspire dashboard — live resource list, console logs, structured logs, and traces. The generated local profile allows anonymous dashboard access.
OTLP collectorthe OTLP URL Aspire prints OpenTelemetry endpoint; framework spans (job dispatch/execution, scheduler runs) land here automatically.
postgresContainer The primary datasource from chapter 1. Chapter 2 uses kv-oauth sessions in KV and adds no auth SQL tables.
workspace (second db)Container The isolated workspace datasource from chapter 3, provisioned alongside the primary.
redisContainer (cache) Redis cache — the default --cache-backend; Redis-compatible. Backs KV/queue workloads and the kv-oauth session store.
workspace (service)allocated endpoint Your guarded oRPC service from chapter 5 — /api/workspace/{workspace}/members requires a scoped principal, /health stays public.
auth-apiallocated endpoint The auth plugin's service from chapter 2 — /api/v1/auth/* (signin, callback, signout, sessions/revoke, session, me).
workers-apiallocated port The Workers API from chapter 4 — triggers and inspects the provision-member job.
background processorsexecutables (no port) The workers processor that drains the job queue — a separate process, not a thread in the API.

Step 3 — Use the dashboard

Open the URL Aspire prints (the generated local profile allows anonymous access):

Aspire dashboard surfaces
Name · TypeDescription
Resourcestab Every container and executable above with status, endpoints, and the resolved environment. The authority for which port each resource bound.
Console logstab stdout/stderr per resource — a failing auth-api or workers processor is one click away.
Structured logs + Tracestab Spans and structured logs correlated by traceparent across services — collected via the OTLP endpoint at the OTLP URL Aspire prints.

Verify your progress

With the graph up, check the app end to end: the auth service, the guarded route and the job.

Shell
netscript service list
netscript contract inspect workspace
netscript plugin doctor
ns-workers executions --limit=10 --json

Use list_api_services → list_service_operations → get_operation_schema to inspect the live workspace.members operation. Call it through the server-side session client from chapter 5 with { workspace: 'ws-1', limit: 20, offset: 0 }. A request without a session returns 401; a session without workspace:read returns 403; a member with that scope receives the members list.

  • [ ] aspire restore and aspire start succeed from inside aspire/.
  • [ ] The dashboard at the URL Aspire prints lists postgres, workspace (db), redis, workspace (service), auth-api, and workers-api — all green.
  • [ ] Aspire reports the auth service ready at its allocated endpoint.
  • [ ] The workspace app handler returns 401 without a session, and an authorized typed members call returns data.
  • [ ] ns-workers show-job provision-member --json confirms the registered job, and executions show its result.

What you built

The complete authenticated team-workspace backend, running locally as one orchestrated system: Postgres, an isolated workspace database, Redis, the guarded workspace service, the auth-api service at its allocated endpoint, and the Workers API with its processor, all in one Aspire resource graph. Across the track you added a pluggable auth backend, a session, team data in its own datasource, off-path provisioning and a route-authz seam that fails closed. The app is single-tenant by design, with org scoping as an app-level extension.

Next steps

Search all documentation

Type a term to search the documentation.