Skip to main content

Local installation

Requirements

  • Install Node.js (version 22 or higher recommended) on your machine.
  • Create a new project with npm init
  • Set your project to be an ES module : npm pkg set type="module"
  • Install typescript in your project npm i --save-dev typescript
  • Install tsx for debugging purpose : npm i --save-dev tsx
  • Install orbits and fuel : npm i @orbi-ts/core @orbi-ts/fuel

Test with Docker-compose

Copy the following docker-compose.yml file into your project folder:

docker-compose.yaml
services:
mongodb:
image: mongo
restart: unless-stopped
ports:
- "27017:27017"
command: ["--replSet", "rs0", "--bind_ip_all"]
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 2s
timeout: 3s
retries: 5
volumes:
- /tmp/orbits/mongo-data:/data/db

mongo-init:
image: mongo
depends_on:
mongodb:
condition: service_healthy
entrypoint: ["mongosh", "--host", "mongodb", "--eval", "rs.initiate({_id: 'rs0', members:[{_id:0, host:'localhost:27017'}]})"]

nodejs:
image: node:22-slim
working_dir: /app
volumes:
- ./:/app
environment:
- ORBITS_MONGO__URL=mongodb://localhost:27017/orbits?replicaSet=rs0
command: ["npx", "tsx", "index.ts"]
depends_on:
- mongodb

volumes:
mongo-data:

Run with:

docker compose up

Modify your source codes and then relaunch the node container :

docker compose down nodejs
docker compose up nodejs

Test without docker-compose

Local mongodb

Install MongoDB locally following the official guide for your OS.

External MongoDB

Set the environment variable ORBITS_DB__MONGO__URL to point to your MongoDB cluster URI before running the app:

export ORBITS_DB__MONGO__URL="mongodb+srv://...."
npx tsx index.ts