SignalK / signalk-server

An implementation of a Signal K central server for boats.
http://signalk.org
Apache License 2.0
321 stars 156 forks source link

Support plugin development in TypeScript #1516

Closed tonybentley closed 1 year ago

tonybentley commented 1 year ago

The interface required for developing a plugin in typescript is buried in the signalk-server package.

Steps to reproduce:

Create a separate plugin GitHub project, and implement typescript. When exporting the default method as specified in the plugin documentation, include the app parameter and interface.

import { ServerAPI } from 'signalk-server/lib/interfaces/plugins';

module.exports = (app: ServerAPI) => { 
...
}

Solution: abstract public interfaces into a type definitions

tkurki commented 1 year ago

I'm all for it! Can you lend a hand?

There's actually a start for this already: https://github.com/SignalK/signalk-server/tree/master/packages/server-api is the module @signalk/server-api.

There's just a minimal Plugin signature https://github.com/SignalK/signalk-server/blob/master/packages/server-api/src/index.ts#L26-L57.

We should move things around so that plugins.ts uses all this https://github.com/SignalK/signalk-server/blob/master/packages/server-api/src/index.ts#L26-L57 from the server-api module and at least most of the stuff here https://github.com/SignalK/signalk-server/blob/master/packages/server-api/src/index.ts#L26-L57 is moved to server-api.