translate.js
952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* Author: Wesnydy Lima Ribeiro
* Email: wesnydy@lavid.ufpb.br
*/
'use strict';
/**
* Required libs.
*/
var shortid = require('shortid')
, amqp = require('../helpers/amqpManager');
exports.translate = function(req, res) {
var body = {};
var id = shortid.generate();
if (!req.body.text)
return console.log('Text key is missing');
body.text = req.body.text;
body.type = 'gloss';
amqp.sendToQueue(body, id,'texts', false, res);
amqp.sendToQueue(body, id,'logs', true, res);
amqp.receiveFromQueue(id, 'glosses', false, res);
};
exports.urltranslate = function(req, res) {
var body = {};
var id = shortid.generate();
if (!req.body.text)
return console.log('Text key missing');
body.text = req.param('text').toString('utf8');
body.type = 'gloss';
amqp.sendToQueue(body, id, 'texts', false, res);
amqp.sendToQueue(body, id, 'logs', true, res);
amqp.receiveFromQueue(id, 'glosses', false, res);
};