Skip to content

Running Locally

The server package is @mattrax/server in apps/server/.

Development

Run the TypeScript entrypoint with:

sh
pnpm --filter @mattrax/server dev -- serve --webhook-url http://localhost:8787/webhook

By default, development mode uses:

OptionDefault
--port3000
--originhttp://localhost:3000
--data-dir./.data

--webhook-url is required because the MDM service delegates management decisions to your backend.

CLI

The CLI command is mattrax-server and supports these subcommands:

CommandPurpose
versionPrints the package version.
serveStarts the HTTP server.

serve accepts:

FlagRequiredDescription
--portNoHTTP port. Defaults to 3000.
--originNoPublic origin used when generating enrollment and asset URLs. Defaults to http://localhost:3000.
--webhook-urlYesBase URL for your management webhook backend.
--data-dirNoDirectory for filesystem-backed server state.
--apple-vendor-certNoPath to an Apple vendor certificate PEM file used to derive the MDM topic.

Example:

sh
pnpm --filter @mattrax/server dev -- serve \
  --port 3000 \
  --origin https://mdm.example.com \
  --webhook-url https://api.example.com/webhook \
  --data-dir ./data \
  --apple-vendor-cert ./certs/apple-vendor.pem

Building

Build the standalone server binary with:

sh
pnpm --filter @mattrax/server build

The build script bundles the TypeScript server with esbuild, creates a Node single executable application blob, injects it into a copied Node binary, and writes the result to:

text
apps/server/dist/mattrax-server

For bundled production builds, the default data directory changes to /opt/mattrax-server.