File tree Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import axios from 'axios'
2
2
3
3
namespace ApiService {
4
4
const interval = 1000 ; // set polling interval to 1 second
5
- const timeout = 12000 ;
5
+ const timeout = 120000 ;
6
6
7
7
export async function getToken ( username : string , password : string ) {
8
8
console . log ( 'Authenticating in ARQAN' )
@@ -32,15 +32,16 @@ namespace ApiService {
32
32
}
33
33
}
34
34
)
35
-
36
35
const task_id = response . data . task_id
36
+ console . log ( "Task id: " , task_id )
37
37
38
38
response = await axios . get ( `http://51.250.88.251:8000/api/tasks/sec-req-extract/${ task_id } ` , {
39
39
headers : {
40
40
'Authorization' : `Bearer ${ token } ` ,
41
41
'accept' : 'application/json'
42
42
}
43
43
} ) ;
44
+
44
45
const startTime = new Date ( ) . getTime ( ) ;
45
46
while ( response . status === 202 && new Date ( ) . getTime ( ) - startTime < timeout ) {
46
47
await new Promise ( resolve => setTimeout ( resolve , interval ) ) ; // Wait for interval before making another request
@@ -52,6 +53,8 @@ namespace ApiService {
52
53
} ) ;
53
54
}
54
55
56
+ console . log ( "Outside cycle" )
57
+ console . log ( response . status )
55
58
if ( response . status === 202 ) {
56
59
throw new Error ( 'Polling timed out' ) ;
57
60
}
Original file line number Diff line number Diff line change @@ -4,16 +4,10 @@ import {Stig} from './interfaces'
4
4
5
5
namespace Requirement {
6
6
export async function isSecurity ( issue : string , token : string ) : Promise < boolean > {
7
- console . log ( 'In isSecurity function' )
8
7
// API call to ARQAN to classify the requirement
9
8
let securitySentences = await ApiService . getSecuritySentences ( issue , token ) . then (
10
9
( result ) => {
11
10
return result . requirements
12
- } ,
13
- ( error ) => {
14
- throw new Error (
15
- `Received ${ error . response . status } status code from ARQAN Classification Service for input: ${ issue } .`
16
- )
17
11
}
18
12
)
19
13
You can’t perform that action at this time.
0 commit comments