'How to validate code from a userinput in the backend useing node.js

I want to try and build something like codeacedemy. Where a client can write code in diffrent languages (Java, Phython ...) for a given question on a website and run tests against there answer when you submit the code.

My guess would be that the code has to be validated in the backend. Im useing node.js. So how would you validate the code for example java with Junit in a node.js and then send back a response to the client.



Solution 1:[1]

I think you need this: eval()

let stringToEval = "let num = 23; console.log(num);"

eval(stringToEval)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hidenplus