<commit_before>var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
  res.json({ success: true });
});

module.exports = router;<commit_msg>apis: Adds rest end points for the job: post, get and delete.<commit_after>var express = require('express')
  , router = express.Router()
  , queue = require('./../lib/q');

/* GET home page. */
router.get('/', function(req, res, next) {
  res.json({ success: true });
});

/* POST A JOB */

router.post('/v1/jobs/:jobType', function(req, res, next){
  console.log("Creating " + req.params.jobType + " job");
  queue.addJob(req.params.jobType, req.body, function(err, jobid){
    if(err){
      console.log("Error occurred:" + err);
      next(err);
    }
    res.json({message: "job created successfully", jobid : jobid});
  });
});

/* GET JOB INFO */

router.get('/v1/jobs/:jobid', function(req, res, next){
  console.log("Info for job with id:" + req.params.jobid);
  queue.jobState(req.params.jobid, function(err, job){
    log.info("JOb info : " + job);
    if(err) {
      console.log("Error occurred: " + err);
    }
    res.json({jobInfo: job});
  });
});


/* DELETE JOBS */

router.delete('/v1/jobs/:jobid', function(req, res, next){
  console.log("Deleting job with id:" + req.params.jobid);
  queue.removeJob(req.params.jobid, function(err){
    if(err) {
      console.log("Error occurred: " + err)
    }
    res.json({success: true, message: "job with id:" + req.params.jobid + " has been removed"});
  });
});



module.exports = router;
{'fraction_non_alphanumeric': 0.20127388535031848, 'fraction_numerical': 0.001910828025477707, 'mean_word_length': 3.4885714285714284, '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': '5647849', 'n_tokens_mistral': 546, 'n_tokens_neox': 537, 'n_words': 124}