Commit 73435c616c4fa633d534668783857197149e85b3
1 parent
9ecf815f
Exists in
master
and in
1 other branch
adicionado check pra ver se a chamada eh bloqueante ou n
Showing
2 changed files
with
59 additions
and
26 deletions
Show diff stats
config/main.js
... | ... | @@ -33,12 +33,43 @@ exports.getLogByName = function (name) { |
33 | 33 | exports.getServiceLogPath = function () { |
34 | 34 | return this.getLogByName('service'); |
35 | 35 | }; |
36 | + | |
36 | 37 | exports.getStatisticsLogPath = function () { |
37 | 38 | return this.getLogByName('statistics'); |
38 | 39 | }; |
40 | + | |
39 | 41 | exports.getErrorLogPath = function () { |
40 | 42 | return this.getLogByName('error'); |
41 | 43 | }; |
44 | + | |
42 | 45 | exports.getCapacityLogPath = function () { |
43 | 46 | return this.getLogByName('capacity'); |
44 | 47 | }; |
48 | + | |
49 | +exports.canRunOnBox = function (service) { | |
50 | + //1 para bloqueante, 2 para nao bloqueante e 3 pra aceitar os dois | |
51 | + var serviceType = parseInt(this.getServiceType()); | |
52 | + | |
53 | + switch(service) { | |
54 | + case 'texto': | |
55 | + return serviceType == 1 || serviceType == 3; | |
56 | + | |
57 | + case 'ios': | |
58 | + return true; | |
59 | + | |
60 | + case 'video': | |
61 | + return serviceType == 2 || serviceType == 3; | |
62 | + | |
63 | + case 'legenda': | |
64 | + return serviceType == 1 || serviceType == 3; | |
65 | + | |
66 | + case 'video-legenda': | |
67 | + return serviceType == 2 || serviceType == 3; | |
68 | + | |
69 | + case 'videornp': | |
70 | + return serviceType == 2 || serviceType == 3; | |
71 | + | |
72 | + default: | |
73 | + return false; | |
74 | + } | |
75 | +}; | ... | ... |
server.js
... | ... | @@ -33,37 +33,39 @@ app.post('/api', function(req, res) { |
33 | 33 | /* Verifica se o paramêtro [servico] possui algum valor */ |
34 | 34 | if (req.body.servico !== '') { |
35 | 35 | /* Verifica qual é o Tipo de Serviço fornecido */ |
36 | - switch(req.body.servico) { | |
37 | - /* Tipo de Serviço: Texto */ | |
38 | - case 'texto': | |
39 | - ep_texto.init(req, res, Request); | |
40 | - break; | |
36 | + if (config.canRunOnBox(req.body.servico)) { | |
37 | + switch(req.body.servico) { | |
38 | + /* Tipo de Serviço: Texto */ | |
39 | + case 'texto': | |
40 | + ep_texto.init(req, res, Request); | |
41 | + break; | |
41 | 42 | |
42 | - /* Tipo de Serviço: iOS */ | |
43 | - case 'ios': | |
44 | - ep_ios.init(req, res); | |
45 | - break; | |
43 | + /* Tipo de Serviço: iOS */ | |
44 | + case 'ios': | |
45 | + ep_ios.init(req, res); | |
46 | + break; | |
46 | 47 | |
47 | - /* Tipo de Serviço: Só o Vídeo */ | |
48 | - case 'video': | |
49 | - ep_video.init(req, res); | |
50 | - break; | |
48 | + /* Tipo de Serviço: Só o Vídeo */ | |
49 | + case 'video': | |
50 | + ep_video.init(req, res); | |
51 | + break; | |
51 | 52 | |
52 | - /* Tipo de Serviço: Só a Legenda */ | |
53 | - case 'legenda': | |
54 | - ep_legenda.init(req, res); | |
55 | - break; | |
53 | + /* Tipo de Serviço: Só a Legenda */ | |
54 | + case 'legenda': | |
55 | + ep_legenda.init(req, res); | |
56 | + break; | |
56 | 57 | |
57 | - /* Tipo de Serviço: Video + Legenda */ | |
58 | - case 'video-legenda': | |
59 | - ep_video_legenda.init(req, res); | |
60 | - break; | |
58 | + /* Tipo de Serviço: Video + Legenda */ | |
59 | + case 'video-legenda': | |
60 | + ep_video_legenda.init(req, res); | |
61 | + break; | |
61 | 62 | |
62 | - /* Case para um Tipo de Serviço inválido */ | |
63 | - default: | |
64 | - res.send(500, parameters.errorMessage('Tipo do serviço inválido')); | |
65 | - break; | |
66 | - } | |
63 | + /* Case para um Tipo de Serviço inválido */ | |
64 | + default: | |
65 | + res.send(500, parameters.errorMessage('Tipo do serviço inválido')); | |
66 | + break; | |
67 | + } // end of switch | |
68 | + } // end of if canRunOnBox | |
67 | 69 | } else { |
68 | 70 | res.send(500, parameters.errorMessage('Especifique o tipo do serviço')); |
69 | 71 | } | ... | ... |