@bmostickit/common 1.0.19 → 1.0.21
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/build/index.d.ts
CHANGED
|
@@ -23,4 +23,5 @@ export * from './events/types/expirations';
|
|
|
23
23
|
export * from './events/types/game-status';
|
|
24
24
|
export * from './events/types/quesetion-type';
|
|
25
25
|
export * from './events/types/quiz-category';
|
|
26
|
+
export * from './utils/cloudinary';
|
|
26
27
|
export * from './utils/generate-signed-url';
|
package/build/index.js
CHANGED
|
@@ -39,4 +39,5 @@ __exportStar(require("./events/types/expirations"), exports);
|
|
|
39
39
|
__exportStar(require("./events/types/game-status"), exports);
|
|
40
40
|
__exportStar(require("./events/types/quesetion-type"), exports);
|
|
41
41
|
__exportStar(require("./events/types/quiz-category"), exports);
|
|
42
|
+
__exportStar(require("./utils/cloudinary"), exports);
|
|
42
43
|
__exportStar(require("./utils/generate-signed-url"), exports);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { v2 as
|
|
2
|
-
export
|
|
1
|
+
import { v2 as cloudinaryInstance } from 'cloudinary';
|
|
2
|
+
export declare const cloudinary: typeof cloudinaryInstance;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cloudinary = void 0;
|
|
4
4
|
const cloudinary_1 = require("cloudinary");
|
|
5
|
-
Object.defineProperty(exports, "cloudinary", { enumerable: true, get: function () { return cloudinary_1.v2; } });
|
|
6
5
|
cloudinary_1.v2.config({
|
|
7
6
|
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
|
|
8
7
|
api_key: process.env.CLOUDINARY_API_KEY,
|
|
9
8
|
api_secret: process.env.CLOUDINARY_API_SECRET,
|
|
10
9
|
secure: true,
|
|
11
10
|
});
|
|
11
|
+
exports.cloudinary = cloudinary_1.v2;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
width
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
interface SignedUrlOptions {
|
|
2
|
+
width?: number;
|
|
3
|
+
height?: number;
|
|
4
|
+
crop?: 'limit' | 'fill' | 'scale';
|
|
5
|
+
resourceType?: 'image' | 'raw' | 'video';
|
|
6
|
+
expiresInSeconds?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const generateSignedMediaUrl: (publicId: string, { width, height, crop, resourceType, expiresInSeconds, }?: SignedUrlOptions) => string;
|
|
9
|
+
export {};
|
|
@@ -1,28 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.generateSignedMediaUrl = void 0;
|
|
4
4
|
const cloudinary_1 = require("./cloudinary");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
const url = cloudinary_1.cloudinary.url(publicId, {
|
|
21
|
-
secure: true,
|
|
22
|
-
sign_url: true,
|
|
23
|
-
resource_type: resourceType
|
|
24
|
-
});
|
|
25
|
-
return [{ url }];
|
|
26
|
-
}
|
|
5
|
+
const generateSignedMediaUrl = (publicId, { width, height, crop = 'limit', resourceType = 'image', expiresInSeconds = 3600, // 1 hour
|
|
6
|
+
} = {}) => {
|
|
7
|
+
const timestamp = Math.floor(Date.now() / 1000) + expiresInSeconds;
|
|
8
|
+
const transformation = width || height
|
|
9
|
+
? [{ width, height, crop }]
|
|
10
|
+
: undefined;
|
|
11
|
+
return cloudinary_1.cloudinary.url(publicId, {
|
|
12
|
+
secure: true,
|
|
13
|
+
sign_url: true,
|
|
14
|
+
resource_type: resourceType,
|
|
15
|
+
transformation,
|
|
16
|
+
timestamp,
|
|
17
|
+
});
|
|
27
18
|
};
|
|
28
|
-
exports.
|
|
19
|
+
exports.generateSignedMediaUrl = generateSignedMediaUrl;
|