https://github.com/rodentman87/kwp-ts
https://github.com/rodentman87/kwp-ts
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/rodentman87/kwp-ts
- Owner: Rodentman87
- License: mit
- Created: 2023-03-05T22:42:40.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-05T22:42:58.000Z (about 3 years ago)
- Last Synced: 2025-02-01T15:45:02.256Z (over 1 year ago)
- Language: TypeScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# KWP Client
This is a simple TypeScript client implementation for KerbalWebProgram, and provides a simple abstraction over the API's structure.
## Usage
A simple client using the HTTP transport:
```ts
import { KerbalWebProgramClient, HTTPTransport } from "kwp-ts";
const transport = new HTTPTransport("http://localhost:8080");
const client = new KerbalWebProgramClient(transport);
const kerbinData = await client.makeRequest("getCelestialBodyData", {
name: "Kerbin",
});
```
Adding extra method types:
```ts
import {
KerbalWebProgramClient,
HTTPTransport,
BaseApiMethods,
ApiMethodData,
} from "kwp-ts";
interface MyCustomMethod extends ApiMethodData {
name: "myCustomMethod";
parameters: {
param1: string;
param2: number;
};
response: {
data1: string;
data2: number;
};
}
const transport = new HTTPTransport("http://localhost:8080");
const client = new KerbalWebProgramClient(
transport
);
```
## TODO
- [ ] Add tests
- [ ] Add WebSocket transport
- [ ] Types for WebSocket events