@@ -18,12 +18,29 @@ app.use(session({
18
18
} ) ) ;
19
19
20
20
app . use ( '/favicon.ico' , express . static ( 'public/images/favicon.ico' ) ) ;
21
+
22
+
21
23
// parse application/json
22
24
app . use ( bodyParser . json ( ) ) ;
23
25
// parse application/x-www-form-urlencoded
24
26
app . use ( bodyParser . urlencoded ( { extended : true } ) ) ;
25
27
// for parsing multipart/form-data
26
28
const multer = require ( 'multer' ) ( )
29
+
30
+ app . post ( '/example_endpoint' , multer . any ( ) , function ( req , res ) {
31
+ //the token comes in from the fron end in the request body
32
+ const myVoiceIt = new VoiceIt2WebSDK . Voiceit2 ( config . VOICEIT_API_KEY , config . VOICEIT_API_TOKEN , { sessionExpirationTimeHours :config . SESSION_EXPIRATION_TIME_HOURS } ) ;
33
+ myVoiceIt . makeCall ( req , res , function ( jsonObj ) {
34
+ if (
35
+ ( jsonObj . callType . includes ( 'Liveness' ) && jsonObj . jsonResponse . success ) || // Liveness Server returns success true/false instead of responseCode
36
+ ( ! jsonObj . callType . includes ( 'Liveness' ) && jsonObj . jsonResponse . responseCode === 'SUCC' )
37
+ ) {
38
+ // Activate Session with userId
39
+ req . session . userId = jsonObj . userId ;
40
+ }
41
+ } ) ;
42
+ } ) ;
43
+
27
44
app . use ( multer . array ( ) ) ;
28
45
// serve all static files in public directory
29
46
app . use ( express . static ( 'public' ) ) ;
@@ -76,19 +93,6 @@ app.get('/console', function (req, res) {
76
93
}
77
94
} )
78
95
79
- app . post ( '/example_endpoint' , multer . any ( ) , function ( req , res ) {
80
- //the token comes in from the fron end in the request body
81
- const myVoiceIt = new VoiceIt2WebSDK . Voiceit2 ( config . VOICEIT_API_KEY , config . VOICEIT_API_TOKEN , { sessionExpirationTimeHours :config . SESSION_EXPIRATION_TIME_HOURS } ) ;
82
- myVoiceIt . makeCall ( req , res , function ( jsonObj ) {
83
- if (
84
- ( jsonObj . callType . includes ( 'Liveness' ) && jsonObj . jsonResponse . success ) || // Liveness Server returns success true/false instead of responseCode
85
- ( ! jsonObj . callType . includes ( 'Liveness' ) && jsonObj . jsonResponse . responseCode === 'SUCC' )
86
- ) {
87
- // Activate Session with userId
88
- req . session . userId = jsonObj . userId ;
89
- }
90
- } ) ;
91
- } ) ;
92
96
93
97
app . get ( '/content_language' , function ( req , res ) {
94
98
res . json ( { contentLanguage : config . CONTENT_LANGUAGE } ) ;
0 commit comments