Skip to content

Bun Bun

You can use the following bunfig.toml to install the dependencies from the buf.build registry.

toml
[install.scopes]
"@buf" = "https://buf.build/gen/npm/v1/"

To install dependencies:

bash
bun add @buf/minekube_gate.connectrpc_es@latest
bash
pnpm add @buf/minekube_gate.connectrpc_es@latest
bash
npm install @buf/minekube_gate.connectrpc_es@latest
bash
yarn add @buf/minekube_gate.connectrpc_es@latest

Refer to the ConnectRPC documentation for more information on how to use ConnectRPC with TypeScript on server side.

Browser support

To use the Gate API in the browser, check out the Web documentation.

ts
import { createClient } from '@connectrpc/connect';
import { createConnectTransport } from '@connectrpc/connect-node';
import { GateService } from '@buf/minekube_gate.connectrpc_es/minekube/gate/v1/gate_service_connect';

const transport = createConnectTransport({
  httpVersion: '1.1',
  baseUrl: 'http://localhost:8080',
});

async function main() {
  const client = createClient(GateService, transport);
  const res = await client.listServers({});
  console.log(JSON.stringify(res.servers, null, 2));
}
void main();

Sample project

This sample project is located in the docs/developers/api/typescript/bun directory.

To install dependencies:

bash
bun install

To run:

bash
bun run index.ts
[
  {
    "name": "server1",
    "address": "localhost:25566",
    "players": 0
  },
  {
    "name": "server2",
    "address": "localhost:25567",
    "players": 0
  },
  {
    "name": "server3",
    "address": "localhost:25568",
    "players": 0
  },
  {
    "name": "server4",
    "address": "localhost:25569",
    "players": 0
  }
]

This project was created using bun init in bun v1.1.26. Bun is a fast all-in-one JavaScript runtime.

Released under the Apache 2.0 License. (web version: ffedb830)