简体   繁体   中英

How to run user's code in a Node.js web app?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM