biz-slide-core 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/entity/image.entity.js +18 -0
- package/dist/entity/index.js +26 -0
- package/dist/entity/png-svg.entity.js +19 -0
- package/dist/entity/ppt-event.entity.js +13 -0
- package/dist/entity/ppt-slide.entity.js +18 -0
- package/dist/entity/ppt.entity.js +30 -0
- package/dist/entity/slide-layout.entity.js +14 -0
- package/dist/entity/slide.entity.js +26 -0
- package/dist/entity/socket.entity.js +13 -0
- package/dist/entity/template.entity.js +14 -0
- package/dist/entity/user.entity.js +15 -0
- package/dist/index.js +21 -0
- package/dist/middleware/authentication.js +123 -0
- package/dist/middleware/index.js +19 -0
- package/dist/middleware/role.js +8 -0
- package/dist/middleware/schemaValidate.js +58 -0
- package/dist/resHandler/errorHandler.js +58 -0
- package/dist/resHandler/index.js +18 -0
- package/dist/resHandler/successHandler.js +8 -0
- package/dist/types/IController.js +2 -0
- package/dist/types/IRequest.js +2 -0
- package/dist/types/index.js +28 -0
- package/dist/utilities/callWithRetries.js +73 -0
- package/dist/utilities/createFolder.js +60 -0
- package/dist/utilities/encryptionUtils.js +66 -0
- package/dist/utilities/index.js +19 -0
- package/package.json +6 -2
- package/src/index.ts +5 -0
- package/{middleware → src/middleware}/authentication.ts +1 -1
- package/{utilities → src/utilities}/createFolder.ts +1 -1
- package/tsconfig.json +9 -107
- /package/{entity → src/entity}/image.entity.ts +0 -0
- /package/{entity → src/entity}/index.ts +0 -0
- /package/{entity → src/entity}/png-svg.entity.ts +0 -0
- /package/{entity → src/entity}/ppt-event.entity.ts +0 -0
- /package/{entity → src/entity}/ppt-slide.entity.ts +0 -0
- /package/{entity → src/entity}/ppt.entity.ts +0 -0
- /package/{entity → src/entity}/slide-layout.entity.ts +0 -0
- /package/{entity → src/entity}/slide.entity.ts +0 -0
- /package/{entity → src/entity}/socket.entity.ts +0 -0
- /package/{entity → src/entity}/template.entity.ts +0 -0
- /package/{entity → src/entity}/user.entity.ts +0 -0
- /package/{middleware → src/middleware}/index.ts +0 -0
- /package/{middleware → src/middleware}/role.ts +0 -0
- /package/{middleware → src/middleware}/schemaValidate.ts +0 -0
- /package/{resHandler → src/resHandler}/errorHandler.ts +0 -0
- /package/{resHandler → src/resHandler}/index.ts +0 -0
- /package/{resHandler → src/resHandler}/successHandler.ts +0 -0
- /package/{types → src/types}/IController.ts +0 -0
- /package/{types → src/types}/IRequest.ts +0 -0
- /package/{types → src/types}/index.ts +0 -0
- /package/{utilities → src/utilities}/callWithRetries.ts +0 -0
- /package/{utilities → src/utilities}/encryptionUtils.ts +0 -0
- /package/{utilities → src/utilities}/index.ts +0 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ImageModel = void 0;
|
4
|
+
var mongoose_1 = require("mongoose");
|
5
|
+
var ImageSchema = new mongoose_1.Schema({
|
6
|
+
focusPoint: { x: Number, y: Number },
|
7
|
+
url: { type: String, required: true },
|
8
|
+
radius: { type: String, required: true },
|
9
|
+
keywords: { type: [String], default: [] },
|
10
|
+
title: { type: String, required: true },
|
11
|
+
userId: { type: mongoose_1.Schema.Types.ObjectId, ref: "user" },
|
12
|
+
createdAt: { type: Date, default: Date.now() },
|
13
|
+
updatedAt: { type: Date, default: Date.now() },
|
14
|
+
deletedAt: { type: Date, default: null },
|
15
|
+
}, {
|
16
|
+
timestamps: true,
|
17
|
+
});
|
18
|
+
exports.ImageModel = (0, mongoose_1.model)("image", ImageSchema);
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./image.entity"), exports);
|
18
|
+
__exportStar(require("./png-svg.entity"), exports);
|
19
|
+
__exportStar(require("./ppt-event.entity"), exports);
|
20
|
+
__exportStar(require("./ppt-slide.entity"), exports);
|
21
|
+
__exportStar(require("./ppt.entity"), exports);
|
22
|
+
__exportStar(require("./slide-layout.entity"), exports);
|
23
|
+
__exportStar(require("./slide.entity"), exports);
|
24
|
+
__exportStar(require("./socket.entity"), exports);
|
25
|
+
__exportStar(require("./template.entity"), exports);
|
26
|
+
__exportStar(require("./user.entity"), exports);
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.PngSvgModel = void 0;
|
4
|
+
var mongoose_1 = require("mongoose");
|
5
|
+
var PngSvgSchema = new mongoose_1.Schema({
|
6
|
+
createdAt: { type: Date, default: Date.now() },
|
7
|
+
updatedAt: { type: Date, default: Date.now() },
|
8
|
+
deletedAt: { type: Date, default: null },
|
9
|
+
isLocked: { type: Boolean, default: false },
|
10
|
+
isCompleted: { type: Boolean, default: false },
|
11
|
+
userId: { type: String, default: null },
|
12
|
+
title: { type: String, default: null },
|
13
|
+
styleCategory: { type: String, default: null },
|
14
|
+
styleSubCategory: { type: String, default: null },
|
15
|
+
colors: { type: [{ type: String, default: null }], default: null, _id: false }
|
16
|
+
}, {
|
17
|
+
timestamps: true,
|
18
|
+
});
|
19
|
+
exports.PngSvgModel = (0, mongoose_1.model)("png-svg", PngSvgSchema);
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.PPTSlideEventModel = void 0;
|
4
|
+
var mongoose_1 = require("mongoose");
|
5
|
+
var PPTEventSchema = new mongoose_1.Schema({
|
6
|
+
createdAt: { type: Date, default: Date.now() },
|
7
|
+
updatedAt: { type: Date, default: Date.now() },
|
8
|
+
pptRef: { type: mongoose_1.Schema.Types.ObjectId, ref: 'ppt' },
|
9
|
+
message: { type: String, default: null }
|
10
|
+
}, {
|
11
|
+
timestamps: true,
|
12
|
+
});
|
13
|
+
exports.PPTSlideEventModel = (0, mongoose_1.model)("ppt-event", PPTEventSchema);
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.PPTSlideModel = void 0;
|
4
|
+
var mongoose_1 = require("mongoose");
|
5
|
+
var PPTSlideSchema = new mongoose_1.Schema({
|
6
|
+
createdAt: { type: Date, default: Date.now() },
|
7
|
+
updatedAt: { type: Date, default: Date.now() },
|
8
|
+
deletedAt: { type: Date, default: null },
|
9
|
+
pptRef: { type: mongoose_1.Schema.Types.ObjectId, ref: 'ppt' },
|
10
|
+
slideRef: { type: mongoose_1.Schema.Types.ObjectId, ref: 'slide' },
|
11
|
+
slideLayoutRef: { type: mongoose_1.Schema.Types.ObjectId, ref: 'slide-layout' },
|
12
|
+
title: { type: String, default: null },
|
13
|
+
rawData: { type: String, default: "{}" },
|
14
|
+
images: { type: String, default: "{}" },
|
15
|
+
}, {
|
16
|
+
timestamps: true,
|
17
|
+
});
|
18
|
+
exports.PPTSlideModel = (0, mongoose_1.model)("ppt-slide", PPTSlideSchema);
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.PPTModel = void 0;
|
4
|
+
var mongoose_1 = require("mongoose");
|
5
|
+
var questionSchema = new mongoose_1.Schema({
|
6
|
+
question: { type: String },
|
7
|
+
answer: { type: String }
|
8
|
+
}, {
|
9
|
+
timestamps: false,
|
10
|
+
_id: false
|
11
|
+
});
|
12
|
+
var PPTSchema = new mongoose_1.Schema({
|
13
|
+
createdAt: { type: Date, default: Date.now() },
|
14
|
+
updatedAt: { type: Date, default: Date.now() },
|
15
|
+
deletedAt: { type: Date, default: null },
|
16
|
+
isLocked: { type: Boolean, default: false },
|
17
|
+
isCompleted: { type: Boolean, default: false },
|
18
|
+
fileCreated: { type: Boolean, default: false },
|
19
|
+
userId: { type: String, default: null },
|
20
|
+
template_type: { type: String, default: null },
|
21
|
+
systemGeneratedtopics: { type: [String], default: [], _id: false },
|
22
|
+
questions: [questionSchema],
|
23
|
+
colors: { type: [String], default: [], _id: false },
|
24
|
+
prompt: { type: String, default: null },
|
25
|
+
templateRef: { type: mongoose_1.Schema.Types.ObjectId, ref: 'template' },
|
26
|
+
slideRefs: { type: [{ type: mongoose_1.Schema.Types.ObjectId, ref: 'ppt-slide' }], default: [], _id: false }
|
27
|
+
}, {
|
28
|
+
timestamps: true,
|
29
|
+
});
|
30
|
+
exports.PPTModel = (0, mongoose_1.model)("ppt", PPTSchema);
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.SlideLayoutModel = void 0;
|
4
|
+
var mongoose_1 = require("mongoose");
|
5
|
+
var SlideLayoutSchema = new mongoose_1.Schema({
|
6
|
+
name: { type: String, default: "", required: true },
|
7
|
+
templateId: { type: mongoose_1.Schema.Types.ObjectId, ref: "template" },
|
8
|
+
createdAt: { type: Date, default: Date.now() },
|
9
|
+
updatedAt: { type: Date, default: Date.now() },
|
10
|
+
deletedAt: { type: Date, default: null },
|
11
|
+
}, {
|
12
|
+
timestamps: true,
|
13
|
+
});
|
14
|
+
exports.SlideLayoutModel = (0, mongoose_1.model)("slide-layout", SlideLayoutSchema);
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.SlideModel = void 0;
|
4
|
+
var mongoose_1 = require("mongoose");
|
5
|
+
var layerSchema = new mongoose_1.Schema({
|
6
|
+
metaType: { type: String, enum: ['text', 'image', 'shape', 'list', 'table'] },
|
7
|
+
optionsMeta: { type: String },
|
8
|
+
chatMeta: { type: String },
|
9
|
+
}, {
|
10
|
+
timestamps: false,
|
11
|
+
_id: false
|
12
|
+
});
|
13
|
+
var SlideSchema = new mongoose_1.Schema({
|
14
|
+
name: { type: String, default: "", required: true },
|
15
|
+
postfix: { type: String, default: "" },
|
16
|
+
rules: { type: String, default: "" },
|
17
|
+
layers: [layerSchema],
|
18
|
+
slideLayoutId: { type: mongoose_1.Schema.Types.ObjectId, ref: "slide-layout" },
|
19
|
+
templateId: { type: mongoose_1.Schema.Types.ObjectId, ref: "template" },
|
20
|
+
createdAt: { type: Date, default: Date.now() },
|
21
|
+
updatedAt: { type: Date, default: Date.now() },
|
22
|
+
deletedAt: { type: Date, default: null },
|
23
|
+
}, {
|
24
|
+
timestamps: true,
|
25
|
+
});
|
26
|
+
exports.SlideModel = (0, mongoose_1.model)("slide", SlideSchema);
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.SocketModel = void 0;
|
4
|
+
var mongoose_1 = require("mongoose");
|
5
|
+
var SocketSchema = new mongoose_1.Schema({
|
6
|
+
createdAt: { type: Date, default: Date.now() },
|
7
|
+
updatedAt: { type: Date, default: Date.now() },
|
8
|
+
userId: { type: String, default: null },
|
9
|
+
socketIds: { type: [String], default: [] }
|
10
|
+
}, {
|
11
|
+
timestamps: true,
|
12
|
+
});
|
13
|
+
exports.SocketModel = (0, mongoose_1.model)("socket", SocketSchema);
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.TemplateModel = void 0;
|
4
|
+
var mongoose_1 = require("mongoose");
|
5
|
+
var TemplateSchema = new mongoose_1.Schema({
|
6
|
+
name: { type: String, default: "", required: true },
|
7
|
+
template_type: { type: String, default: "", required: true },
|
8
|
+
createdAt: { type: Date, default: Date.now() },
|
9
|
+
updatedAt: { type: Date, default: Date.now() },
|
10
|
+
deletedAt: { type: Date, default: null },
|
11
|
+
}, {
|
12
|
+
timestamps: true,
|
13
|
+
});
|
14
|
+
exports.TemplateModel = (0, mongoose_1.model)("template", TemplateSchema);
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.UserModel = void 0;
|
4
|
+
var mongoose_1 = require("mongoose");
|
5
|
+
var UserSchema = new mongoose_1.Schema({
|
6
|
+
email: { type: String, unique: true, sparse: true },
|
7
|
+
password: { type: String, default: null },
|
8
|
+
role: { type: String, default: null },
|
9
|
+
createdAt: { type: Date, default: Date.now() },
|
10
|
+
updatedAt: { type: Date, default: Date.now() },
|
11
|
+
deletedAt: { type: Date, default: null },
|
12
|
+
}, {
|
13
|
+
timestamps: true,
|
14
|
+
});
|
15
|
+
exports.UserModel = (0, mongoose_1.model)("user", UserSchema);
|
package/dist/index.js
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./entity"), exports);
|
18
|
+
__exportStar(require("./middleware"), exports);
|
19
|
+
__exportStar(require("./resHandler"), exports);
|
20
|
+
__exportStar(require("./types"), exports);
|
21
|
+
__exportStar(require("./utilities"), exports);
|
@@ -0,0 +1,123 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
+
function step(op) {
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
+
switch (op[0]) {
|
21
|
+
case 0: case 1: t = op; break;
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
+
default:
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
+
if (t[2]) _.ops.pop();
|
31
|
+
_.trys.pop(); continue;
|
32
|
+
}
|
33
|
+
op = body.call(thisArg, _);
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
+
}
|
37
|
+
};
|
38
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
39
|
+
var t = {};
|
40
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
41
|
+
t[p] = s[p];
|
42
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
43
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
44
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
45
|
+
t[p[i]] = s[p[i]];
|
46
|
+
}
|
47
|
+
return t;
|
48
|
+
};
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
50
|
+
exports.authorizeWithSlideApp = exports.authorize = void 0;
|
51
|
+
var utilities_1 = require("../utilities");
|
52
|
+
var entity_1 = require("../entity");
|
53
|
+
var authorize = function (roles) {
|
54
|
+
return function (req, res, next) {
|
55
|
+
return __awaiter(this, void 0, void 0, function () {
|
56
|
+
var token, user_1, hasAccess, _a, createdAt, updatedAt, deletedAt, password, rest;
|
57
|
+
return __generator(this, function (_b) {
|
58
|
+
switch (_b.label) {
|
59
|
+
case 0:
|
60
|
+
if (!req.headers.authorization) {
|
61
|
+
return [2 /*return*/, res.status(401).json({ message: 'Unauthorized' })];
|
62
|
+
}
|
63
|
+
if (!roles.length) {
|
64
|
+
return [2 /*return*/, res.status(401).json({ message: 'Unauthorized' })];
|
65
|
+
}
|
66
|
+
if (!req.headers.authorization) return [3 /*break*/, 3];
|
67
|
+
return [4 /*yield*/, (0, utilities_1.verifyUid)(req.headers.authorization)];
|
68
|
+
case 1:
|
69
|
+
token = _b.sent();
|
70
|
+
if (!token) {
|
71
|
+
return [2 /*return*/, res.status(401).json({ message: 'Session Expired' })];
|
72
|
+
}
|
73
|
+
return [4 /*yield*/, entity_1.UserModel.findOne({ email: token.value.email })];
|
74
|
+
case 2:
|
75
|
+
user_1 = _b.sent();
|
76
|
+
if (!user_1) {
|
77
|
+
return [2 /*return*/, res.status(401).json({ message: 'No User Found' })];
|
78
|
+
}
|
79
|
+
hasAccess = roles.find(function (role) { return role === user_1.role; });
|
80
|
+
if (!hasAccess) {
|
81
|
+
return [2 /*return*/, res.status(403).json({ message: 'Forbbiden' })];
|
82
|
+
}
|
83
|
+
_a = user_1.toObject(), createdAt = _a.createdAt, updatedAt = _a.updatedAt, deletedAt = _a.deletedAt, password = _a.password, rest = __rest(_a, ["createdAt", "updatedAt", "deletedAt", "password"]);
|
84
|
+
req.user = rest;
|
85
|
+
next();
|
86
|
+
_b.label = 3;
|
87
|
+
case 3: return [2 /*return*/];
|
88
|
+
}
|
89
|
+
});
|
90
|
+
});
|
91
|
+
};
|
92
|
+
};
|
93
|
+
exports.authorize = authorize;
|
94
|
+
var authorizeWithSlideApp = function () {
|
95
|
+
return function (req, res, next) {
|
96
|
+
return __awaiter(this, void 0, void 0, function () {
|
97
|
+
var token;
|
98
|
+
return __generator(this, function (_a) {
|
99
|
+
switch (_a.label) {
|
100
|
+
case 0:
|
101
|
+
if (!req.headers.authorization) {
|
102
|
+
return [2 /*return*/, res.status(401).json({ message: 'Unauthorized' })];
|
103
|
+
}
|
104
|
+
if (!req.headers.authorization) return [3 /*break*/, 2];
|
105
|
+
return [4 /*yield*/, (0, utilities_1.verifyUid)(req.headers.authorization)];
|
106
|
+
case 1:
|
107
|
+
token = _a.sent();
|
108
|
+
if (!token) {
|
109
|
+
return [2 /*return*/, res.status(401).json({ message: 'Session Expired' })];
|
110
|
+
}
|
111
|
+
// token.value.customerid
|
112
|
+
req.user = {
|
113
|
+
userId: "123" //token.value.customerid
|
114
|
+
};
|
115
|
+
next();
|
116
|
+
_a.label = 2;
|
117
|
+
case 2: return [2 /*return*/];
|
118
|
+
}
|
119
|
+
});
|
120
|
+
});
|
121
|
+
};
|
122
|
+
};
|
123
|
+
exports.authorizeWithSlideApp = authorizeWithSlideApp;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./authentication"), exports);
|
18
|
+
__exportStar(require("./role"), exports);
|
19
|
+
__exportStar(require("./schemaValidate"), exports);
|
@@ -0,0 +1,58 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
+
function step(op) {
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
+
switch (op[0]) {
|
21
|
+
case 0: case 1: t = op; break;
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
+
default:
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
+
if (t[2]) _.ops.pop();
|
31
|
+
_.trys.pop(); continue;
|
32
|
+
}
|
33
|
+
op = body.call(thisArg, _);
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
+
}
|
37
|
+
};
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
+
exports.validateSchema = void 0;
|
40
|
+
var validateSchema = function (schema) {
|
41
|
+
return function (req, res, next) {
|
42
|
+
return __awaiter(this, void 0, void 0, function () {
|
43
|
+
var error, errorMessage;
|
44
|
+
return __generator(this, function (_a) {
|
45
|
+
error = schema.validate(req.body, { abortEarly: false }).error;
|
46
|
+
if (error) {
|
47
|
+
errorMessage = error.details.map(function (err) { return err.message; }).join(', ');
|
48
|
+
return [2 /*return*/, res.status(400).json({ message: errorMessage })];
|
49
|
+
}
|
50
|
+
else {
|
51
|
+
next();
|
52
|
+
}
|
53
|
+
return [2 /*return*/];
|
54
|
+
});
|
55
|
+
});
|
56
|
+
};
|
57
|
+
};
|
58
|
+
exports.validateSchema = validateSchema;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
if (typeof b !== "function" && b !== null)
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
+
extendStatics(d, b);
|
13
|
+
function __() { this.constructor = d; }
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
+
};
|
16
|
+
})();
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
18
|
+
exports.errorHandler = exports.NotFoundRequestError = exports.BadRequestError = void 0;
|
19
|
+
var BadRequestError = /** @class */ (function (_super) {
|
20
|
+
__extends(BadRequestError, _super);
|
21
|
+
function BadRequestError(message) {
|
22
|
+
var _this = _super.call(this, message) || this;
|
23
|
+
_this.name = 'BadRequestError';
|
24
|
+
return _this;
|
25
|
+
}
|
26
|
+
return BadRequestError;
|
27
|
+
}(Error));
|
28
|
+
exports.BadRequestError = BadRequestError;
|
29
|
+
var NotFoundRequestError = /** @class */ (function (_super) {
|
30
|
+
__extends(NotFoundRequestError, _super);
|
31
|
+
function NotFoundRequestError(message) {
|
32
|
+
var _this = _super.call(this, message) || this;
|
33
|
+
_this.name = 'NotFoundRequestError';
|
34
|
+
return _this;
|
35
|
+
}
|
36
|
+
return NotFoundRequestError;
|
37
|
+
}(Error));
|
38
|
+
exports.NotFoundRequestError = NotFoundRequestError;
|
39
|
+
// Custom error handler middleware
|
40
|
+
var errorHandler = function (err, req, res, next) {
|
41
|
+
console.error(err.stack); // Log the error for debugging
|
42
|
+
var statusCode = 500; // Default status code
|
43
|
+
var errorMessage = 'Internal Server Error'; // Default error message
|
44
|
+
if (err instanceof BadRequestError) {
|
45
|
+
statusCode = 400;
|
46
|
+
errorMessage = err.message;
|
47
|
+
}
|
48
|
+
else if (err instanceof NotFoundRequestError) {
|
49
|
+
statusCode = 404;
|
50
|
+
errorMessage = err.message;
|
51
|
+
}
|
52
|
+
// Send an error response
|
53
|
+
res.status(statusCode).json({
|
54
|
+
message: errorMessage,
|
55
|
+
error: err.name // Optionally send the error name/type
|
56
|
+
});
|
57
|
+
};
|
58
|
+
exports.errorHandler = errorHandler;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./errorHandler"), exports);
|
18
|
+
__exportStar(require("./successHandler"), exports);
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.successHandler = void 0;
|
4
|
+
// Generic success handler middleware
|
5
|
+
var successHandler = function (data, req, res, next) {
|
6
|
+
res.status(200).json(data);
|
7
|
+
};
|
8
|
+
exports.successHandler = successHandler;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
exports.QUEUES = void 0;
|
18
|
+
__exportStar(require("./IController"), exports);
|
19
|
+
__exportStar(require("./IRequest"), exports);
|
20
|
+
var QUEUES;
|
21
|
+
(function (QUEUES) {
|
22
|
+
QUEUES["IMAGE_MODEL_BULK"] = "image-model-bulk";
|
23
|
+
QUEUES["IMAGE_MODEL_SINGLE"] = "image-model-single";
|
24
|
+
QUEUES["NOTIFICATION"] = "notification";
|
25
|
+
QUEUES["THUMBNAIL"] = "thumbnail";
|
26
|
+
QUEUES["PPT"] = "ppt";
|
27
|
+
QUEUES["PNG_SVG"] = "png-svg"; // to convert raster to vector image
|
28
|
+
})(QUEUES || (exports.QUEUES = QUEUES = {}));
|
@@ -0,0 +1,73 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
+
function step(op) {
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
+
switch (op[0]) {
|
21
|
+
case 0: case 1: t = op; break;
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
+
default:
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
+
if (t[2]) _.ops.pop();
|
31
|
+
_.trys.pop(); continue;
|
32
|
+
}
|
33
|
+
op = body.call(thisArg, _);
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
+
}
|
37
|
+
};
|
38
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
40
|
+
if (ar || !(i in from)) {
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
42
|
+
ar[i] = from[i];
|
43
|
+
}
|
44
|
+
}
|
45
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
46
|
+
};
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
48
|
+
exports.callWithRetries = void 0;
|
49
|
+
function callWithRetries(retryCount, failedMessage, functionRef) {
|
50
|
+
var args = [];
|
51
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
52
|
+
args[_i - 3] = arguments[_i];
|
53
|
+
}
|
54
|
+
return __awaiter(this, void 0, void 0, function () {
|
55
|
+
var error_1;
|
56
|
+
return __generator(this, function (_a) {
|
57
|
+
switch (_a.label) {
|
58
|
+
case 0:
|
59
|
+
_a.trys.push([0, 2, , 3]);
|
60
|
+
return [4 /*yield*/, functionRef.apply(void 0, args)];
|
61
|
+
case 1: return [2 /*return*/, _a.sent()];
|
62
|
+
case 2:
|
63
|
+
error_1 = _a.sent();
|
64
|
+
if (retryCount <= 0)
|
65
|
+
throw error_1;
|
66
|
+
console.log(failedMessage);
|
67
|
+
return [2 /*return*/, callWithRetries.apply(void 0, __spreadArray([retryCount - 1, failedMessage, functionRef], args, false))];
|
68
|
+
case 3: return [2 /*return*/];
|
69
|
+
}
|
70
|
+
});
|
71
|
+
});
|
72
|
+
}
|
73
|
+
exports.callWithRetries = callWithRetries;
|
@@ -0,0 +1,60 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
+
function step(op) {
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
+
switch (op[0]) {
|
21
|
+
case 0: case 1: t = op; break;
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
+
default:
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
+
if (t[2]) _.ops.pop();
|
31
|
+
_.trys.pop(); continue;
|
32
|
+
}
|
33
|
+
op = body.call(thisArg, _);
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
+
}
|
37
|
+
};
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
40
|
+
};
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
42
|
+
exports.createFolder = void 0;
|
43
|
+
var fs_1 = __importDefault(require("fs"));
|
44
|
+
function createFolder(folderPath) {
|
45
|
+
return __awaiter(this, void 0, void 0, function () {
|
46
|
+
return __generator(this, function (_a) {
|
47
|
+
try {
|
48
|
+
if (!fs_1.default.existsSync(folderPath)) {
|
49
|
+
fs_1.default.mkdirSync(folderPath);
|
50
|
+
}
|
51
|
+
console.log("Folder \"".concat(folderPath, "\" is ready."));
|
52
|
+
}
|
53
|
+
catch (error) {
|
54
|
+
console.error("Error: ".concat(error.message));
|
55
|
+
}
|
56
|
+
return [2 /*return*/];
|
57
|
+
});
|
58
|
+
});
|
59
|
+
}
|
60
|
+
exports.createFolder = createFolder;
|
@@ -0,0 +1,66 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
+
function step(op) {
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
+
switch (op[0]) {
|
21
|
+
case 0: case 1: t = op; break;
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
+
default:
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
+
if (t[2]) _.ops.pop();
|
31
|
+
_.trys.pop(); continue;
|
32
|
+
}
|
33
|
+
op = body.call(thisArg, _);
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
+
}
|
37
|
+
};
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
40
|
+
};
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
42
|
+
exports.verifyUid = exports.signUid = void 0;
|
43
|
+
var jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
44
|
+
var signUid = function (value) {
|
45
|
+
return jsonwebtoken_1.default.sign({ value: value }, process.env.JWTSECRET || 'secret', {
|
46
|
+
expiresIn: '8h' // expires in 8 hours
|
47
|
+
});
|
48
|
+
};
|
49
|
+
exports.signUid = signUid;
|
50
|
+
var verifyUid = function (token) { return __awaiter(void 0, void 0, void 0, function () {
|
51
|
+
return __generator(this, function (_a) {
|
52
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
53
|
+
var jwtToken = token.split(" ")[1];
|
54
|
+
jsonwebtoken_1.default.verify(jwtToken, process.env.JWTSECRET || 'secret', function (err, decoded) {
|
55
|
+
if (err) {
|
56
|
+
console.log(err);
|
57
|
+
resolve(null);
|
58
|
+
}
|
59
|
+
else {
|
60
|
+
resolve(decoded);
|
61
|
+
}
|
62
|
+
});
|
63
|
+
})];
|
64
|
+
});
|
65
|
+
}); };
|
66
|
+
exports.verifyUid = verifyUid;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./callWithRetries"), exports);
|
18
|
+
__exportStar(require("./createFolder"), exports);
|
19
|
+
__exportStar(require("./encryptionUtils"), exports);
|
package/package.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
{
|
2
2
|
"name": "biz-slide-core",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.1",
|
4
4
|
"description": "",
|
5
|
-
"main": "index.js",
|
5
|
+
"main": "dist/index.js",
|
6
6
|
"scripts": {
|
7
7
|
"build": "tsc",
|
8
8
|
"test": "echo \"Error: no test specified\" && exit 1"
|
@@ -15,5 +15,9 @@
|
|
15
15
|
"joi": "^17.11.0",
|
16
16
|
"jsonwebtoken": "^9.0.2",
|
17
17
|
"typescript": "^5.3.3"
|
18
|
+
},
|
19
|
+
"devDependencies": {
|
20
|
+
"@types/express": "^4.17.21",
|
21
|
+
"@types/jsonwebtoken": "^9.0.5"
|
18
22
|
}
|
19
23
|
}
|
package/src/index.ts
ADDED
@@ -18,7 +18,7 @@ const authorize = (roles: string[]) => {
|
|
18
18
|
return res.status(401).json({ message: 'Session Expired' })
|
19
19
|
}
|
20
20
|
|
21
|
-
let user = await UserModel.findOne({ email: token.value.email })
|
21
|
+
let user: any = await UserModel.findOne({ email: token.value.email })
|
22
22
|
|
23
23
|
if (!user) {
|
24
24
|
return res.status(401).json({ message: 'No User Found' })
|
package/tsconfig.json
CHANGED
@@ -1,109 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"compilerOptions": {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
/* Language and Environment */
|
14
|
-
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
15
|
-
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
16
|
-
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
17
|
-
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
18
|
-
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
19
|
-
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
20
|
-
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
21
|
-
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
22
|
-
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
23
|
-
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
24
|
-
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
25
|
-
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
26
|
-
|
27
|
-
/* Modules */
|
28
|
-
"module": "commonjs", /* Specify what module code is generated. */
|
29
|
-
// "rootDir": "./", /* Specify the root folder within your source files. */
|
30
|
-
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
31
|
-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
32
|
-
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
33
|
-
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
34
|
-
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
35
|
-
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
36
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
37
|
-
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
38
|
-
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
39
|
-
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
40
|
-
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
41
|
-
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
42
|
-
// "resolveJsonModule": true, /* Enable importing .json files. */
|
43
|
-
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
44
|
-
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
45
|
-
|
46
|
-
/* JavaScript Support */
|
47
|
-
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
48
|
-
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
49
|
-
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
50
|
-
|
51
|
-
/* Emit */
|
52
|
-
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
53
|
-
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
54
|
-
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
55
|
-
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
56
|
-
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
57
|
-
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
58
|
-
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
59
|
-
// "removeComments": true, /* Disable emitting comments. */
|
60
|
-
// "noEmit": true, /* Disable emitting files from a compilation. */
|
61
|
-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
62
|
-
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
63
|
-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
64
|
-
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
65
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
66
|
-
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
67
|
-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
68
|
-
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
69
|
-
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
70
|
-
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
71
|
-
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
72
|
-
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
73
|
-
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
74
|
-
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
75
|
-
|
76
|
-
/* Interop Constraints */
|
77
|
-
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
78
|
-
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
79
|
-
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
80
|
-
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
81
|
-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
82
|
-
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
83
|
-
|
84
|
-
/* Type Checking */
|
85
|
-
"strict": true, /* Enable all strict type-checking options. */
|
86
|
-
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
87
|
-
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
88
|
-
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
89
|
-
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
90
|
-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
91
|
-
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
92
|
-
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
93
|
-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
94
|
-
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
95
|
-
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
96
|
-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
97
|
-
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
98
|
-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
99
|
-
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
100
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
101
|
-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
102
|
-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
103
|
-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
104
|
-
|
105
|
-
/* Completeness */
|
106
|
-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
107
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
108
|
-
}
|
109
|
-
}
|
3
|
+
"target": "es5",
|
4
|
+
"module": "commonjs",
|
5
|
+
"outDir": "./dist", // Specify your desired output directory
|
6
|
+
"strict": true,
|
7
|
+
"esModuleInterop": true
|
8
|
+
},
|
9
|
+
"include": ["src/**/*.ts"],
|
10
|
+
"exclude": ["node_modules"]
|
11
|
+
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|