<commit_before>var endpoint = require('../app/endpoint');

// This endpoint defines an HTTP GET interface for adding events,
// and is limited to small data objects (if any).
// For large data objects you'd need the POST version.

// The name is "hg" for "http GET".
endpoint.register('http/GET/hg', function(req, res, args) {
    endpoint.parseArgs(args, null, req, 'http-get', function(err, parsed) {
        if (err) return res.sendStatus(500);
        if (!parsed) return res.sendStatus(400);
        var project  = parsed.project,
            category = parsed.category,
            action   = parsed.action;
        function callback(error) { res.sendStatus(error ? 500 : 200); }
        if (parsed.data) {
            endpoint.db.registerDataEvent(project, category, action, parsed.data, callback);
        } else {
            endpoint.db.registerSimpleEvent(project, category, action, callback);
        }
    });
});<commit_msg>Much simpler endpoint thanks to better API design.<commit_after>var endpoint = require('../app/endpoint');

// This endpoint defines an HTTP GET interface for adding events,
// and is limited to small data objects (if any).
// For large data objects you'd need the POST version.

// The name is "hg" for "http GET".
endpoint.register('http/GET/hg', function(req, res, args) {
    endpoint.parseArgs(args, null, req, 'http-get', function(err, parsed) {
        if (err) return res.sendStatus(500);
        if (!parsed) return res.sendStatus(400);
        endpoint.db.registerEvent(parsed, function(error) {
            res.sendStatus(error ? 500 : 200);
        });
    });
});
{'fraction_non_alphanumeric': 0.13197026022304834, 'fraction_numerical': 0.01486988847583643, 'mean_word_length': 2.9486552567237165, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3060181', 'n_tokens_mistral': 473, 'n_tokens_neox': 447, 'n_words': 148}