session-sync-auth-site 3.0.4 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/authenticate.js +1 -5
- package/src/setUpConnection.js +30 -14
package/package.json
CHANGED
package/src/authenticate.js
CHANGED
|
@@ -21,11 +21,7 @@ const authenticate = ({
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// Connect to DB if not already connected
|
|
24
|
-
|
|
25
|
-
console.log('Establishing DB connection for session-sync-auth-site...')
|
|
26
|
-
await setUpConnection(connectionInfo)
|
|
27
|
-
console.log('...DB connection established for session-sync-auth-site.')
|
|
28
|
-
}
|
|
24
|
+
await setUpConnection(connectionInfo)
|
|
29
25
|
|
|
30
26
|
let accessToken = req.headers['x-access-token']
|
|
31
27
|
|
package/src/setUpConnection.js
CHANGED
|
@@ -6,20 +6,36 @@ const setUpConnection = async ({
|
|
|
6
6
|
connectionObj,
|
|
7
7
|
}={}) => {
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
global.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
if(global.sessionSyncAuthSiteConnection) return
|
|
10
|
+
|
|
11
|
+
if(!global.sessionSyncAuthSiteConnectionPromise) {
|
|
12
|
+
|
|
13
|
+
global.sessionSyncAuthSiteConnectionPromise = (async () => {
|
|
14
|
+
|
|
15
|
+
console.log('Establishing DB connection for session-sync-auth-site...')
|
|
16
|
+
|
|
17
|
+
connectionObj = connectionObj || new ConnectionString(connectionStr)
|
|
18
|
+
|
|
19
|
+
global.sessionSyncAuthSiteConnection = await mysql.createConnection({
|
|
20
|
+
multipleStatements: true,
|
|
21
|
+
dateStrings: true,
|
|
22
|
+
charset : 'utf8mb4',
|
|
23
|
+
// debug: true,
|
|
24
|
+
host: connectionObj.host || connectionObj.hosts[0].name,
|
|
25
|
+
user: connectionObj.user || connectionObj.username,
|
|
26
|
+
password: connectionObj.password,
|
|
27
|
+
database: connectionObj.database || connectionObj.path[0],
|
|
28
|
+
port: connectionObj.port,
|
|
29
|
+
namedPlaceholders: true,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
console.log('...DB connection established for session-sync-auth-site.')
|
|
33
|
+
|
|
34
|
+
})()
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
await global.sessionSyncAuthSiteConnectionPromise
|
|
23
39
|
|
|
24
40
|
}
|
|
25
41
|
|