<commit_before>express = require 'express'
mongo = require 'mongoskin'
router = express.Router()

# Mongodb Connect
db = mongo.db('mongodb://localhost:27017/alarm-doc')

router.get '/receiver', (req, res) ->
  json_ret = {
    "code": 1002,
    "msg": "BAD REQUEST",
    "request": req.route.path
  }
  res.status(400).json(json_ret)

router.post '/receiver', (req, res) ->
  db.collection('send_list').insertOne req.body, (err, r) ->
    if r.insertedCount == 1
      res.status(201).json({
        "code": 1000,
        "msg": "CREATED",
        "request": req.route.path
        })
    else
      res.status(500).json({
        "code": 999,
        "msg": "INTERNAL SERVER ERROR",
        "request": req.route.path
        })
module.exports = router<commit_msg>feat(routes/apis.coffee): 告警通知入队列<commit_after>express = require 'express'
mongo = require 'mongoskin'
kue = require 'kue'
router = express.Router()

# Mongodb Connect
db = mongo.db('mongodb://localhost:27017/alarm-doc')

# Kue Quened
queue = kue.createQueue()

router.get '/receiver', (req, res) ->
  json_ret = {
    "code": 1002,
    "msg": "BAD REQUEST",
    "request": req.route.path
  }
  res.status(400).json(json_ret)

router.post '/receiver', (req, res) ->
  db.collection('send_list').insertOne req.body, (err, r) ->
    if r.insertedCount == 1
      job = queue.create('email', req.body).save((err) ->
        if !err
          res.status(201).json({
            "code": 1000,
            "msg": "CREATED job:"+ job.id,
            "request": req.route.path
          })
        else
          res.status(500).json({
            "code": 1001,
            "msg": "CREATED job fail",
            "request": req.route.path
          })
      )
    else
      res.status(500).json({
        "code": 999,
        "msg": "INTERNAL SERVER ERROR",
        "request": req.route.path
        })
module.exports = router
{'fraction_non_alphanumeric': 0.17153478491768454, 'fraction_numerical': 0.031332979288369624, 'mean_word_length': 2.3642857142857143, 'pattern_counts': {'":': 21, '<': 3, '<?xml version=': 0, '>': 10, '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': '5729669', 'n_tokens_mistral': 696, 'n_tokens_neox': 647, 'n_words': 134}