Showing
1 changed file
with
26 additions
and
4 deletions
... | @@ -10,15 +10,37 @@ const machineRead = require("./machineRead"); | ... | @@ -10,15 +10,37 @@ const machineRead = require("./machineRead"); |
10 | const cliConnection = async (req, res) => { | 10 | const cliConnection = async (req, res) => { |
11 | let clientData = {}, | 11 | let clientData = {}, |
12 | analyzeData = {}, | 12 | analyzeData = {}, |
13 | + searchData = []; | ||
13 | 14 | ||
14 | - clientData = req.body.data; | 15 | + try { |
15 | - //clientData = req.body.data; | 16 | + clientData = req.body.data; |
17 | + //clientData = req.body.data; | ||
18 | + if( !clientData.text.replace( /\s/g, '' ).length ) { | ||
19 | + throw new Error( "client text empty" ); | ||
20 | + } | ||
21 | + } | ||
22 | + catch ( err ) { | ||
23 | + console.log( err ); | ||
24 | + res.json( { "return_code" : -1, "error_code" : err.message } ); | ||
25 | + res.status( 403 ); | ||
26 | + return false; | ||
27 | + } | ||
28 | + | ||
29 | + try { | ||
30 | + analyzeData = await textAnalytic( clientData ); | ||
31 | + } | ||
32 | + catch ( err ) { | ||
33 | + console.log( err ); | ||
34 | + res.json( { "return_code" : -1, "error_code" : err.message } ); | ||
35 | + res.status( 502 ); | ||
36 | + return false; | ||
37 | + } | ||
16 | 38 | ||
17 | - analyzeData = await textAnalytic(clientData); | 39 | + // searchData try catch |
18 | 40 | ||
19 | analyzeData.searchResults = searchData; | 41 | analyzeData.searchResults = searchData; |
20 | res.send({ return_code: 0, return_data: analyzeData }); | 42 | res.send({ return_code: 0, return_data: analyzeData }); |
21 | res.status(200); | 43 | res.status(200); |
22 | }; | 44 | }; |
23 | 45 | ||
24 | -module.exports = cliConnection; | 46 | +module.exports = cliConnection; |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment