This is a client library to work with the Missions Service of rescueTABLET. It allows you to create, update, delete and retrieve missions as well as subscribe to real-time updates.
Sorry for the lack of documentation, this is a work in progress.
Caution
This library is still under heavy development. Until we've reached a stable 1.0.0 version, please expect breaking changes even in minor releases.
Add the following line to .npmrc in your project directory (create the file if it doesn't exist yet):
@rescuetablet:registry=https://npm.pkg.github.com/
Install the library and its peer dependencies in your project:
npm i @rescuetablet/missions-client firebaseimport { createMissionsManager } from "@rescuetablet/missions-client/browser";
const manager = await createMissionsManager();
await manager.authorize(missionsApiKey);import { createMissionsManager } from "@rescuetablet/missions-client/browser";
import {
useMissions,
useMissionsUser,
MissionsContextProvider,
} from "@rescuetablet/missions-client/react";
// create the manager as described above
// const manager = …
export default function App() {
return (
<MissionsContextProvider manager={manager}>
<Main />
</MissionsContextProvider>
);
}
function Main() {
const missions = useMissions();
const user = useMissionsUser();
return <pre>{JSON.stringify({ missions, user }, null, 2)}</pre>;
}We export all types used in the API. You can import them like this:
import { type Mission } from "@rescuetablet/missions-client";We provide a Hey API implementation to interact with the API. Use manager.getClientOptions() to get the client configuration including base URL, user agent and API token.
import { createMission } from "@rescuetablet/missions-client/client";
// create the manager as described above
// const manager = …
await createMission({
...manager.getClientOptions(),
data: {
keyword: "TEST",
message: "Test Mission",
// more mission data
},
throwOnError: true,
});The manager object provides a way to subscribe to real-time updates. You can listen to changes in missions like this:
manager.on("mission_added", (mission) => {
console.log("Mission updated", mission);
});This library is provided as is under an MIT license by rescueTABLET.