leancloud-log-middleware
Advanced tools
Comparing version 1.4.1 to 1.4.2
20
index.js
var request = require('request'); | ||
var AV = require('leanengine'); | ||
var BASE_URL = (process.env.isUS === 'true') ? 'http://us-api.leancloud.cn/1.1/classes' : 'http://api.leancloud.cn/1.1/classes'; | ||
var BASE_URL = (process.env.isUS === 'true') ? 'http://us-api.leancloud.cn/1.1/classes' : 'https://api.leancloud.cn/1.1/classes'; | ||
var CLASS = process.env.LOG_SYSTEM_CLASS; | ||
@@ -10,3 +10,2 @@ | ||
appKey: process.env.LEANCLOUD_APP_KEY, | ||
masterKey: process.env.LEANCLOUD_APP_MASTER_KEY, | ||
region: 'us' | ||
@@ -18,3 +17,2 @@ }); | ||
appKey: process.env.LEANCLOUD_APP_KEY, | ||
masterKey: process.env.LEANCLOUD_APP_MASTER_KEY | ||
}); | ||
@@ -82,2 +80,14 @@ } | ||
var fetchSession = function(req) { | ||
if(req.cookies){ | ||
if(req.cookies.sessiontoken) | ||
return req.cookies.sessiontoken; | ||
} else if (req.headers){ | ||
if(req.headers.sessiontoken) | ||
return req.headers.sessiontoken; | ||
} else { | ||
return null; | ||
} | ||
}; | ||
var add = function (_payload, cb) { | ||
@@ -125,3 +135,3 @@ var url = BASE_URL + '/' + CLASS; | ||
var Request = function (req, res, next) { | ||
var token = req.cookies.sessiontoken || req.headers.sessiontoken; | ||
var token = fetchSession(req); | ||
var payload = defaultRequestPayload(req, res, next); | ||
@@ -146,3 +156,3 @@ if (token) { | ||
var ORIGIN_JSON_FUNCTION = res.json; | ||
var token = req.cookies.sessiontoken || req.headers.sessiontoken; | ||
var token = fetchSession(req); | ||
@@ -149,0 +159,0 @@ res.json = function(_result) { |
{ | ||
"name": "leancloud-log-middleware", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "Middleware of creating Leancloud object, by configuring LOG_SYSTEM_APP_ID, LOG_SYSTEM_APP_KEY and LOG_SYSTEM_CLASS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
9448
209
11