# Shared-package monorepo

Two independently runnable Node web services that consume the same workspace
package, with Dockerfiles and a Bex Blueprint that redeploy on shared-library
and lockfile changes.

**Filter evidence pin:** Bex `d0f17feb3ece1ce20c8c85384e8ee68ff4b2e1d3`
(`rootDirMatches` then `buildFilterMatches`). Empty changed-path payloads fail
open. A narrow `rootDir` vetoes shared paths even if they appear in `buildFilter`.

## Layout

```text
packages/shared/     # @shared-package-monorepo/shared
apps/api/            # service identity "api" (port 3101)
apps/worker-api/     # service identity "worker-api" (port 3102)
render.yaml          # dockerContext: ., shared + lockfile in filters
docs/NOTES.md        # ignored by buildFilter
```

## Local run

```bash
cd examples/shared-package-monorepo
npm install
npm run start:api          # PORT=3101
npm run start:worker-api   # other terminal, PORT=3102
curl -s localhost:3101/ | jq .
curl -s localhost:3102/healthz
npm test
npm run rehearse           # explanatory deploy matrix (not live Bex)
```

## Docker (from this directory as context root)

```bash
docker build -f apps/api/Dockerfile -t shared-mono-api .
docker build -f apps/worker-api/Dockerfile -t shared-mono-worker-api .
docker run --rm -p 3101:3101 -e PORT=3101 shared-mono-api
docker run --rm -p 3102:3102 -e PORT=3102 shared-mono-worker-api
```

## Deploy on Bex

1. Push this tree to a repository you own; set `repo` / `branch` in `render.yaml`.
2. Connect the repo in a non-production workspace ([GitHub integration](https://bex.co/docs/platform/github-integration)).
3. Apply the Blueprint ([Blueprints](https://bex.co/docs/platform/blueprints)). Listing a `repo` URL does not install a webhook by itself.
4. Push the change matrix in `.pm` source-review / `npm run rehearse` and inspect per-service deploy history and `/` responses.

Hosted push outcomes require an authorized Git-connected workspace; local rehearsal output is explanatory only.

## Safety

Do not point filters at a customer monorepo from this sample without replacing
`repo` and reviewing `buildFilter` paths. Filters are not CI approval gates.
