Open bopjesvla opened 8 years ago
Ultimately, we have the fallback of allowing the user complete control by importing horizon as a library. I think if you're interested in the different between size and speed of json-schema parsing libraries, then you're in the realm of writing your own custom backend. The default backend should focus on working for 80% of use cases and allowing the user to take over once it isn't sufficient
I think if you're interested in the different between size and speed of json-schema parsing libraries, then you're in the realm of writing your own custom backend.
That particular comment was about document validation on the client. And yeah, it wasn't the best example. The first and the last one are more important.
A slightly more concrete proposal that depends on #345:
[plugins.X]
in config.toml
is required and called with the horizon instance and config options. This can also be done programmatically from server.js
.server.js
can hook into.I'll expand on why I think auth and validation should be implemented as plugins later, but I'd like to hear your thoughts on this first.
Disorganised notes:
Two more things:
Linking the work-in-progress RFC for Horizon plugins: https://github.com/rethinkdb/horizon/pull/588
Reading through the discussion on document validation, it seems to me that if everything is implemented as a fixed API, horizon will only be used by people with specific use cases.
I don't think document validation should be part of the core, for the simple reason that no one solution will suit every app. You might be thinking about storing the schemas in the database. What if I want to validate login information before the web socket is opened? The schemas might be read from JSON files. What if I want to use YAML? You might pick ajv as the json-schema implementation because it's fast. What if I want to use jsen because it's three times as small? What if my app doesn't need any fancy APIs whatsoever, and I'm just using horizon for the realtime feeds?
This is what I imagine a document validation plugin would look like:
An auth plugin:
Plugin configuration would be done in config.toml and/or a configuration module like webpack's config.js.