Package Idea: validated-publication

I’ve been using mdg:validated-method (https://github.com/meteor/validated-method) and really loving it. I like how it forces you into using best-practices. I think we should do the same thing for publications.

Ideas:

  • Would define Meteor.validatedPublication
  • name
  • validate: validate using SimpleSchema
  • maxLimit: prevent over-fetching data
  • userRequired: calls this.ready() if user not logged-in
  • permissionCheck: calls this.ready() if returns false
  • wrap https://github.com/englue/meteor-publish-composite?
  • stretch goals - query builder, REST?

Do you think this package would be useful? Any ideas about how it might work?

4 Likes

Hey, glad you like the package!

There’s one thing I’ve realized when building ValidatedMethod - it’s not really possible to anticipate all of the extensions and wrapper packages up front. For pub/sub, you might want some or all of the following:

Server:

  1. Publish composite
  2. Reactive publish
  3. Argument validation
  4. Permissions
  5. REST

Client:

  1. Subs manager
  2. Template subscriptions

Basically, I think both Methods and Publications/Subscriptions need some sort of mixin/extension system, much like React components have mixins. That way, you can mix and match the different functionality you need, and it can be published by different people rather than having to be built into the core package itself.

Also, I wouldn’t attach it to Meteor.validatedPublication - probably a top-level symbol, or in 1.3 it would just be a module - import ValidatedPublication from 'validated-publication'.

1 Like

This idea just came to my head! Did you make any progress with it?

2 Likes

Since the last post, I added a mixin system for ValidatedMethod and it seems to be working well!

2 Likes