11#!/usr/bin/env node
22
33const express = require ( 'express' ) ;
4- const session = require ( 'express-session' ) ; // https://github.com/expressjs/session
4+ const session = require ( 'express-session' ) ; // https://github.com/expressjs/session
55const bodyParser = require ( 'body-parser' ) ;
66const cookieParser = require ( 'cookie-parser' ) ;
77const MemoryStore = require ( 'memorystore' ) ( session ) ; // https://github.com/roccomuso/memorystore
@@ -19,7 +19,7 @@ const helmet = require('helmet'); // https://expressjs.com/en/advanced/best-prac
1919const moment = require ( 'moment' ) ;
2020const csrf = require ( 'csurf' ) ; // https://www.npmjs.com/package/csurf
2121const examplesApi = require ( './config/examplesAPI.json' ) ;
22- const { getManifest } = require ( './lib/manifestService' )
22+ const { getManifest } = require ( './lib/manifestService' ) ;
2323
2424const eg001 = require ( './lib/eSignature/controllers/eg001EmbeddedSigning' ) ;
2525
@@ -30,36 +30,36 @@ const {
3030 eg024, eg025, eg026, eg027, eg028, eg029, eg030,
3131 eg031, eg032, eg033, eg034, eg035, eg036, eg037,
3232 eg038, eg039, eg040
33- } = require ( " ./lib/eSignature/controllers" ) ;
33+ } = require ( ' ./lib/eSignature/controllers' ) ;
3434
3535const {
3636 eg001click, eg002click, eg003click,
3737 eg004click, eg005click,
38- } = require ( " ./lib/click/controllers" ) ;
38+ } = require ( ' ./lib/click/controllers' ) ;
3939
4040const {
4141 eg001rooms, eg002rooms, eg003rooms,
4242 eg004rooms, eg005rooms, eg006rooms,
4343 eg007rooms, eg008rooms, eg009rooms,
44- } = require ( " ./lib/rooms/controllers" ) ;
44+ } = require ( ' ./lib/rooms/controllers' ) ;
4545
4646const {
4747 eg001monitor, eg002monitor
48- } = require ( " ./lib/monitor/controllers/index" ) ;
48+ } = require ( ' ./lib/monitor/controllers/index' ) ;
4949
5050const {
5151 eg001admin, eg002admin, eg003admin,
5252 eg004admin, eg005admin, eg006admin,
5353 eg007admin, eg008admin, eg009admin
54- } = require ( " ./lib/admin/controllers" ) ;
54+ } = require ( ' ./lib/admin/controllers' ) ;
5555
5656const PORT = process . env . PORT || 3000 ;
5757const HOST = process . env . HOST || 'localhost' ;
5858const max_session_min = 180 ;
5959const csrfProtection = csrf ( { cookie : true } ) ;
6060
61- let hostUrl = 'http://' + HOST + ':' + PORT
62- if ( dsConfig . appUrl != '' && dsConfig . appUrl != '{APP_URL}' ) { hostUrl = dsConfig . appUrl }
61+ let hostUrl = 'http://' + HOST + ':' + PORT ;
62+ if ( dsConfig . appUrl !== '' && dsConfig . appUrl !== '{APP_URL}' ) { hostUrl = dsConfig . appUrl ; }
6363
6464let app = express ( )
6565 . use ( helmet ( ) )
@@ -78,14 +78,14 @@ let app = express()
7878 . use ( passport . initialize ( ) )
7979 . use ( passport . session ( ) )
8080 . use ( bodyParser . urlencoded ( { extended : true } ) )
81- . use ( ( ( req , res , next ) => {
81+ . use ( ( req , res , next ) => {
8282 res . locals . user = req . user ;
8383 res . locals . session = req . session ;
8484 res . locals . dsConfig = { ...dsConfig , docOptions : docOptions , docNames : docNames } ;
85- res . locals . examplesApi = examplesApi
85+ res . locals . examplesApi = examplesApi ;
8686 res . locals . hostUrl = hostUrl ; // Used by DSAuthCodeGrant#logout
87- next ( )
88- } ) ) // Send user info to views
87+ next ( ) ;
88+ } ) // Send user info to views
8989 . use ( flash ( ) )
9090 . set ( 'views' , path . join ( __dirname , 'views' ) )
9191 . set ( 'view engine' , 'ejs' )
@@ -97,12 +97,12 @@ let app = express()
9797 if ( req . session . authMethod === 'jwt-auth' ) {
9898 req . dsAuth = req . dsAuthJwt ;
9999 }
100- next ( )
100+ next ( ) ;
101101 } )
102102 . use ( async ( req , res , next ) => {
103103 let manifestUrl ;
104104
105- switch ( true ) {
105+ switch ( true ) {
106106 case examplesApi . examplesApi . isRoomsApi :
107107 manifestUrl = dsConfig . roomsManifestUrl ;
108108 break ;
@@ -158,7 +158,7 @@ if (examplesApi.examplesApi.isRoomsApi) {
158158 . get ( '/eg008' , eg008rooms . getController )
159159 . post ( '/eg008' , eg008rooms . createController )
160160 . get ( '/eg009' , eg009rooms . getController )
161- . post ( '/eg009' , eg009rooms . createController )
161+ . post ( '/eg009' , eg009rooms . createController ) ;
162162} else if ( examplesApi . examplesApi . isClickApi ) {
163163 app . get ( '/eg001' , eg001click . getController )
164164 . post ( '/eg001' , eg001click . createController )
@@ -169,12 +169,12 @@ if (examplesApi.examplesApi.isRoomsApi) {
169169 . get ( '/eg004' , eg004click . getController )
170170 . post ( '/eg004' , eg004click . createController )
171171 . get ( '/eg005' , eg005click . getController )
172- . post ( '/eg005' , eg005click . createController )
172+ . post ( '/eg005' , eg005click . createController ) ;
173173} else if ( examplesApi . examplesApi . isMonitorApi ) {
174174 app . get ( '/eg001' , eg001monitor . getController )
175175 . post ( '/eg001' , eg001monitor . createController )
176176 . get ( '/eg002' , eg002monitor . getController )
177- . post ( '/eg002' , eg002monitor . createController )
177+ . post ( '/eg002' , eg002monitor . createController ) ;
178178} else if ( examplesApi . examplesApi . isAdminApi ) {
179179 app . get ( '/eg001' , eg001admin . getController )
180180 . post ( '/eg001' , eg001admin . createController )
@@ -194,7 +194,7 @@ if (examplesApi.examplesApi.isRoomsApi) {
194194 . get ( '/eg008' , eg008admin . getController )
195195 . post ( '/eg008' , eg008admin . createController )
196196 . get ( '/eg009' , eg009admin . getController )
197- . post ( '/eg009' , eg009admin . createController )
197+ . post ( '/eg009' , eg009admin . createController ) ;
198198} else {
199199 app . get ( '/eg001' , eg001 . getController )
200200 . post ( '/eg001' , eg001 . createController )
@@ -273,16 +273,16 @@ if (examplesApi.examplesApi.isRoomsApi) {
273273 . get ( '/eg039' , eg039 . getController )
274274 . post ( '/eg039' , eg039 . createController )
275275 . get ( '/eg040' , eg040 . getController )
276- . post ( '/eg040' , eg040 . createController )
276+ . post ( '/eg040' , eg040 . createController ) ;
277277}
278278
279- function dsLoginCB1 ( req , res , next ) { req . dsAuthCodeGrant . oauth_callback1 ( req , res , next ) }
280- function dsLoginCB2 ( req , res , next ) { req . dsAuthCodeGrant . oauth_callback2 ( req , res , next ) }
279+ function dsLoginCB1 ( req , res , next ) { req . dsAuthCodeGrant . oauth_callback1 ( req , res , next ) ; }
280+ function dsLoginCB2 ( req , res , next ) { req . dsAuthCodeGrant . oauth_callback2 ( req , res , next ) ; }
281281
282282/* Start the web server */
283283if ( dsConfig . dsClientId && dsConfig . dsClientId !== '{CLIENT_ID}' &&
284284 dsConfig . dsClientSecret && dsConfig . dsClientSecret !== '{CLIENT_SECRET}' ) {
285- app . listen ( PORT )
285+ app . listen ( PORT ) ;
286286 console . log ( `Listening on ${ PORT } ` ) ;
287287 console . log ( `Ready! Open ${ hostUrl } ` ) ;
288288} else {
@@ -298,25 +298,25 @@ You can set them in the configuration file config/appsettings.json or set enviro
298298// the user by ID when deserializing. However, since this example does not
299299// have a database of user records, the complete DocuSign profile is serialized
300300// and deserialized.
301- passport . serializeUser ( function ( user , done ) { done ( null , user ) } ) ;
302- passport . deserializeUser ( function ( obj , done ) { done ( null , obj ) } ) ;
301+ passport . serializeUser ( function ( user , done ) { done ( null , user ) ; } ) ;
302+ passport . deserializeUser ( function ( obj , done ) { done ( null , obj ) ; } ) ;
303303
304- const SCOPES = [ " signature" ] ;
304+ const SCOPES = [ ' signature' ] ;
305305const ROOM_SCOPES = [
306- " signature" , " dtr.rooms.read" , " dtr.rooms.write" ,
307- " dtr.documents.read" , " dtr.documents.write" , " dtr.profile.read" , " dtr.profile.write" ,
308- " dtr.company.read" , " dtr.company.write" , " room_forms"
306+ ' signature' , ' dtr.rooms.read' , ' dtr.rooms.write' ,
307+ ' dtr.documents.read' , ' dtr.documents.write' , ' dtr.profile.read' , ' dtr.profile.write' ,
308+ ' dtr.company.read' , ' dtr.company.write' , ' room_forms'
309309] ;
310310const CLICK_SCOPES = [
311- " signature" , " click.manage" , " click.send"
311+ ' signature' , ' click.manage' , ' click.send'
312312] ;
313313const MONITOR_SCOPES = [
314- " signature" , " impersonation"
314+ ' signature' , ' impersonation'
315315] ;
316316const ADMIN_SCOPES = [
317- " organization_read" , " group_read" , " permission_read " ,
318- " user_read" , " user_write" , " account_read" ,
319- " domain_read" , " identity_provider_read" , " signature"
317+ ' organization_read' , ' group_read' , ' permission_read ' ,
318+ ' user_read' , ' user_write' , ' account_read' ,
319+ ' domain_read' , ' identity_provider_read' , ' signature'
320320] ;
321321let scope ;
322322if ( examplesApi . examplesApi . isRoomsApi ) {
@@ -334,7 +334,7 @@ if (examplesApi.examplesApi.isRoomsApi) {
334334let docusignStrategy = new DocusignStrategy ( {
335335 production : dsConfig . production ,
336336 clientID : dsConfig . dsClientId ,
337- scope : scope . join ( " " ) ,
337+ scope : scope . join ( ' ' ) ,
338338 clientSecret : dsConfig . dsClientSecret ,
339339 callbackURL : hostUrl + '/ds/callback' ,
340340 state : true // automatic CSRF protection.
@@ -361,8 +361,8 @@ let docusignStrategy = new DocusignStrategy({
361361 */
362362if ( ! dsConfig . allowSilentAuthentication ) {
363363 // See https://stackoverflow.com/a/32877712/64904
364- docusignStrategy . authorizationParams = function ( options ) {
364+ docusignStrategy . authorizationParams = function ( options ) {
365365 return { prompt : 'login' } ;
366- }
366+ } ;
367367}
368368passport . use ( docusignStrategy ) ;
0 commit comments