Skip to content
Ninja Cloud · Quickstart

Deploy your first service

Take a small Node service from your machine to a running, observable deployment on Ninja Cloud. About ten minutes, start to finish.

Command reference is provisional

The workflow below is the intended path, but some exact command names, flags, and package identifiers are still being finalised. Anything unverified is marked with a TODO. Check ninjacloud --help for your CLI version, or ask the team, before scripting it into CI.

What you will build

A single HTTP service that answers GET /healthz with a JSON health payload and returns a greeting on every other path. You will deploy it, then confirm it is healthy and streaming logs.

Prerequisites

  • A Ninja Cloud account with permission to create services.
  • Node.js 20 LTS or newer, with npm.
  • A terminal and about ten minutes.

1. Install the CLI

Install the CLI globally and confirm it resolves on your PATH.

bash
# Requires Node.js 20 LTS or newer.
# TODO(platform): confirm the published npm package name for the CLI.
npm install --global @ninjacloud/cli

# Confirm the binary is on your PATH.
ninjacloud --version

2. Authenticate

Log in interactively, or mint a scoped token for automation. The CLI stores credentials locally for interactive use.

bash
# Opens a browser to complete device authorisation.
ninjacloud login

# For CI, create a scoped token instead of logging in interactively.
# TODO(platform): confirm token scopes and flag names.
ninjacloud auth token create --scope deploy

In CI, pass the token through the environment rather than committing it.

bash
# Keep tokens out of source control — export them in your shell or CI secrets.
export NINJACLOUD_TOKEN="<token>"   # TODO(platform): confirm the environment variable name.

3. Create the service

Create a project directory and add a minimal service. This example uses the Node.js standard library only, so there is nothing to install.

terminalbash
mkdir my-first-service
cd my-first-service
server.tsts
import { createServer } from "node:http";

const port = Number(process.env.PORT ?? 8080);

createServer((request, response) => {
  if (request.url === "/healthz") {
    response.writeHead(200, { "content-type": "application/json" });
    response.end(JSON.stringify({ status: "ok" }));
    return;
  }

  response.writeHead(200, { "content-type": "text/plain" });
  response.end("Hello from Ninja Cloud\\n");
}).listen(port, () => {
  console.log("listening on :" + port);
});

Add a manifest so the deploy knows the runtime and the port to expose.

ninja.yamlyaml
# TODO(platform): confirm the manifest filename, schema, and field names.
service: my-first-service
runtime: nodejs20
port: 8080

4. Deploy it

Deploy the service into a region close to your users. Ninja Cloud builds the image, provisions the service, and routes traffic behind a stable hostname.

bash
# TODO(platform): confirm region identifiers and deploy flags.
ninjacloud deploy --service my-first-service --region <region>
text
# Illustrative output — exact wording varies by CLI version.
Building image ......... done
Provisioning service ... done
Routing traffic ........ done
Service ready: https://my-first-service.<region>.ninjacloud.example

5. Observe it

Logs and health are wired in from the first deploy. Confirm the service is healthy, then stream its output while you send it a request.

bash
# Stream logs from the running service.
# TODO(platform): confirm the log subcommand and flags.
ninjacloud logs --service my-first-service --follow

# Check health and the most recent deploy.
ninjacloud status --service my-first-service
text
# Illustrative output.
my-first-service   healthy   region: <region>   replicas: 2
latest deploy      succeeded   2m ago

From another terminal, request the health endpoint:

bash
curl https://my-first-service.<region>.ninjacloud.example/healthz
# {"status":"ok"}

6. Clean up

Delete the service when you are done so it stops billing. Deploys are reversible; deleting is the one action that is not.

bash
# Remove the service when you are finished.
# TODO(platform): confirm the delete command.
ninjacloud service delete my-first-service

Next steps