<commit_before>'use strict';

let ApiController = require('./ApiController');

class ServerController extends ApiController {
    /**
     * Initialises this controller
     */
    static init(app) {
        app.get('/api/server/projects', this.getAllProjects);
        app.get('/api/server/:project/environments', this.getAllEnvironments);
    }
    
    /**
     * Gets a list of all projects
     */
    static getAllProjects(req, res) {
        ProjectHelper.getAllProjects()
        .then((projects) => {
            res.send(projects);
        })
        .catch((e) => {
            res.status(502).send(e);
        });
    }
    
    /**
     * Gets a list of all environments
     */
    static getAllEnvironments(req, res) {
        let project = req.params.project;

        ProjectHelper.getAllEnvironments(project)
        .then((environments) => {
            res.send(environments);<commit_msg>readded auth to project listing<commit_after>'use strict';

let ApiController = require('./ApiController');

class ServerController extends ApiController {
    /**
     * Initialises this controller
     */
    static init(app) {
        app.get('/api/server/projects', this.middleware({ setProjects: false }), this.getAllProjects);
        app.get('/api/server/:project/environments', this.middleware({ setProjects: false }), this.getAllEnvironments);
    }
    
    /**
     * Gets a list of all projects
     */
    static getAllProjects(req, res) {
        ProjectHelper.getAllProjects()
        .then((projects) => {
            res.send(projects);
        })
        .catch((e) => {
            res.status(502).send(e);
        });
    }
    
    /**
     * Gets a list of all environments
     */
    static getAllEnvironments(req, res) {
        let project = req.params.project;

        ProjectHelper.getAllEnvironments(project)
        .then((environments) => {
            res.send(environments);
{'fraction_non_alphanumeric': 0.1336116910229645, 'fraction_numerical': 0.003131524008350731, 'mean_word_length': 2.2003338898163607, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2482685', 'n_tokens_mistral': 550, 'n_tokens_neox': 545, 'n_words': 103}