Skip to content

Evaluate's javascript and returns a JSON object using Node

Notifications You must be signed in to change notification settings

weepy/node_eval

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Node Eval

Allows arbitrary javascript to be evaluated using V8. This is mostly useful for other servers to evaluate javascript, without needing a direct bridge.

/eval?js=12*12 => {"success":true,"result":144}

/eval?js=12*a => {"success":false,"exception":"ReferenceError: a is not defined"}

Context is maintained

/eval?js=this.a=9 => {"success":true,"result":null}

/eval?js=12*a => {"success":true,"result":108}

It's also possible to supply a source file on disk and a context name:

/eval?js=func()&file=/abs/path/to/file => {"success":true,"result": "func output ok"}

Note that to be able to call functions, you'll need to expose them using the CommonJS "exports" declaration.

Todo

Unfortunately, require seems to only load the file once, meaning that currently there can only be one context per file

About

Evaluate's javascript and returns a JSON object using Node

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published