corebasic 1.0.72 → 1.0.73
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/utils.js +20 -3
- package/package.json +1 -1
package/libs/utils.js
CHANGED
|
@@ -163,7 +163,7 @@ export async function fileToJson(path, file) {
|
|
|
163
163
|
|
|
164
164
|
|
|
165
165
|
function execute(pipeline, errfn) {
|
|
166
|
-
startPipeline(pipeline, 0, undefined, errfn)
|
|
166
|
+
startPipeline(pipeline, 0, undefined, errfn)
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
function startPipeline(pipeline, index, data, errfn) {
|
|
@@ -177,9 +177,26 @@ function startPipeline(pipeline, index, data, errfn) {
|
|
|
177
177
|
// S3 Object Storage
|
|
178
178
|
// -----------------
|
|
179
179
|
|
|
180
|
-
export async function getUrl(path, expiry = 3600) { // expiry default: 1 Hour
|
|
180
|
+
export async function getUrl(path, expiry = 3600) { // expiry default: 1 Hour
|
|
181
181
|
return await getSignedUrl(S3, new GetObjectCommand({ Bucket: bucketName, Key: path }), { expiresIn: expiry })
|
|
182
182
|
}
|
|
183
|
-
export async function putUrl(path, expiry = 3600) { // expiry default: 1 Hour
|
|
183
|
+
export async function putUrl(path, expiry = 3600) { // expiry default: 1 Hour
|
|
184
184
|
return await getSignedUrl(S3, new PutObjectCommand({ Bucket: bucketName, Key: path }), { expiresIn: expiry })
|
|
185
185
|
}
|
|
186
|
+
|
|
187
|
+
// ---------------------------
|
|
188
|
+
// Express Middleware Exclude
|
|
189
|
+
// ---------------------------
|
|
190
|
+
export const excludeMiddleware = function(middleware, ...paths) {
|
|
191
|
+
return function(req, res, next) {
|
|
192
|
+
const pathCheck = paths.some(path => {
|
|
193
|
+
let url = req.path.split('/')
|
|
194
|
+
let cmp = path.split('/')
|
|
195
|
+
if (url.length !== cmp.length)
|
|
196
|
+
return false
|
|
197
|
+
let f = cmp.map((p,index) => p.startsWith(":") ? url[index] : p).join('/')
|
|
198
|
+
return f === req.path
|
|
199
|
+
})
|
|
200
|
+
pathCheck ? next() : middleware(req, res, next);
|
|
201
|
+
}
|
|
202
|
+
}
|