Hey, y'all! I built a Flarum REST API client for TypeScript. It's got all the basics for you to retrieve forum data on your websites or in the server (the package is runtime-agnostic) :)
Install with your favorite package manager:
# My favorite is pnpm
pnpm add flarum-api-client
And use!
import FlarumAPIClient from 'flarum-api-client';
const client = new FlarumAPIClient('https://example.com');
client.discussions.getAll().then(discussions => {
console.log(discussions)
});
It's definitely still a WIP so there might be some issues. Let me know if anything comes up and I'll fix it asap! I did my best to ensure it's fully typed as well so it should have a pretty good DX.
Repo: OrdinaryJellyfish/flarum-api-client.js
I know there are some CORS issues when used in the browser for some specific request types, which I am actively trying to figure out. Oddly enough CORS headers aren't always set...even when I explicity do so in either a custom middleware or my server config 🤔 I did get zero sleep last night so I'm probably just braindead atm