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

hono-stremio

v0.1.1

Published

A third-party Stremio Addon middleware for Hono

Downloads

23

Readme

hono-stremio

Easily build Stremio addons using Hono. Write your code once and deploy it to any platform supported by Hono, such as Cloudflare, Fastly, Deno, Bun, AWS, and more.

This package is compatible with the stremio-addon-sdk interface, thus requiring zero to minimal changes to integrate your existing Stremio addon.

:zap: Quickstart

  1. Create a new Hono project (if you haven't already) and install the package:
$ npm create hono@latest my-app
$ npm i hono-stremio
  1. Get the addon interface:

ESM:

// addon.js
import addonBuilder from 'stremio-addon-sdk/src/builder'
import landingTemplate from 'stremio-addon-sdk/src/landingTemplate'

const builder = new addonBuilder({
  // ...
})

builder.defineStreamHandler(function (args) {
  // ...
})

const addonInterface = builder.getInterface() /// <--- get the interface
const landingHTML = landingTemplate(addonInterface.manifest) // (optional) Generate landing page HTML. You can also provide your own HTML if you prefer.

CJS:

// addon.js
const addonBuilder = require('stremio-addon-sdk/src/builder')
const landingTemplate = require('stremio-addon-sdk/src/landingTemplate')

const builder = new addonBuilder({
  // ...
})

builder.defineStreamHandler(function (args) {
  // ...
})

const addonInterface = builder.getInterface() /// <--- get the interface
const landingHTML = landingTemplate(addonInterface.manifest) // (optional) Generate landing page HTML. You can also provide your own HTML if you prefer.

[!NOTE]
The addon builder MUST be imported by its full relative path stremio-addon-sdk/src/builder, as shown above. This is required to ensure compatibility with all of Hono's supported platforms. See the FAQ below for more information.

  1. Connect the stremio router to your Hono app:
// index.ts
import { Hono } from 'hono'
import { getRouter } from 'hono-stremio'

// ...

const addonRouter = getRouter(addonInterface, { landingHTML })

const app = new Hono()

app.route('/', addonRouter)

export default app

That's it! You can now deploy your Stremio addon to any platform supported by Hono. Follow the Hono documentation to learn more.

:question: FAQ

Why do I need to import the addon builder by its full relative path?

The Stremio Addon SDK still uses the old module.exports and require syntax (i.e. CJS) which is not natively supported by all Hono platforms. The main issue here is that most (if not all) platforms are already using the new ES Module standard (ESM) by default. While CJS modules can be imported from ESM, there's no named exports but only a default-exported object. Thus, when importing from the package entrypoint (index.js) you are importing all of the code contained in the package including Node-specific code that will not work on other platforms.

By importing the addon builder by its full relative path, you are basically hand-picking the necessary module from the package, without the additional clutter from the entrypoint. This is a temporary workaround until the Stremio Addon SDK is updated to use ESM.

If you have any suggestions or ideas on how to improve this, please open an issue to discuss! I would love to hear your thoughts.