corebasic 1.0.160 → 1.0.161
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/libs/features.js +18 -3
- package/libs/session.js +2 -0
- package/package.json +1 -1
package/libs/features.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Dip from './dip.js'
|
|
2
2
|
import * as Kafka from './kafka.js'
|
|
3
3
|
import * as Utils from './utils.js'
|
|
4
|
+
import * as Session from './session.js'
|
|
4
5
|
import * as Messaging from './messaging.js'
|
|
5
6
|
import axios from 'axios'
|
|
6
7
|
import jwt from 'jsonwebtoken'
|
|
@@ -101,16 +102,30 @@ async function announce() {
|
|
|
101
102
|
})
|
|
102
103
|
await Messaging.produce(`${process.env.REDIS_CHANNEL_PREFIX}_SLYP_FEATURES_LIST`, JSON.stringify({...exp_features, uid: appId }))
|
|
103
104
|
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
function getFeaturelessFeature(req) {
|
|
108
|
+
if (Session.ALLOWED_URLS.includes(req.path)) {
|
|
109
|
+
for(let key in features){
|
|
110
|
+
if (features[key].featureless && features[key].api === req.method.toUpperCase() + ' ' + req.path) {
|
|
111
|
+
return getFeature(key)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
104
117
|
const apiHandler = async (req, res) => {
|
|
105
118
|
let method = req.method.toLowerCase()
|
|
106
119
|
try {
|
|
107
|
-
|
|
120
|
+
let feature = getFeature(req.body?.feature)
|
|
121
|
+
let featureless = feature ? undefined : (feature = getFeaturelessFeature(req))
|
|
122
|
+
|
|
123
|
+
if (!req.body?.feature && !featureless) {
|
|
108
124
|
console.warn(`Feature: feature not sent by client`)
|
|
109
125
|
throw { status: 404, message: "Resource not found. Feature not sent by client." }
|
|
110
126
|
}
|
|
111
127
|
|
|
112
|
-
|
|
113
|
-
if (!feature) {
|
|
128
|
+
if (!feature && !featureless) {
|
|
114
129
|
console.warn(`Feature: ${req.body.feature} not available`)
|
|
115
130
|
throw { status: 404, message: `Resource not found. Feature ${req.body.feature} not available.` }
|
|
116
131
|
}
|
package/libs/session.js
CHANGED
|
@@ -12,9 +12,11 @@ const REFRESH_TOKEN_SECRET = process.env.JWT_REFRESH_TOKEN_SECRET || "MY_SECRET_
|
|
|
12
12
|
const DEPLOY_TOKEN_SECRET = process.env.DEPLOY_TOKEN_SECRET || "MY_SECRET_DEPLOY_TOKEN"
|
|
13
13
|
|
|
14
14
|
let urlsAllowed = []
|
|
15
|
+
export var ALLOWED_URLS = []
|
|
15
16
|
|
|
16
17
|
export const start = (expressApp, allowedUrls) => {
|
|
17
18
|
urlsAllowed = ["/refreshToken", "/login"].concat(allowedUrls ?? [])
|
|
19
|
+
ALLOWED_URLS = urlsAllowed
|
|
18
20
|
app = expressApp
|
|
19
21
|
|
|
20
22
|
|