Trying to clone a repository & send it to the frontend with Node & Express

This page summarizes the projects mentioned and recommended in the original post on /r/node

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • Puts Debuggerer

    Ruby library for improved puts debugging, automatically displaying bonus useful information such as source line number and source code.

    const express = require("express"); const app = express(); const port = 3000; const path = require("path"); const { execSync } = require("child_process"); // function to download the repo const downloadRepo = (repoURL) => execSync(`git clone ${repoURL}`, { stdio: [0, 1, 2], cwd: path.resolve(__dirname, ""), }); // route to clone the repo app.get("/:repoOwner/:repoName", async (req, res) => { const { repoOwner, repoName } = req.params; // composing the repo URL to be downloaded const fullRepoURL = `https://github.com/${repoOwner}/${repoName}.git`; // downloading the repo in the root folder await downloadRepo(fullRepoURL); // returns the FULL URL of the repo in the frontend res.send(fullRepoURL); // trying to return the repo's content in the the frontend // I get status 304 (not modified) res.sendFile(path.resolve(__dirname, repoName)); }); app.listen(port, () => { console.log(`App listening at http://localhost:${port}`); });

  • isomorphic-git

    A pure JavaScript implementation of git for node and browsers!

    I recently had to implement git cloning into a full stack project and I found a very useful library OP can use. isomorphic-git which would solve this issue and allow them to clone into a virtual filesystem which can help save speed, storage, and possibly keep it secure. Plus if the memfs package is used the OP can just dumb the JSON of the Volume object into the request.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts