Meteor smartpackage which provides a api accessible via DDP to evaluate expressions, watch expression results or execute server helpers and publish the result/log.
JavaScript
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.md
eval.js
git_helpers.js
helpers.js
license.md
package.js
result_format.js
versions.json

README.md

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 https://github.com/meteor/meteor/pull/1207 or something like this is implemented i can create a source handler plugin to add it automatically.