Stone.jsDocs
Paradigm

Adapters

Node HTTP

@stone-js/node-http-adapter serves your domain over HTTP on a Node process. It is the adapter most projects start with, and the one behind stone dev for backend apps.

#Install

terminalbash
npm i @stone-js/node-http-adapter

#Enable it

Add the decorator (or the blueprint) to the manifest. default: true marks it as the adapter to run when several are stacked and none is selected another way.

app/Application.tsdeclarativeimperative
import { StoneApp } from '@stone-js/core'
import { Routing } from '@stone-js/router'
import { NodeHttp } from '@stone-js/node-http-adapter'

@NodeHttp({ default: true })   // serve HTTP on Node
@Routing()
@StoneApp({ name: 'tasks' })
export class Application {}
import { defineStoneApp } from '@stone-js/core'
import { routerBlueprint } from '@stone-js/router'
import { nodeHttpAdapterBlueprint } from '@stone-js/node-http-adapter'

export const App = defineStoneApp(
  { name: 'tasks' },
  [routerBlueprint, nodeHttpAdapterBlueprint]
)
terminalbash
npm run dev                 # local server, hot reload
curl localhost:8080/tasks   # your routes, served

#Configuration

OptionTypeDefaultDescription
defaultbooleanfalseRun this adapter by default when several are stacked.
url / host / portstring / number·Where the server listens (also settable via the environment).
serverobject·Underlying server options (timeouts, body limits).

It builds on @stone-js/http-core, so the request and response model, cookies, headers and file uploads are the runtime-agnostic ones documented in Essentials.

#Deploy

Build and run the Node output behind your process manager or container. Because the domain is untouched by this adapter, the same code can later move to the edge or a Lambda by swapping the adapter, not the app.

terminalbash
npm run build      # produces the Node server
node dist/server.mjs

A minimal production container: multi-stage so only the runtime and pruned dependencies ship.

Dockerfiledocker
# --- build stage ---
FROM node:20-slim AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build                       # -> dist/server.mjs

# --- runtime stage ---
FROM node:20-slim
WORKDIR /app
ENV NODE_ENV=production
COPY package*.json ./
RUN npm ci --omit=dev
COPY --from=build /app/dist ./dist
EXPOSE 8080
CMD ["node", "dist/server.mjs"]

Stone.js

Your app exists in every runtime. Until you run it.

An open-source project by Stone Foundation
Created by Mr. Stone (Evens Pierre)