lunaria-api
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

lunaria-api

GitHub release (latest by date) GitHub Workflow Status License

A Node API client for the video game Lunaria.

Lunaria is a video game for programmers, and is played by writing code that interacts with the game through a gRPC API. This package contains a gRPC client that is auto-generated from the Protocol Buffers that declare Lunaria's API.

Getting Started

First, add lunaria-api as a new dependency to your project:

npm install lunaria-api

The following TypeScript example shows how to initialize a new API client and query the version of the running game. For a full list of available API calls, check out the specification of Lunaria's API:

https://github.com/playlunaria/lunaria-api/tree/main/protobufs

import {
  GetVersionRequest,
  GetVersionResponse,
  LunariaServiceClient,
} from "lunaria-api";
import * as grpc from "@grpc/grpc-js";

// Initialize a new API client
const lunaria = new LunariaServiceClient(
  "127.0.0.1:1904",
  grpc.credentials.createInsecure()
);

// Initialize the request payload
const request = new GetVersionRequest();

// Asynchronously send the request and process the response in a callback
lunaria.getVersion(request, (err, response: GetVersionResponse) => {
  const version = response.getVersion();

  if (version != undefined) {
    const versionString = [
      version.getMajor(),
      version.getMinor(),
      version.getPatch(),
    ].join(".");

    console.log(`Lunaria is running version ${versionString}`);
  }
});

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Readme

Keywords

Package Sidebar

Install

npm i lunaria-api

Weekly Downloads

1

Version

0.2.1

License

(MIT OR Apache-2.0)

Unpacked Size

41.6 kB

Total Files

11

Last publish

Collaborators

  • jdno