Gotify
https://gotify.net/ Gotify is a simple server for sending & receiving messages
Welcome to @digital-alchemy/gotify-extension!
💾 Install
This library can be installed as a simple dependency
npm i @digital-alchemy/gotify-extension
Then added to your project
import { LIB_GOTIFY } from "@digital-alchemy/gotify-extension";
// application
const MY_APP = CreateApplication({
  libraries: [LIB_GOTIFY],
  name: "home_automation",
})
// library
export const MY_LIBRARY = CreateLibrary({
  depends: [LIB_GOTIFY],
  name: "special_logic",
})
🎉 Listing as an import will automatically load into
LoadedModulesand make the library features available asgotifyonTServiceParams.
Services
applicationclientmessage
Multi-channel type friendly messages
Create a wrapper to send messages from a particular application. Uses the correct credentials, and quick to type
enum MyGotifyApps {
  testing = "testing",
  reminders = "reminders",
}
export function MyGotifyServices({ gotify, config }: TServiceParams) {
  return {
    ...(Object.fromEntries(
      Object.values(MyGotifyApps).map(i => [
        i,
        async (message: Message) => {
          await gotify.message.create({
            ...message,
            appid: config.gotify.CHANNEL_MAPPING[i],
          });
        },
      ]),
    ) as Record<`${MyGotifyApps}`, (message: Message) => Promise<void>>),
  };
}
Send messages
export function MyService({ app, lifecycle, internal }: TServiceParams) {
  lifecycle.onReady(async() => {
    await app.gotify.reminders({
      message: `Failed to create countdown timer for ${internal.utils.relativeDate(target)}`,
    });
  })
}