plugins: added getConnections and events to api
Massimo Melina committed
Apr 25, 2022 at 22:11 UTC
aa19c30c95df352161a0f8e6fdf800cc57e8bfb3
2 files changed
+8
-1
README.md
+5
-1
@@ -177,7 +177,11 @@ The `api` object you get as parameter of the `init` contains the following:
177
- `getConfig(key: string): any` get config's value set up by using `exports.config`.
178
179
- `const: object` all constants of the `const.ts` file are exposed here. E.g. BUILD_TIMESTAMP, API_VERSION, etc.
180
-
180
+
181
+ - `getConnections: Connections[]` retrieve current list of active connections.
182
+
183
+ - `events: EventEmitter` this is the main events emitter used by HFS.
184
+
185
- `srcDir: string` this can be useful if you need to import some extra function not available in `api`.
186
```js
187
exports.init = api => {
server/src/plugins.ts
+3
@@ -15,6 +15,7 @@ import { serveFile } from './serveFile'
15
import events from './events'
16
import { readFile } from 'fs/promises'
17
import { existsSync, mkdirSync } from 'fs'
18
+import { getConnections } from './connections'
19
20
const PATH = 'plugins'
21
@@ -176,6 +177,8 @@ async function rescan() {
177
srcDir: __dirname,
178
const: Const,
179
require,
180
+ getConnections,
181
+ events,
182
getConfig: (cfgKey: string) =>
183
getConfig(CFG_PLUGINS_CONFIG)?.[id]?.[cfgKey]
184
})