Skip to content

MODEX HCloud SDK Update v1.3

Choose a tag to compare

@TahierJerr TahierJerr released this 22 Apr 13:56
· 7 commits to main since this release

Modex HCloud SDK

A TypeScript SDK for interacting with the [Hetzner Cloud API](https://docs.hetzner.cloud/), designed for internal use by MODEX services. Built for performance, type-safety, and simplicity.


🚀 What’s New in v1.3

✨ Features

  • 🆕 getDatacenter + getDatacenters

    • Fetch individual datacenter info
    • Filter, sort, and paginate across datacenters
    • Returns full location + server_types support
  • 🆕 sshIntoServer

    • Execute commands over SSH using node-ssh
    • Automatically handles connection, command, and cleanup
    • Can be used to provision servers post-creation
  • → serverTypes functions have been moved to sdk/servers/server-type/

    • Cleaner structure
    • Better grouping with related server actions

✅ Test Coverage

  • Full integration tests for:
    • getLocation, getLocations
    • getDatacenter, getDatacenters
    • sshIntoServer (with mocks)

📆 Installation

npm install @modex/hcloud

🧠 Usage

Get a Location

const location = await hcloud.locations.getById(1)
console.log(location.city) // "Nuremberg"

List Datacenters

const { datacenters, meta } = await getDatacenters({ per_page: 10 })

SSH Into Server

const { stdout } = await sshIntoServer("192.168.1.100", "apt update && apt upgrade -y", "root")
console.log(stdout)

💡 Requires SSH_PRIVATE_KEY in your environment


📁 File Structure (partial)

sdk/
├── locations/
│   └── datacenters/
│       ├── getDatacenters.ts
│       └── getDatacenter.ts
├── servers/
│   ├── actions/
│   │   └── sshIntoServer.ts
│   └── server-type/
│       ├── getServerTypes.ts
│       ├── getServerType.ts
│       └