speedly 2.1.1 → 2.1.3
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/dist/cjs/config/init.js +0 -1
- package/dist/cjs/configs.default.d.ts +8 -0
- package/dist/cjs/configs.default.js +2 -1
- package/dist/cjs/document/document.js +9 -5
- package/dist/cjs/kit/db/db.js +8 -3
- package/dist/cjs/types/index.d.ts +1 -1
- package/dist/cjs/types/index.js +38 -5
- package/dist/cjs/util/importFromPwd.d.ts +1 -1
- package/dist/cjs/util/importFromPwd.js +2 -2
- package/dist/esm/config/init.js +0 -1
- package/dist/esm/configs.default.d.ts +8 -0
- package/dist/esm/configs.default.js +2 -1
- package/dist/esm/document/document.js +9 -5
- package/dist/esm/kit/db/db.js +8 -3
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/types/index.js +38 -5
- package/dist/esm/util/importFromPwd.d.ts +1 -1
- package/dist/esm/util/importFromPwd.js +2 -2
- package/package.json +2 -1
package/dist/cjs/config/init.js
CHANGED
|
@@ -37,7 +37,6 @@ function speedly(config = {}) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
console.log("init", 48, fs_1.default.existsSync(path_1.default.join(process.cwd(), "src/module")));
|
|
41
40
|
if (finalConfig.documentation &&
|
|
42
41
|
fs_1.default.existsSync(path_1.default.join(process.cwd(), "src/module")))
|
|
43
42
|
(0, document_1.default)(app, path_1.default.join(process.cwd(), "src/module"), finalConfig.documentation === true
|
|
@@ -31,6 +31,14 @@ export interface DefaultConfig {
|
|
|
31
31
|
translate: {
|
|
32
32
|
one_api_token: string;
|
|
33
33
|
};
|
|
34
|
+
document: {
|
|
35
|
+
editEntities?: {
|
|
36
|
+
[key: string]: {
|
|
37
|
+
rename?: string;
|
|
38
|
+
basePath?: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
34
42
|
}
|
|
35
43
|
declare const defaultConfigs: DefaultConfig;
|
|
36
44
|
export default defaultConfigs;
|
|
@@ -9,6 +9,8 @@ const path_1 = __importDefault(require("path"));
|
|
|
9
9
|
const swagger_ui_express_1 = __importDefault(require("swagger-ui-express"));
|
|
10
10
|
const swagger_themes_1 = require("swagger-themes");
|
|
11
11
|
const parser_1 = require("./parser");
|
|
12
|
+
const getConfig_1 = __importDefault(require("../util/getConfig"));
|
|
13
|
+
const config = (0, getConfig_1.default)('document');
|
|
12
14
|
const METHODS_WITH_BODY = ["post", "put", "patch"];
|
|
13
15
|
/* ===================== HELPERS ======================= */
|
|
14
16
|
function extractPath(layer) {
|
|
@@ -100,14 +102,15 @@ function scanRouter(router, base = "") {
|
|
|
100
102
|
}
|
|
101
103
|
/* ================== MAIN ANALYZER ===================== */
|
|
102
104
|
function routeAnalyzer(route, routerName) {
|
|
105
|
+
const realName = config.editEntities?.[routerName]?.rename || routerName;
|
|
103
106
|
const routerDetails = {};
|
|
104
107
|
const scanned = scanRouter(route);
|
|
105
108
|
scanned.forEach((route) => {
|
|
106
|
-
const fullPath = `/${routerName}${(0, parser_1.expressToSwagger)(route.path)}`;
|
|
109
|
+
const fullPath = `/${config.editEntities?.[routerName]?.basePath || routerName}${(0, parser_1.expressToSwagger)(route.path)}`;
|
|
107
110
|
routerDetails[fullPath] = {};
|
|
108
111
|
Object.entries(route.methods).forEach(([method, detail]) => {
|
|
109
112
|
const doc = {
|
|
110
|
-
tags: [routerName.replace(
|
|
113
|
+
tags: [realName || routerName.replace('_', ' ')],
|
|
111
114
|
description: "Public route",
|
|
112
115
|
};
|
|
113
116
|
const validation = detail.middlewares.find((mw) => mw.handle?.__validationSchema)?.handle.__validationSchema;
|
|
@@ -235,9 +238,10 @@ function RouterFetcher(baseDir, servers) {
|
|
|
235
238
|
try {
|
|
236
239
|
const router = require(routerPath);
|
|
237
240
|
paths = { ...paths, ...routeAnalyzer(router, mf) };
|
|
241
|
+
const realName = config.editEntities?.[mf]?.rename || mf;
|
|
238
242
|
tags.push({
|
|
239
|
-
name: mf.replace("_", " "),
|
|
240
|
-
description: `${mf} operations`,
|
|
243
|
+
name: realName || mf.replace("_", " "),
|
|
244
|
+
description: `${realName || mf} operations`,
|
|
241
245
|
});
|
|
242
246
|
}
|
|
243
247
|
catch (err) {
|
|
@@ -265,6 +269,6 @@ function swaggerLoader(app, baseDir = path_1.default.join(process.cwd(), "src/mo
|
|
|
265
269
|
const doc = RouterFetcher(baseDir, servers);
|
|
266
270
|
const theme = new swagger_themes_1.SwaggerTheme();
|
|
267
271
|
app.use("/docs", swagger_ui_express_1.default.serve, swagger_ui_express_1.default.setup(doc, {
|
|
268
|
-
customCss: theme.getBuffer(swagger_themes_1.SwaggerThemeNameEnum.
|
|
272
|
+
customCss: theme.getBuffer(swagger_themes_1.SwaggerThemeNameEnum.CLASSIC),
|
|
269
273
|
}));
|
|
270
274
|
}
|
package/dist/cjs/kit/db/db.js
CHANGED
|
@@ -9,6 +9,7 @@ const strToObj_1 = __importDefault(require("../../util/strToObj"));
|
|
|
9
9
|
const getConfig_1 = __importDefault(require("../../util/getConfig"));
|
|
10
10
|
const translator_1 = __importDefault(require("../../util/translator"));
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
|
+
const importFromPwd_1 = __importDefault(require("../../util/importFromPwd"));
|
|
12
13
|
let configs = (0, getConfig_1.default)("db");
|
|
13
14
|
const usingMongoDb = (collectionName, config = { type: "external" }) => {
|
|
14
15
|
let model;
|
|
@@ -18,9 +19,12 @@ const usingMongoDb = (collectionName, config = { type: "external" }) => {
|
|
|
18
19
|
};
|
|
19
20
|
if (config?.path)
|
|
20
21
|
__path = config.path;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
if (config.type == 'external') {
|
|
23
|
+
model = (0, importFromPwd_1.default)(__path, collectionName);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
model = require(path_1.default.join("../../model", collectionName));
|
|
27
|
+
}
|
|
24
28
|
if (model.default)
|
|
25
29
|
model = model.default;
|
|
26
30
|
const actionHandler = {
|
|
@@ -428,6 +432,7 @@ const usingMongoDb = (collectionName, config = { type: "external" }) => {
|
|
|
428
432
|
});
|
|
429
433
|
// if(req.query.select) data = data.select(req.query.select)
|
|
430
434
|
data = await data;
|
|
435
|
+
req.document = data;
|
|
431
436
|
if (queryState.events.after) {
|
|
432
437
|
await queryState.events.after(req, data);
|
|
433
438
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import yup from "yup";
|
|
1
|
+
import * as yup from "yup";
|
|
2
2
|
export = yup;
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -11,7 +44,7 @@ const mongoose_1 = require("mongoose");
|
|
|
11
44
|
const importFromPwd_1 = __importDefault(require("../util/importFromPwd"));
|
|
12
45
|
const path_1 = __importDefault(require("path"));
|
|
13
46
|
const media = (0, importFromPwd_1.default)(path_1.default.join(configs.model.path, "media"));
|
|
14
|
-
const
|
|
47
|
+
const yup = __importStar(require("yup"));
|
|
15
48
|
const fs_1 = __importDefault(require("fs"));
|
|
16
49
|
const lodash_1 = __importDefault(require("lodash"));
|
|
17
50
|
const types = {
|
|
@@ -42,7 +75,7 @@ const types = {
|
|
|
42
75
|
},
|
|
43
76
|
};
|
|
44
77
|
// Add a global method for strings to ensure they are valid ObjectIds
|
|
45
|
-
|
|
78
|
+
yup.addMethod(yup.string, "oid", function (errorMessage = "آیدی درست نیست") {
|
|
46
79
|
return this.test({
|
|
47
80
|
name: "oid",
|
|
48
81
|
message: errorMessage,
|
|
@@ -58,7 +91,7 @@ yup_1.default.addMethod(yup_1.default.string, "oid", function (errorMessage = "
|
|
|
58
91
|
},
|
|
59
92
|
});
|
|
60
93
|
});
|
|
61
|
-
|
|
94
|
+
yup.addMethod(yup.string, "media", function (type = "image") {
|
|
62
95
|
return this.test("media", "invalid media file", async function (value) {
|
|
63
96
|
const { path, createError } = this;
|
|
64
97
|
if (!value)
|
|
@@ -73,7 +106,7 @@ yup_1.default.addMethod(yup_1.default.string, "media", function (type = "image")
|
|
|
73
106
|
return true;
|
|
74
107
|
});
|
|
75
108
|
});
|
|
76
|
-
|
|
109
|
+
yup.addMethod(yup.array, "media", function (typeSchema = { ...types }) {
|
|
77
110
|
let mediaSchema;
|
|
78
111
|
return this.transform((value) => {
|
|
79
112
|
return value?.map((item) => {
|
|
@@ -152,4 +185,4 @@ yup_1.default.addMethod(yup_1.default.array, "media", function (typeSchema = { .
|
|
|
152
185
|
return true;
|
|
153
186
|
});
|
|
154
187
|
});
|
|
155
|
-
module.exports =
|
|
188
|
+
module.exports = yup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function importFromPwd(
|
|
1
|
+
export default function importFromPwd(...paths: string[]): any;
|
|
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = importFromPwd;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
function importFromPwd(
|
|
8
|
+
function importFromPwd(...paths) {
|
|
9
9
|
if (!require?.main?.filename)
|
|
10
10
|
return null;
|
|
11
11
|
const mainDir = path_1.default.dirname(require.main.filename);
|
|
12
|
-
const fullPath = path_1.default.join(mainDir,
|
|
12
|
+
const fullPath = path_1.default.join(mainDir, ...paths);
|
|
13
13
|
try {
|
|
14
14
|
return require(fullPath);
|
|
15
15
|
}
|
package/dist/esm/config/init.js
CHANGED
|
@@ -37,7 +37,6 @@ function speedly(config = {}) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
console.log("init", 48, fs_1.default.existsSync(path_1.default.join(process.cwd(), "src/module")));
|
|
41
40
|
if (finalConfig.documentation &&
|
|
42
41
|
fs_1.default.existsSync(path_1.default.join(process.cwd(), "src/module")))
|
|
43
42
|
(0, document_1.default)(app, path_1.default.join(process.cwd(), "src/module"), finalConfig.documentation === true
|
|
@@ -31,6 +31,14 @@ export interface DefaultConfig {
|
|
|
31
31
|
translate: {
|
|
32
32
|
one_api_token: string;
|
|
33
33
|
};
|
|
34
|
+
document: {
|
|
35
|
+
editEntities?: {
|
|
36
|
+
[key: string]: {
|
|
37
|
+
rename?: string;
|
|
38
|
+
basePath?: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
34
42
|
}
|
|
35
43
|
declare const defaultConfigs: DefaultConfig;
|
|
36
44
|
export default defaultConfigs;
|
|
@@ -9,6 +9,8 @@ const path_1 = __importDefault(require("path"));
|
|
|
9
9
|
const swagger_ui_express_1 = __importDefault(require("swagger-ui-express"));
|
|
10
10
|
const swagger_themes_1 = require("swagger-themes");
|
|
11
11
|
const parser_1 = require("./parser");
|
|
12
|
+
const getConfig_1 = __importDefault(require("../util/getConfig"));
|
|
13
|
+
const config = (0, getConfig_1.default)('document');
|
|
12
14
|
const METHODS_WITH_BODY = ["post", "put", "patch"];
|
|
13
15
|
/* ===================== HELPERS ======================= */
|
|
14
16
|
function extractPath(layer) {
|
|
@@ -100,14 +102,15 @@ function scanRouter(router, base = "") {
|
|
|
100
102
|
}
|
|
101
103
|
/* ================== MAIN ANALYZER ===================== */
|
|
102
104
|
function routeAnalyzer(route, routerName) {
|
|
105
|
+
const realName = config.editEntities?.[routerName]?.rename || routerName;
|
|
103
106
|
const routerDetails = {};
|
|
104
107
|
const scanned = scanRouter(route);
|
|
105
108
|
scanned.forEach((route) => {
|
|
106
|
-
const fullPath = `/${routerName}${(0, parser_1.expressToSwagger)(route.path)}`;
|
|
109
|
+
const fullPath = `/${config.editEntities?.[routerName]?.basePath || routerName}${(0, parser_1.expressToSwagger)(route.path)}`;
|
|
107
110
|
routerDetails[fullPath] = {};
|
|
108
111
|
Object.entries(route.methods).forEach(([method, detail]) => {
|
|
109
112
|
const doc = {
|
|
110
|
-
tags: [routerName.replace(
|
|
113
|
+
tags: [realName || routerName.replace('_', ' ')],
|
|
111
114
|
description: "Public route",
|
|
112
115
|
};
|
|
113
116
|
const validation = detail.middlewares.find((mw) => mw.handle?.__validationSchema)?.handle.__validationSchema;
|
|
@@ -235,9 +238,10 @@ function RouterFetcher(baseDir, servers) {
|
|
|
235
238
|
try {
|
|
236
239
|
const router = require(routerPath);
|
|
237
240
|
paths = { ...paths, ...routeAnalyzer(router, mf) };
|
|
241
|
+
const realName = config.editEntities?.[mf]?.rename || mf;
|
|
238
242
|
tags.push({
|
|
239
|
-
name: mf.replace("_", " "),
|
|
240
|
-
description: `${mf} operations`,
|
|
243
|
+
name: realName || mf.replace("_", " "),
|
|
244
|
+
description: `${realName || mf} operations`,
|
|
241
245
|
});
|
|
242
246
|
}
|
|
243
247
|
catch (err) {
|
|
@@ -265,6 +269,6 @@ function swaggerLoader(app, baseDir = path_1.default.join(process.cwd(), "src/mo
|
|
|
265
269
|
const doc = RouterFetcher(baseDir, servers);
|
|
266
270
|
const theme = new swagger_themes_1.SwaggerTheme();
|
|
267
271
|
app.use("/docs", swagger_ui_express_1.default.serve, swagger_ui_express_1.default.setup(doc, {
|
|
268
|
-
customCss: theme.getBuffer(swagger_themes_1.SwaggerThemeNameEnum.
|
|
272
|
+
customCss: theme.getBuffer(swagger_themes_1.SwaggerThemeNameEnum.CLASSIC),
|
|
269
273
|
}));
|
|
270
274
|
}
|
package/dist/esm/kit/db/db.js
CHANGED
|
@@ -9,6 +9,7 @@ const strToObj_1 = __importDefault(require("../../util/strToObj"));
|
|
|
9
9
|
const getConfig_1 = __importDefault(require("../../util/getConfig"));
|
|
10
10
|
const translator_1 = __importDefault(require("../../util/translator"));
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
|
+
const importFromPwd_1 = __importDefault(require("../../util/importFromPwd"));
|
|
12
13
|
let configs = (0, getConfig_1.default)("db");
|
|
13
14
|
const usingMongoDb = (collectionName, config = { type: "external" }) => {
|
|
14
15
|
let model;
|
|
@@ -18,9 +19,12 @@ const usingMongoDb = (collectionName, config = { type: "external" }) => {
|
|
|
18
19
|
};
|
|
19
20
|
if (config?.path)
|
|
20
21
|
__path = config.path;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
if (config.type == 'external') {
|
|
23
|
+
model = (0, importFromPwd_1.default)(__path, collectionName);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
model = require(path_1.default.join("../../model", collectionName));
|
|
27
|
+
}
|
|
24
28
|
if (model.default)
|
|
25
29
|
model = model.default;
|
|
26
30
|
const actionHandler = {
|
|
@@ -428,6 +432,7 @@ const usingMongoDb = (collectionName, config = { type: "external" }) => {
|
|
|
428
432
|
});
|
|
429
433
|
// if(req.query.select) data = data.select(req.query.select)
|
|
430
434
|
data = await data;
|
|
435
|
+
req.document = data;
|
|
431
436
|
if (queryState.events.after) {
|
|
432
437
|
await queryState.events.after(req, data);
|
|
433
438
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import yup from "yup";
|
|
1
|
+
import * as yup from "yup";
|
|
2
2
|
export = yup;
|
package/dist/esm/types/index.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -11,7 +44,7 @@ const mongoose_1 = require("mongoose");
|
|
|
11
44
|
const importFromPwd_1 = __importDefault(require("../util/importFromPwd"));
|
|
12
45
|
const path_1 = __importDefault(require("path"));
|
|
13
46
|
const media = (0, importFromPwd_1.default)(path_1.default.join(configs.model.path, "media"));
|
|
14
|
-
const
|
|
47
|
+
const yup = __importStar(require("yup"));
|
|
15
48
|
const fs_1 = __importDefault(require("fs"));
|
|
16
49
|
const lodash_1 = __importDefault(require("lodash"));
|
|
17
50
|
const types = {
|
|
@@ -42,7 +75,7 @@ const types = {
|
|
|
42
75
|
},
|
|
43
76
|
};
|
|
44
77
|
// Add a global method for strings to ensure they are valid ObjectIds
|
|
45
|
-
|
|
78
|
+
yup.addMethod(yup.string, "oid", function (errorMessage = "آیدی درست نیست") {
|
|
46
79
|
return this.test({
|
|
47
80
|
name: "oid",
|
|
48
81
|
message: errorMessage,
|
|
@@ -58,7 +91,7 @@ yup_1.default.addMethod(yup_1.default.string, "oid", function (errorMessage = "
|
|
|
58
91
|
},
|
|
59
92
|
});
|
|
60
93
|
});
|
|
61
|
-
|
|
94
|
+
yup.addMethod(yup.string, "media", function (type = "image") {
|
|
62
95
|
return this.test("media", "invalid media file", async function (value) {
|
|
63
96
|
const { path, createError } = this;
|
|
64
97
|
if (!value)
|
|
@@ -73,7 +106,7 @@ yup_1.default.addMethod(yup_1.default.string, "media", function (type = "image")
|
|
|
73
106
|
return true;
|
|
74
107
|
});
|
|
75
108
|
});
|
|
76
|
-
|
|
109
|
+
yup.addMethod(yup.array, "media", function (typeSchema = { ...types }) {
|
|
77
110
|
let mediaSchema;
|
|
78
111
|
return this.transform((value) => {
|
|
79
112
|
return value?.map((item) => {
|
|
@@ -152,4 +185,4 @@ yup_1.default.addMethod(yup_1.default.array, "media", function (typeSchema = { .
|
|
|
152
185
|
return true;
|
|
153
186
|
});
|
|
154
187
|
});
|
|
155
|
-
module.exports =
|
|
188
|
+
module.exports = yup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function importFromPwd(
|
|
1
|
+
export default function importFromPwd(...paths: string[]): any;
|
|
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = importFromPwd;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
function importFromPwd(
|
|
8
|
+
function importFromPwd(...paths) {
|
|
9
9
|
if (!require?.main?.filename)
|
|
10
10
|
return null;
|
|
11
11
|
const mainDir = path_1.default.dirname(require.main.filename);
|
|
12
|
-
const fullPath = path_1.default.join(mainDir,
|
|
12
|
+
const fullPath = path_1.default.join(mainDir, ...paths);
|
|
13
13
|
try {
|
|
14
14
|
return require(fullPath);
|
|
15
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "speedly",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Schema-driven backend framework for rapid API and admin panel development",
|
|
5
5
|
"author": "MAHSERIN",
|
|
6
6
|
"license": "MIT",
|
|
@@ -82,6 +82,7 @@
|
|
|
82
82
|
"@types/multer": "^2.0.0",
|
|
83
83
|
"@types/node": "^24.5.2",
|
|
84
84
|
"@types/swagger-ui-express": "^4.1.8",
|
|
85
|
+
"cookie-parser": "^1.4.7",
|
|
85
86
|
"ts-node": "^10.9.2",
|
|
86
87
|
"typescript": "^5.9.2"
|
|
87
88
|
},
|