@bmostickit/common 1.0.18 → 1.0.19

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,3 +23,4 @@ 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/generate-signed-url';
package/build/index.js CHANGED
@@ -39,3 +39,4 @@ __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/generate-signed-url"), exports);
@@ -0,0 +1,2 @@
1
+ import { v2 as cloudinary } from 'cloudinary';
2
+ export { cloudinary };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cloudinary = void 0;
4
+ const cloudinary_1 = require("cloudinary");
5
+ Object.defineProperty(exports, "cloudinary", { enumerable: true, get: function () { return cloudinary_1.v2; } });
6
+ cloudinary_1.v2.config({
7
+ cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
8
+ api_key: process.env.CLOUDINARY_API_KEY,
9
+ api_secret: process.env.CLOUDINARY_API_SECRET,
10
+ secure: true,
11
+ });
@@ -0,0 +1,6 @@
1
+ export declare const generateSignedUrl: (publicId: string, resourceType?: "image" | "raw" | "video") => {
2
+ width: number;
3
+ url: string;
4
+ }[] | {
5
+ url: string;
6
+ }[];
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateSignedUrl = void 0;
4
+ const cloudinary_1 = require("./cloudinary");
5
+ const generateSignedUrl = (publicId, resourceType = 'image') => {
6
+ if (resourceType === 'image') {
7
+ const widths = [300, 600, 900];
8
+ const urls = widths.map((w) => {
9
+ const url = cloudinary_1.cloudinary.url(publicId, {
10
+ secure: true,
11
+ sign_url: true,
12
+ transformation: [{ width: w, height: 550, crop: 'limit ' }],
13
+ resource_type: resourceType,
14
+ });
15
+ return { width: w, url };
16
+ });
17
+ return urls;
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
+ }
27
+ };
28
+ exports.generateSignedUrl = generateSignedUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bmostickit/common",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -22,6 +22,7 @@
22
22
  "@types/cookie-session": "^2.0.48",
23
23
  "@types/express": "^4.17.21",
24
24
  "@types/jsonwebtoken": "^9.0.6",
25
+ "cloudinary": "^2.7.0",
25
26
  "cookie-session": "^2.1.0",
26
27
  "express": "^4.19.2",
27
28
  "express-validator": "^7.0.1",