{"size": 476, "ext": "js", "max_stars_repo_path": "api/posts.js", "max_stars_repo_name": "Hackathon-Squad/Community", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "api/posts.js", "max_issues_repo_name": "Hackathon-Squad/Community", "max_issues_repo_issues_event_min_datetime": "2021-02-20T06:38:34.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-21T09:06:14.000Z", "max_forks_repo_path": "api/posts.js", "max_forks_repo_name": "Hackathon-Squad/Community", "max_forks_repo_forks_event_min_datetime": "2021-03-28T08:19:00.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-28T08:19:00.000Z"}
{"max_stars_count": null, "max_issues_count": 23, "max_forks_count": 1, "avg_line_length": 25.0526315789, "max_line_length": 58, "alphanum_fraction": 0.6365546218}
const express = require("express");
const router = express.Router();
const db = require("../db");

router.get("/", async (req, res) => {
  const collection = db.collection("posts");
  const documents = await collection.get();
  let docArray = [];
  try {
    documents.forEach((doc) => docArray.push(doc.data()));
  } catch (error) {
    console.error(error);
    res.status(500).send("There was an error");
  }
  res.status(200).send(docArray);
});

module.exports = router;
