{"size": 876, "ext": "js", "max_stars_repo_path": "webapp/src/routes/logs.js", "max_stars_repo_name": "thor1878/P2", "max_stars_repo_stars_event_min_datetime": "2022-02-10T09:35:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-10T09:57:17.000Z", "max_issues_repo_path": "webapp/src/routes/logs.js", "max_issues_repo_name": "thor1878/P2", "max_issues_repo_issues_event_min_datetime": "2022-02-10T13:22:30.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-24T09:03:14.000Z", "max_forks_repo_path": "webapp/src/routes/logs.js", "max_forks_repo_name": "thor1878/P2", "max_forks_repo_forks_event_min_datetime": "2022-03-30T13:13:22.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T13:13:22.000Z"}
{"max_stars_count": 3, "max_issues_count": 2, "max_forks_count": 1, "avg_line_length": 31.2857142857, "max_line_length": 112, "alphanum_fraction": 0.6141552511}
const express = require('express');
const { contactTS } = require('../utils/TestServer');

const router = express.Router();

// Endpoint for logs page
router.get('/:repoOwner/:repoName/:branch/logs', async (req, res) => {
    const repoOwner = req.params.repoOwner;
    const repoName = req.params.repoName;
    const branch = req.params.branch;

    // Contact test generation server to GET the test info file (without updating it).
    const testInfo = await contactTS('/test-info', 'GET', {
        repository: repoOwner + "/" + repoName,
        branch: branch,
        token: req.user.token,
        update: false
    });

    res.render('logs', {
        testInfo: JSON.parse(JSON.stringify(testInfo).replace(/(\"description\"\:[^\r\n]*?)[ ]\<.*?\>/g, '$1')),
        user: repoOwner, 
        repo: repoName, 
        branch: branch
    });
})

module.exports = router;