title: How can I create APIs from User Provided Code?
body: <p>I am working on a platform where a user will select a programming language (from Python, Java, and NodeJs). And will write down his code in a function.</p>
  <p>My job is to convert this function into an API endpoint.</p>
  <p>And the API endpoint looks like this:</p>
  <p><code>www.myapi.com/:username/api/:function-name</code></p>
  <p>I am unable to figure out how can I execute this code function when a user calls this API endpoint.</p>
  <p>This platform is built using Next.js on the frontend, Nest.js is used for servers, and PostgreSQL is the database. Both frontend and server are hosted on GCP GKE.</p>
  <p>Till now I have thought of the following approaches:</p>
  <ol>
  <li><p>Parse the code and extract particular values like programming language, list of dependencies, function name, function params, function return type, and function code. Then when the endpoint for this function is called I will on the go convert this code into Nest.js or Node.js. But I think this approach is not scalable and efficient in terms of performance.</p>
  </li>
  <li><p>Another thing I thought of was creating a docker image of each of these functions, and storing them in Google Storage, and whenever the endpoint is called I will simply spin up the docker image. But I am not able to find out a way to do this.</p>
  </li>
  </ol>
  <p>So, any suggestions on how can I achieve this or how can I spin up a docker image using an API call??</p>