@samitouri / QOSami-HFS / commits / 1d6de4a5

doc: backend/frontend distinction for plugins

Massimo Melina committed Oct 29, 2024 at 11:37 UTC 1d6de4a537512c43369e0967800da5986cf94605
2 files changed +5 -1
dev-plugins.md
+4
@@ -11,6 +11,10 @@ Each plug-in has access to the same set of features.
11 Normally you'll have a plug-in that's a theme, and another that's a firewall,
12 but nothing is preventing a single plug-in from doing both tasks.
13
14 +## Backend / Frontend
15 +
16 +Plugins can run both in backend (the server) and frontend (the browser). Frontend files reside in the "public" folder, while all the rest is backend.
17 +
18 ## Exported object
19 `plugin.js` is a javascript module (executed by Node.js), and its main way to communicate with HFS is by exporting things.
20 For example, it can define its description like this
src/nat.ts
+1 -1
@@ -67,7 +67,7 @@ export const getNatInfo = debounceAsync(async () => {
67 const res = await haveTimeout(10_000, upnpClient.getGateway()).catch(() => null)
68 const status = await getServerStatus()
69 const mappings = res && await haveTimeout(5_000, upnpClient.getMappings()).catch(() => null)
70 - console.debug("mappings found", mappings?.map(x => x.description) || "none")
70 + console.debug("mappings found", mappings?.map(x => x.description).join(', ') || "none")
71 const localIps = await getIps(false)
72 const gatewayIp = await gatewayIpPromise
73 const localIp = res?.address || (gatewayIp ? _.maxBy(localIps, x => inCommon(x, gatewayIp)) : localIps[0])