{"size": 680, "ext": "js", "max_stars_repo_path": "server/imports/softwarePanels/export.js", "max_stars_repo_name": "Unit1229/thorium-code", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/imports/softwarePanels/export.js", "max_issues_repo_name": "Unit1229/thorium-code", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server/imports/softwarePanels/export.js", "max_forks_repo_name": "Unit1229/thorium-code", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.5652173913, "max_line_length": 72, "alphanum_fraction": 0.6382352941}
import App from "../../app";
import yazl from "yazl";
export default function exportSoftwarePanel(id, res) {
  const panel = App.softwarePanels.find(s => s.id === id);
  if (!panel) {
    return res.end("No Panel");
  }
  const zipfile = new yazl.ZipFile();
  const panelBuff = new Buffer(JSON.stringify(panel));
  zipfile.addBuffer(panelBuff, "softwarePanel/softwarePanel.json", {
    mtime: new Date(),
    mode: parseInt("0100664", 8), // -rw-rw-r--
  });

  zipfile.end({}, function() {
    res.set({
      "Content-Disposition": `attachment; filename=${panel.name}.panel`,
      "Content-Type": "application/octet-stream",
    });
    zipfile.outputStream.pipe(res);
  });
}
