Brandon Keepers - @AdrianP Quick question for y...
@AdrianP Quick question for you. I was just looking through the source for your flags plugin to learn from it, and noticed it calls
initFlagsEndpoint
in start
instead of in registerWithRouter
. Can you help me understand why? https://github.com/panaaj/signalk-flags/blob/main/src/index.ts#L1094 Replies
ahh, I might have just realized why. Is it because you wanted to publish the API as
/resources/flags
and not /plugins/flags
? Followup question then: why publish your own endpoints instead of using the resource-provider api? Just curious and wanting to learnCorrect, registerWithRouter roots the endpoint under /plugins (from memory).
The resources API pattern is centred around /resourcetype/id where the responses are json.
Additional sending file contents of different type (i.e. svg file contents) breaks this pattern hence stepping outside.
Makes sense. I like the pattern though of still nesting it under resources.
Resources is a broad category so it's a good place to put things that don't go in the data model.