Files
freeCodeCamp/tools/contributor/dashboard-app/server/routes/all-repos.js
Oliver Eyton-Williams c8d7f0a782 feat(tools): remove eslint-plugin-prettier for prettier (#42438)
* feat: remove eslint-plugin-prettier for prettier

This removes the annoying lint warnings when all that needs to change is
formatting

* fix: use .js lint-staged config to ignore properly

* fix: lint everything if a lot of files are changed

It's faster than making lots of individual linter calls

* chore: apply prettier

* fix: ignore code in curriculum-file-structure
2021-10-06 21:02:21 +05:30

21 lines
610 B
JavaScript

const router = require('express').Router();
const { ALL_REPOS } = require('../models');
const { reqLimiter } = require('../req-limiter');
router.get('/', reqLimiter, async (request, response) => {
let allRepos = await ALL_REPOS.find({}).then((data) => data);
allRepos.sort((a, b) => a._id - b._id);
allRepos = allRepos.reduce((allReposArr, aRepo) => {
const { _id, prs } = aRepo;
if (prs.length) {
prs.sort((a, b) => a._id - b._id);
return allReposArr.concat({ _id, prs });
}
return allRepos;
}, []);
response.json({ ok: true, allRepos });
});
module.exports = router;