Skip to content

The Compiler service for the HandsOnCoding project, an open-source MOOC (Massive Open Online Courses) for multiple programming languages.

License

Notifications You must be signed in to change notification settings

Hands-On-Coding-Project/pdg-compiler

Repository files navigation

HandsOnCoding Compiler (Back-End)

This is the compiler API for the HandsOnCoding project, an open-source MOOC (Massive Open Online Courses) for multiple programming languages.

Build With

Node Javascript Express Docker Mocha Chai Swagger

Getting Started

Prerequisites

In order to run this project you should install Node in your computer.

Is recomended to use and install Docker Desktop to run the project with all the needed dependecies in a secure enviroment.

Installation

  1. Clone the repository
    git clone https://github.com/mavaldot/pdg-compiler
  2. Go inside the project folder
    cd HandsOnCoding-Back
  3. Install npm packages (if you are going to run without Docker)
    npm i

Usage

Code types

Code Meaning
-1 Internal Error
10 Compiled correctly
11 Syntax error
20 Shell error
21 Compilation error
30 Timed Out
40 Request error
50 Invalid language

Scripts (Package.json)

Script Description
test Run mocha tests
start Start the app

Run the scripts with the command:

npm run <script>

Configuration

This project runs JavaScript, Python, and C++ code, but you can also define more languages in the data/languages.js file. You only need to add the language in the json variable as follows:

{
    "python": {
        "filename": "main.py",
        "command": "python3 main.py < input.txt"
    }
}

Start

To run the service, just execute the command:

npm start

If you want to use Docker, open Docker Desktop and run this commands instead:

docker build -t comserver .
docker run -p 12345:12345 comserver

In both cases, the service will be running at http://localhost:12345/.

Mocha (Test)

To run the tests, use the following command:

npm start test

Swagger

To auto-generate an HTML file from the Swagger specs (generated every time you run the app in the "docs" folder), you need to install the global dependencies:

npm install -g redoc-cli

and run the following command from the root folder:

redoc-cli build -o docs/swagger.html docs/swagger.json

How do I use the compiler?

Just do a POST request to the base URL with a JSON file with the following structure:

{
    "language": "python",
    "code": "print(input())"
    "input": "Hello World!"
}

and you will receive a similar JSON file:

{
    "code": 10
    "msg": "Hello World!\n"
}

For more information visit the Compiler API Doc.

Related Projects

Contact Information

Quality Esteban Ariza Acosta (Esarac)

Github LinkedIn Gmail Instagram

About

The Compiler service for the HandsOnCoding project, an open-source MOOC (Massive Open Online Courses) for multiple programming languages.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published