CodeRunner is a backend application built using NestJS framework that allows users to run and execute code in 7 different languages (JavaScript, Python, C++, Java,typescript,c, and Dart). The application has been built with security in mind and uses a factory pattern to validate the code before executing it.
- Clone the repository:
https://github.com/Amalreji111/coderunner.git
- Install the dependencies:
npm install
3.The application should now be running on http://localhost:3000
- Start the app:
nest start
The application exposes a single endpoint /run that accepts a POST request with a JSON payload containing the code and the language.
Example payload:
{
"code": "console.log('Hello World')",
"language": "javascript"
}
The application will validate the code before executing it to ensure that it does not contain any malicious code. Once the code has been validated, it will execute the code and return the output in the response.
The application uses a factory pattern to validate the code before executing it. The factory uses a combination of regular expressions and SonarQube analysis to ensure that the code does not contain any malicious code.
Feel free to contribute to the project by submitting a pull request.
- Nest.js - A progressive Node.js framework for building efficient and scalable server-side applications.
Nest is MIT licensed.