Skip to content

Meteor smartpackage which provides a api accessible via DDP to evaluate expressions, watch expression results or execute server helpers and publish the result/log.

License

Notifications You must be signed in to change notification settings

gandev/meteor-server-eval

Repository files navigation

meteor-server-eval

meteor add gandev:server-eval

meteor smartpackage which provides a client api to evaluate expressions on a meteor server. This package was created to use with meteor-server-console.

server-eval is meant to be a development tool and therefore utilizes the debugOnly flag, so meteor doesn't put it in production!

API

  • exports: "ServerEval" symbol which provides the following functions:

    • .results() returns a Meteor.Collection cursor with all evaluation results
    • .metadata() returns a Meteor.Collection cursor with various infos like a list with supported packages
    • .watch() returns a Meteor.Collection cursor with evaluation results identified by watches
    • .eval(expression, options) calls "eval" function with the given expression and options:
      • package: "your-package to use as scope",
      • watch: true to create or update a watch,
      • ignore_size: true to ignore the 5MB result object limit
      • autocomplete: true if eval for autocomplete, runs _.keys(expr),
      • search: ... / eval with autocomplete true only return keys starting with this string
    • .removeWatch(id) remove watch by id
    • .clear() removes all evaluation results
    • .execute(command, scope, args) execute helper (command) function with given arguments array or executes command with node child_process.exec (scope is used to execute in package folder)
  • the .eval, .clear and .removeWatch functions are realized with it's corresponding Meteor.methods (same args):

    • 'serverEval/eval'
    • 'serverEval/removeWatch'
    • 'serverEval/clear'
    • 'serverEval/execute'

Caveat

  • Unfortunately, to use the package scope functionality you have to add following code snippet to your package:

     Custom.__serverEval = function(expression) {
          return eval(expression);
     };
    

    Custom has to be a arbitrary server api.export('...') in your package.js Package.on_use(function(api){})

    maybe if pull request meteor/meteor#1207 or something like this is implemented i can create a source handler plugin to add it automatically.

About

Meteor smartpackage which provides a api accessible via DDP to evaluate expressions, watch expression results or execute server helpers and publish the result/log.

Resources

License

Stars

Watchers

Forks

Packages

No packages published