<commit_before>var express     = require('express'),
    bodyParser  = require('body-parser'),
    mongoose    = require('mongoose'),
    config      = require('./config/default'),
    CssRef      = require('./app/models/cssref');

mongoose.connect(config.mongouri);

var app = express();

app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

var port = process.env.PORT || 8080;

var router = express.Router();
router.get('/', function(req, res) {
    res.json({ message: 'Welcome to CSS Reference API' });
});
app.use('/api', router);

app.listen(port);
console.log('Server listening on port ' + port);

<commit_msg>Implements QUERY, POST, GET, PUT & DELETE with a dummy field<commit_after>var express     = require('express'),
    bodyParser  = require('body-parser'),
    mongoose    = require('mongoose'),
    config      = require('./config/default'),
    CssRef      = require('./app/models/cssref');

mongoose.connect(config.mongouri);

var app = express();

app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

var port = process.env.PORT || 8080;

var router = express.Router();

router.use(function(req, res, next) {
    console.log(req.method + ' ' +
        req.baseUrl + req.url + ' ' +
        res.statusCode + ' ' +
        req.headers.host + ' ' +
        req.headers['user-agent']
    );
    next();
});

router.get('/', function(req, res) {
    res.json({ message: 'Welcome to CSS Reference API' });
});

router.route('/css')
    .post(function(req, res) {
        var cssref = new CssRef();
        cssref.name = req.body.name;

        cssref.save(function(err) {
            if (err) {
                res.send(err);
            }
            res.json(cssref);
        });
    })
    .get(function(req, res) {
        CssRef.find(function(err, cssrefs) {
            if (err) {
                res.send(err);
            }
            res.json(cssrefs);
        })
    });
router.route('/css/:ref_id')
    .get(function(req, res) {
        CssRef.findById(req.params.ref_id, function(err, cssref) {
            if (err) {
                res.send(err);
            }
            res.json(cssref);
        });
    })
    .put(function(req, res) {
        CssRef.findById(req.params.ref_id, function(err, cssref) {
            if (err) {
                res.send(err);
            }
            cssref.name = req.body.name;
            cssref.save(function(err) {
                if (err) {
                    res.send(err);
                }
                res.json(cssref);
            });
        });
    })
    .delete(function(req, res) {
        CssRef.remove({
            _id: req.params.ref_id
        }, function(err, cssref) {
            if (err) {
                res.send(err);
            }
            res.json('204');
        });
    });

app.use('/api', router);

app.listen(port);
console.log('Server listening on port ' + port);


{'fraction_non_alphanumeric': 0.1676912568306011, 'fraction_numerical': 0.003756830601092896, 'mean_word_length': 1.931931931931932, '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': '2669119', 'n_tokens_mistral': 942, 'n_tokens_neox': 925, 'n_words': 165}