npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mastodon-connector

v0.0.1

Published

Connect to several Mastodon-API-servers from a config-file.

Downloads

4

Readme

mastodon-connector

A wrapper for the Node.js-package "mastodon-api" to get started quickly writing apps, which want to eat Fediverse-APIs.

What

  1. Initialize API-consuming fediverse-apps from a config-file.

  2. If no access_token is given, get it by passing a user's account-password, or use a dummy-string, if you want to use public API-methods.

  3. Use mastodon-api to provide listen- and send-functions in an FediApp.

  4. Write freshly obtained access_tokens to file and remove passwords.

Why

  1. Fastest way to get started with developing FediApps.

  2. Much less time-consuming than getting access_tokens via a webbrowser and traveling over several pages. No copy'n'pasting, no mouse harmed.

  3. Take advantage of mastodon-api and provide some shortcut-wrappers.

  4. Store access_tokens permanently for re-use and remove passwords for security reasons.

How

Provide a config-file in JSON-format with this structure:

[
    {
        "server": "https://social.tchncs.de",
        "username": "[email protected]",
        "password": "yourSuperSecretPassword"
    }
  ,
    {
        "server": "https://social.nasqueron.de",
        "username": "[email protected]",
        "access_token": "092u37eg26bet2g2z2bv2tr1fwz2dkdu3zi7rd02i2jgslw9"
    }
  ,
    {
        "server": "https://social.example.com",
        "username": "[email protected]",
        "access_token": "arbitraryNonEmptyStringForUsingPublicApiFuncs"
    }
]

Then in one of your app's script, do:

const FediApps = require('mastodon-connector').FediApps

const callback = app => console.log('Ready to eat API of', app)

const filepath = 'config.json'

const fediapps = new FediApps(filepath, callback)

The callback-function is what you want to extend for further usage. Here's an example using an app's listen-function:

const msgHandler = msg => console.log(msg)

const callback = app => app.listen('public', msgHandler)

You can pass another callback, executed after all apps were initiated:

const afterAll = (apps) => {

  for(let i in apps) apps[i].send('A message send to all accounts')

}

new FediApps(filepath, callback, afterAll)

Author

Ida Ebkes, 2019.

License

MIT, a copy is attached.

Contact

For bug-reports, questions and everything, please add an issue in the repository:

https://github.com/ida/fediapps/issues

Credits for merits

Huge thanks go to:

  • The "mastodon-api"-package for paving the way to stream-listening and sending posts, written by Eliah Winkler, a.k.a. "vanita5".

  • The packages "mastodon-register-app" and "mastodon-get-token" written by Sandro Hawke, for giving guidance on how to obtain an access_token via password-authentication.