0

I don't even know how to call it!

I just wanna make a platform (just for fun and knowledge) for tabletop RPG when my user's can automate rolls, character sheets and so. I was inspired by the Macro system of MapTools and Roll20 and the script system of RPGMaker.

But I don't have idea how to make my node app read a text sent by the user, read it and save for posterior use. I was think in use JavaScript, Python or Lua as user's language. Anyone can point me a direction?

  • You an do this in node by reading the user input as a string and then running it using eval. Just be careful as the user can do some serious damage so running any code without validating first is bad practice. – Hattan Shobokshi Nov 22 '16 at 01:19
  • Node's [`vm` module](https://nodejs.org/dist/latest-v7.x/docs/api/vm.html) can help with Hattan's suggestion. Use it in place of `eval()`. – Jonathan Lonowski Nov 22 '16 at 01:58
  • 1
    Does this answer your question? [Safely sandbox and execute user submitted JavaScript?](https://stackoverflow.com/questions/17513212/safely-sandbox-and-execute-user-submitted-javascript) – ggorlen Apr 14 '20 at 06:02

1 Answers1

0

well, while eval and vm module are both helpful here, I am inclined to think about spawning a new node process with the user file as an argument, for two reasons:

  1. Provide maximum isolation between user's code and the server code.
  2. Simulate user's code execution in more realistic manner.
Gireesh Punathil
  • 1,344
  • 8
  • 18