This sample runs a full Node-Boot application (controllers, dependency injection, middleware,
authorization, validation) as an Encore.ts service, using
@nodeboot/encore-server.
Encore.ts owns the HTTP listening socket itself; the only way to plug a request handler into it is
through a "raw endpoint" (api.raw), which
receives plain Node.js IncomingMessage/ServerResponse objects - just like node:http.
api/encore.service.tsdeclares theapiEncore service.api/index.tsregisters a single catch-all raw endpoint (path: "/!path",method: "*") that boots the Node-Boot application on cold start and forwards every request intoEncoreServer's handler, which routes it through Node-Boot's own controllers.src/app.tsis the actual Node-Boot application:@NodeBootApplication, dependency injection (@EnableDI), validation (@EnableValidations), and authorization (@EnableAuthorization) wired up exactly like any other Node-Boot server adapter.src/controllers,src/services,src/middlewares, andsrc/authcontain the same kind of framework-agnostic Node-Boot code you'd write for Express/Koa/Fastify - it runs unchanged here.
- Encore CLI (
brew install encoredev/tap/encore, or see the docs for other platforms) - Node.js and
pnpm(this sample is part of the Node-Boot pnpm workspace)
From the repository root, build the workspace packages this sample depends on, then start Encore:
pnpm install
pnpm --filter @nodeboot/encore-sample... run build
cd samples/sample-encore
encore runencore run starts Encore's local runtime and development dashboard at
http://localhost:9400. Once running, call the API:
curl http://localhost:4000/api/hello
# "Hello, from Node-Boot running on Encore.ts!"
curl http://localhost:4000/api/hello/info
curl -X POST http://localhost:4000/api/users \
-H "Content-Type: application/json" \
-H "Authorization: Bearer local-test-token" \
-d '{"name": "Ada Lovelace", "email": "ada@example.com"}'
curl http://localhost:4000/api/usersEncore.ts apps are fully open source and can be built into a standard Docker image and deployed anywhere:
encore build docker nodeboot-encore-sample:latest
docker run -p 4000:8080 nodeboot-encore-sample:latestSee the self-hosting guide for configuring infrastructure (env vars, secrets, etc.) for a self-hosted deployment.
Link the app to Encore Cloud (creates a free account/app on first run) and push to deploy:
encore app link
git add -A .
git commit -m "Initial commit"
git push encoreThen open the Cloud Dashboard to monitor the deployment and get your production URL.
- The
UserServiceuses an in-memoryMappurely to keep the sample self-contained. Swap it for an Encore.ts SQL database (encore.dev/storage/sqldb) or@nodeboot/starter-persistencefor a real application. EncoreDriveralways writes the final HTTP response itself via Node-Boot'sGlobalErrorHandler;ErrorMiddlewareis only invoked for observability side effects (logging, alerting, etc.).