OpenArtifacts

openartifacts.sh / templates / node-api

Node HTTP API

Node.js 22, no dependencies · size small · 3 files, 5.6 kB

A minimal JSON API on Node's built-in http module: one file, no dependencies, no install step, so a cold start is just node server.mjs and the first request after a sleep is answered in about a second. Start here when you want plain JavaScript and your own routes.

Deploy it

One call publishes it as-is and boots it. It needs no environment variables. Files you send with the call replace the template's files of the same name, and fields you send override its oa.json. It is billed like any service.

With curl

# once: an account and its token
curl -sX POST "https://openartifacts.sh/v1/signup?ref=templates"
# the template, published and booted
curl -sX POST https://openartifacts.sh/v1/publish \
  -H "Authorization: Bearer $OA_TOKEN" \
  -F type=service -F template=node-api -F slug=my-node-api

From an MCP client

publish_artifact {"type": "service", "template": "node-api",
                  "slug": "my-node-api"}

With the CLI

npx @openartifacts/cli signup --ref templates   # once
npx @openartifacts/cli deploy --template node-api --slug my-node-api
# or edit first: the files, here, then a normal deploy
npx @openartifacts/cli init node-api
npx @openartifacts/cli deploy ./node-api --slug my-node-api

Then: Try curl <url>/api/hello?name=agent and curl -X POST <url>/api/echo -d '{"hello":"world"}'. Add routes in server.mjs.

Call it

curl -s <url>/                         # name, Node version, routes
curl -s "<url>/api/hello?name=agent"   # {"message":"Hello, agent!"}
curl -s -X POST <url>/api/echo -H 'content-type: application/json' -d '{"hello":"world"}'
curl -s <url>/api/time

Errors are JSON {"code": "...", "message": "..."} with a 4xx or 5xx status.

Environment

None needed. The platform sets PORT (the server listens on 0.0.0.0:$PORT) and OA_URL (this service's public URL). Add your own with oa env set <slug> KEY=value or PUT /v1/artifacts/<slug>/env, and read them from process.env.

Extend it

What it costs

Prices for small, the size this template needs (current prices on openartifacts.sh):

Starting it needs an hour of awake time in credit ($0.03), and an account runs one service per $1 of balance.

Files

Every file, as JSON you can edit and publish: GET /v1/templates/node-api.


← all templates · openartifacts.sh · docs.md · skill.md