Rishabh-malhotraa / caucus

Realtime Collaborate Editor with Embedded Compiler
https://caucus.rishabhmalhotra.in/
MIT License
296 stars 69 forks source link

Replace JDoodle with Piston #20

Open Rishabh-malhotraa opened 3 years ago

Rishabh-malhotraa commented 3 years ago

Jdoodle you are capped to 200 request per day, while piston is free and open source you can have your own docker container running or just use the public API for execution and the only limit is not more that 5 request per second 🚀.

There is no rush right now as we are not exceed more than 100 request per day, you can check the number of request left with the http://caucus-app.herokuapp.com/api/credit-spent

https://github.com/engineer-man/piston https://www.jdoodle.com/compiler-api

GregDevProjects commented 2 years ago

Hi @Rishabh-malhotraa! Can I work on this for hacktoberfest?

Rishabh-malhotraa commented 2 years ago

Sure go right ahead. Here is a bit more context about this issue.

So for us to run code on the browser, we make an API call to a remote code execution service, right now we use something called jdoodle, it only provides us with 200 execution per day. I look to migrate this to Piston, which is free and open-source and has unlimited executions per day.

For this, you need to go through the Piston docs and should send a post request to the piston server for code execution in the format they accept.

The changes you would be required to make is in both the caucus and caucus-server repository,

Changes to the backend https://github.com/Rishabh-malhotraa/caucus-server/blob/main/src/routes/api-routes.ts https://github.com/Rishabh-malhotraa/caucus-server/blob/main/src/utils/getLanguageVersion.ts

Changes to the frontend https://github.com/Rishabh-malhotraa/caucus/blob/main/src/service/CodeExecutionInfo.tsx https://github.com/Rishabh-malhotraa/caucus/blob/main/src/component/InputOutputFile/InputOutputFile.tsx

GregDevProjects commented 2 years ago

@Rishabh-malhotraa ~can you share the environment variables needed to run https://github.com/Rishabh-malhotraa/caucus-server with me?~

Never mind! I signed up for a free account and the endpoints are working for me now

GregDevProjects commented 2 years ago

@Rishabh-malhotraa here's the PR: https://github.com/Rishabh-malhotraa/caucus-server/pull/6

I tested it locally, and it seemed to work fine without any modifications to the frontend. I'm no too familiar with this repo though, so let me know if I'm missing something!