您最多能選擇 25 個主題 主題必須以字母或數字為開頭,可包含連接號 ('-') 且最長為 35 個字。
 
garrettmills 444a1b3b20 Unit tests, final implementation, README 10 個月前
src Unit tests, final implementation, README 10 個月前
test/unit Unit tests, final implementation, README 10 個月前
.gitignore Unit tests, final implementation, README 10 個月前
README.md Unit tests, final implementation, README 10 個月前
index.js Unit tests, final implementation, README 10 個月前
package.json Unit tests, final implementation, README 10 個月前
yarn.lock Unit tests, final implementation, README 10 個月前

README.md

flitter-gotify

Flitter Gotify is a service wrapper for interacting with Gotify notification gateways from the Flitter application framework. It provides a standard notify service that can be used to send notifications to a Gotify app, or to any number of groups of apps, as configured.

Usage

Install & Setup

Install Flitter Gotify in your Flitter application:

yarn add flitter-gotify

The, add the NotifyUnit to your Units.flitter.js file. This line should go in the "Pre-Routing Custom Units" section, so it is available to the main routing stack during boot:

const Units = {
    // ... other Units ...
    'Notify'        : require('flitter-gotify/src/unit/NotifyUnit'),
    // ... other Units ...
}

Now, run the deployment script to add the notify config template to your application:

./flitter deploy notify

Configuration

The notify deployment creates the configs/notify.config.js file in your application. Here, you can fill in the information for your Gotify server and app keys. By default, Flitter Gotify will use the "default" channel group. You can create additional channel groups by adding to the groups object to provide a name and an array of app keys associated with that group.

You can also set the default values in your .env file:

GOTIFY_HOST="https://your.gotify.url/"
GOTIFY_DEFAULT_APP_KEY="super-secretappkey"

Sending Notifications

Once configured, you can send notifications to the various channels using the notify service in your application. Here are a few examples:

// app/controllers/Some.controller.js
const Controller = require('libflitter/controller/Controller')

class SomeController extends Controller {
    static get services() {
        return [...super.services, 'notify']
    }

    async example_endpoint(req, res, next) {
        // Send a message to the default group:
        await this.notify.send('My Title', 'This is a custom notification message!')

        // Send a message with a different priority (default is 5)
        await this.notify.send('My Title', 'A less important message', 3)

        // Send a message to a different channel group
        await this.notify.send('Uh, oh!', 'This is a critical error!', 9, 'admins')

        return res.api('Messages sent!')
    }
}

Testing

To run the unit tests for Flitter Gotify:

yarn install
yarn run test_units

License

Copyright © 2020 Garrett Mills

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.