Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/digital-alchemy-ts/gotify
Rest API bindings for gotify
https://github.com/digital-alchemy-ts/gotify
automation digital-alchemy gotify home-automation nodejs notifications typescript
Last synced: about 2 months ago
JSON representation
Rest API bindings for gotify
- Host: GitHub
- URL: https://github.com/digital-alchemy-ts/gotify
- Owner: Digital-Alchemy-TS
- License: mit
- Created: 2024-03-09T18:43:02.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-04-15T02:00:35.000Z (9 months ago)
- Last Synced: 2024-06-08T16:19:55.724Z (7 months ago)
- Topics: automation, digital-alchemy, gotify, home-automation, nodejs, notifications, typescript
- Language: TypeScript
- Homepage: https://docs.digital-alchemy.app/Gotify
- Size: 375 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# 📨 Welcome to the Gotify Adapter Library
- [Extended docs](https://docs.digital-alchemy.app)
- [Discord](https://discord.gg/JkZ35Gv97Y)This library acts as a simple set of REST adapters for Gotify, primarily used for emitting messages from your application.
## ⚙️ Configuration
- **`BASE_URL`**: Target server for API.
- **`CHANNEL_MAPPING`**: Map tokens to friendly names to use within the application.```ini
[gotify.CHANNEL_MAPPING]
app_name=token
another_app=token
app_the_third=token
```- **`TOKEN`**: Application token.
## 🛠 Services
- **`application`**
- **`client`**
- **`message`**## 🌐 Multi-channel Type-friendly Messages
> Create a wrapper to send messages from a particular application, using the correct credentials, and quick to type.
```typescript
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>),
};
}
```> Send messages:
```typescript
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)}`,
});
})
}
```