Scaffold the team workspace
In this chapter you create my-workspace/, a NetScript workspace with an example service and a
Postgres database, and boot it under Aspire. The auth backend, the team database, the provisioning
job and the route guards in later chapters all attach to this app.
What you will build
A my-workspace/ directory with a typed workspace service on its own port, a Postgres database,
and the Aspire orchestration that provisions Postgres and the Redis cache. At the end, the Aspire
dashboard at the URL Aspire prints shows the service, database and cache running, and
deno task check passes.
Before you begin
You need Deno 2.x, the Aspire CLI, and Docker running, because Aspire starts the Postgres and Redis containers. Check all three:
deno --version # Deno 2.x
aspire --version # the Aspire CLI
docker info # prints engine details, not a connection error
Install the NetScript CLI from JSR, then confirm it is on your PATH:
deno install --global --allow-all --name netscript --minimum-dependency-age=0 jsr:@netscript/cli@0.0.9
netscript --help
The public command groups are agent, config, contract, db, deploy, generate, init, marketplace, plugin, service, tokens, ui:add, ui:init, ui:list, ui:remove and ui:update. If netscript is not found, add Deno's install directory to your PATH and open a new terminal.
Step 1 — Preview the scaffold
--dry-run plans the scaffold and prints per-phase file and directory totals without writing to
disk:
netscript init my-workspace --service --service-name workspace --db postgres --dry-run
A clean dry run confirms your flags are valid. The CLI rejects bad combinations, such as an unknown
--db engine, before any file exists.
This track uses --db postgres, the recommended default. You can swap it for mysql, mssql or
sqlite and follow along the same way; SQLite is file-backed, so it has no Aspire container.
Step 2 — Create my-workspace/
Run the same command without --dry-run:
netscript init my-workspace --service --service-name workspace --db postgres
cd my-workspace
The CLI scaffolds my-workspace/, formats the output with deno fmt, initializes a git repository,
and prints a next steps summary for your options.
| Name · Type | Description |
|---|---|
--service --service-name workspaceexample service |
Include an example oRPC service named 'workspace' at its allocated endpoint. You protect it in chapter 5. |
--db postgresdatabase workspace |
Scaffold a Postgres database workspace. This primary datasource is available for application data; chapter 2 uses KV-backed auth without an auth SQL migration. |
--dry-runplan only |
Plan the scaffold and print totals without writing any files (Step 1). |
Step 3 — Tour what you got
my-workspace/ has this shape. The rest of the track edits these directories:
- my-workspace/
- apps/dashboard/ # Fresh frontend (defineFreshApp)
- contracts/ # Shared oRPC + Zod contracts, versioned under versions/v1/
- services/workspace/ # The example oRPC service (src/main.ts, router.ts) — guarded in chapter 5
- plugins/ # Plugin registry — empty until you add the auth plugin in chapter 2
- database/ # The primary Postgres workspace; a second db is added in chapter 3
- aspire/ # Aspire TypeScript orchestration (isolated Node runtime)
- appsettings.json # Infrastructure config (Services / Databases / Persistent)
- deno.json # Workspace root (members, tasks, dependency catalog)
- netscript.config.ts # Framework config (defineConfig)
You return to two of them most: services/workspace/ is the oRPC service whose routes you
protect in chapter 5, and plugins/ is where the auth plugin lands in chapter 2. Everything
takes its types from contracts/, the typed seam between your services and any client.
Step 4 — Bring up orchestration
Aspire provisions your database and cache; you don't start containers by hand. Run it from the
aspire/ folder so the CLI finds apphost.mts:
cd aspire
aspire restore # once per machine: restores the Aspire SDK modules
aspire start # starts the AppHost and every declared resource
aspire start brings up Postgres, Redis and your workspace service, then prints the Aspire
dashboard URL. The generated local profile allows anonymous dashboard access. Open the dashboard:
the URL Aspire prints
Leave aspire start running in this terminal for the rest of the track. The dashboard's resource
list shows the exact port each resource bound.
Verify your progress
In a second terminal, with aspire start still running in the first, check the workspace service
and type-check the workspace:
curl "$SERVICE_URL/health"
deno task check
curl returns a healthy JSON response and deno task check finishes clean.
- [ ]
netscript --helplists the public command groups. - [ ]
my-workspace/exists withservices/workspace/,plugins/,database/, andaspire/. - [ ]
aspire startis up;postgresandredisare green in the dashboard at the URL Aspire prints. - [ ]
curl "$SERVICE_URL/health"returns a healthy response. - [ ]
deno task checkpasses.
What you built
A NetScript workspace at my-workspace/: a typed workspace service at its allocated endpoint, shared contracts,
a Postgres database and a Redis cache, all orchestrated by Aspire and visible in one dashboard. The
service still answers anyone. Next, you add an identity layer so the app can tell a team member from
a stranger.