-
Notifications
You must be signed in to change notification settings - Fork 2
feat: typescript and tests #9
base: master
Are you sure you want to change the base?
Conversation
adrianhopebailie
commented
Sep 11, 2018
- update to TypeScript
- add tests and coverage
- deprecate inconsistent behaviour
Codecov Report
@@ Coverage Diff @@
## master #9 +/- ##
=========================================
Coverage ? 75.67%
=========================================
Files ? 1
Lines ? 37
Branches ? 12
=========================================
Hits ? 28
Misses ? 4
Partials ? 5
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just two minor comments
README.md
Outdated
run() | ||
``` | ||
|
||
If no parameters are provided it will attempt to find the config in environment variables. If these are not found it will load a plugin that attempts to connect to a local moneyd instance on port 7768. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link to moneyd
} | ||
export type DataHandler = (data: Buffer) => Promise<Buffer> | ||
export type MoneyHandler = (amount: string) => Promise<void> | ||
export interface PluginInstance extends EventEmitter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this type should just be called Plugin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to get some consistency across all our "module loading" types so I copied the StoreInstance
type name from ilp-connector
.
I also want to avoid using very common names.
Maybe a better convention is IlpPlugin
and IlpStore
etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think having a common name is a problem here because a) you don't need to import this interface b) if you do you're going to use it for the main plugin abstraction and c) if it does conflict with something else you've called Plugin you can always rename it. IlpPlugin seems a little redundant because you're getting it from a module called ilp something so there isn't any ambiguity about the context
ba6afc9
to
323173e
Compare
run() | ||
``` | ||
|
||
If no parameters are provided it will attempt to find the config in environment variables. If these are not found it will load a plugin that attempts to connect to a local [moneyd](../moneyd) instance on port 7768. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant link to the moneyd repo so you can find instructions for running it (right now the link is broken)
use this anywhere that you need an ILP plugin created from details in the | ||
environment. | ||
environment or by specifying the detauls in code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/detauls/defaults
constructor of `ilp-plugin-btp` or the module name in `ILP_PLUGIN`. | ||
TypeScript: | ||
```typescript | ||
import createPlugin, { DataHandler } from '..' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a README example, should it import from ilp-plugin
instead of a relative path?
run() | ||
``` | ||
|
||
If no parameters are provided it will attempt to find the config in environment variables. If these are not found it will load a plugin that attempts to connect to a local [moneyd](../moneyd) instance on port 7768. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe say "connect to a local moneyd instance on port 7768 using ilp-plugin-btp", just to be explicit about the default plugin.
|
||
async function run () { | ||
await plugin.connect() | ||
await plugin.sendData(/* ... */) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this example intended to be runnable? If so, there should be some dummy data here.
"version": "3.2.1", | ||
"description": "> A generic handle to ILP", | ||
"main": "index.js", | ||
"version": "3.2.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's with the version change here?
|
||
export interface PluginServices { | ||
store: any | ||
log: Logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logger
needs to be imported from ilp-logger
.
Could use the latest version of ilp-logger
(which has Typescript) while you're at it.
Is this still active at all? Can it be closed? |