Hello world connector
Here is the traditional hello world code, but for a connector!
If you run it, you will see the hello world message in the standard output as a JSON string. The cozy stack can interpret those messages and this will be useful later.
If you want to run this connector outside tech.io, this is not hard either provided you have NodeJS 6 or better installed :
Create a directory, then run :
npm init npm install cozy-konnector-libs
index.js file in this directory and put the code of the connector in it.
Then run :
Your hello world konnector should work!
BaseKonnector ( fetch, options )
This connector does not do much, but it is the occasion to learn about the features of the BaseKonnector:
- Every connector must inherit from the
- It fetches the information about the linked account in the cozy (or in
./konnector-dev-config.jsonin standalone mode)
- It calls the function passed as argument in its constructor with an object argument containing all the parameters for the connector (none is needed this time) after doing all the previous steps and waits for a promise as a return value
You can change the
fields value in
konnector-dev-config.json and see that it is passed as first argument in the init function.
log ( type, message, label )
type: Can be
debug. There is a color associated to each type.
messageis the item we want to log and can be of any type which can be JSON.stringified.
labelis optional and must be a string
production, messages are outputted in JSON. The
cozy-stackcan interpret certain logs to show information to the user while the konnector fetches data
standalone, it outputs colored text 🌸