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@latestbash
pnpm add @buf/minekube_gate.connectrpc_es@latestbash
npm install @buf/minekube_gate.connectrpc_es@latestbash
yarn add @buf/minekube_gate.connectrpc_es@latestRefer 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 installTo 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.
