speedly 1.2.1 → 1.2.7

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/db/db.js CHANGED
@@ -21,7 +21,7 @@ const usingMongoDb = (collectionName, config = {}) => {
21
21
  };
22
22
  if (config?.path)
23
23
  __path = config.path;
24
- model = require(path_1.default.join(__path, collectionName));
24
+ model = require(path_1.default.join(require?.main?.filename || '', __path, collectionName));
25
25
  const actionHandler = {
26
26
  find: (match = {}) => {
27
27
  queryState.action = "find";
@@ -1,4 +1,4 @@
1
- declare const _default: (configField: string) => {
1
+ declare const configGetter: (configField: string) => {
2
2
  [key: string]: unknown;
3
3
  };
4
- export default _default;
4
+ export default configGetter;
@@ -1,13 +1,38 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // const { path } = require('../../app');
4
- const cosmiconfig_1 = require("cosmiconfig");
5
- exports.default = (configField) => {
6
- const explorer = (0, cosmiconfig_1.cosmiconfigSync)("speedly"); // اسم پروژه‌ت
7
- const result = explorer.search(process.cwd());
8
- if (result && result.config && result.config[configField]) {
9
- return result.config[configField];
10
- }
11
- else
6
+ const fs_1 = __importDefault(require("fs"));
7
+ const path_1 = __importDefault(require("path"));
8
+ const find = (field, ...args) => {
9
+ const rel = path_1.default.join.apply(null, [].slice.call(args));
10
+ if (!require?.main?.filename)
12
11
  return {};
12
+ return findStartingWith(path_1.default.dirname(require.main.filename), rel, field);
13
+ };
14
+ const findStartingWith = (start, rel, field) => {
15
+ const file = path_1.default.join(start, rel);
16
+ const formats = ['.ts', '.js', '.json'];
17
+ for (const [index, format] of formats.entries()) {
18
+ try {
19
+ if (fs_1.default.statSync(file + format))
20
+ return require(file + format)[field] || {};
21
+ }
22
+ catch (err) {
23
+ if (index + 1 != formats.length)
24
+ continue;
25
+ if (path_1.default.dirname(start) !== start) {
26
+ return findStartingWith(path_1.default.dirname(start), rel, field);
27
+ }
28
+ return {};
29
+ }
30
+ }
31
+ };
32
+ const configGetter = (configField) => {
33
+ const foundData = find(configField, 'speedly.config');
34
+ if (foundData)
35
+ return foundData;
36
+ return {};
13
37
  };
38
+ exports.default = configGetter;
package/dist/esm/db/db.js CHANGED
@@ -21,7 +21,7 @@ const usingMongoDb = (collectionName, config = {}) => {
21
21
  };
22
22
  if (config?.path)
23
23
  __path = config.path;
24
- model = require(path_1.default.join(__path, collectionName));
24
+ model = require(path_1.default.join(require?.main?.filename || '', __path, collectionName));
25
25
  const actionHandler = {
26
26
  find: (match = {}) => {
27
27
  queryState.action = "find";
@@ -1,4 +1,4 @@
1
- declare const _default: (configField: string) => {
1
+ declare const configGetter: (configField: string) => {
2
2
  [key: string]: unknown;
3
3
  };
4
- export default _default;
4
+ export default configGetter;
@@ -1,13 +1,38 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // const { path } = require('../../app');
4
- const cosmiconfig_1 = require("cosmiconfig");
5
- exports.default = (configField) => {
6
- const explorer = (0, cosmiconfig_1.cosmiconfigSync)("speedly"); // اسم پروژه‌ت
7
- const result = explorer.search(process.cwd());
8
- if (result && result.config && result.config[configField]) {
9
- return result.config[configField];
10
- }
11
- else
6
+ const fs_1 = __importDefault(require("fs"));
7
+ const path_1 = __importDefault(require("path"));
8
+ const find = (field, ...args) => {
9
+ const rel = path_1.default.join.apply(null, [].slice.call(args));
10
+ if (!require?.main?.filename)
12
11
  return {};
12
+ return findStartingWith(path_1.default.dirname(require.main.filename), rel, field);
13
+ };
14
+ const findStartingWith = (start, rel, field) => {
15
+ const file = path_1.default.join(start, rel);
16
+ const formats = ['.ts', '.js', '.json'];
17
+ for (const [index, format] of formats.entries()) {
18
+ try {
19
+ if (fs_1.default.statSync(file + format))
20
+ return require(file + format)[field] || {};
21
+ }
22
+ catch (err) {
23
+ if (index + 1 != formats.length)
24
+ continue;
25
+ if (path_1.default.dirname(start) !== start) {
26
+ return findStartingWith(path_1.default.dirname(start), rel, field);
27
+ }
28
+ return {};
29
+ }
30
+ }
31
+ };
32
+ const configGetter = (configField) => {
33
+ const foundData = find(configField, 'speedly.config');
34
+ if (foundData)
35
+ return foundData;
36
+ return {};
13
37
  };
38
+ exports.default = configGetter;
package/package.json CHANGED
@@ -1,39 +1,38 @@
1
- {
2
- "name": "speedly",
3
- "version": "1.2.1",
4
- "main": "dist/cjs/index.js",
5
- "module": "dist/esm/index.js",
6
- "types": "dist/esm/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "import": "./dist/esm/index.js",
10
- "require": "./dist/cjs/index.js"
11
- }
12
- },
13
- "scripts": {
14
- "build": "npm run build:cjs && npm run build:esm",
15
- "build:cjs": "tsc -p tsconfig.cjs.json",
16
- "build:esm": "tsc -p tsconfig.esm.json",
17
- "dev": "ts-node src/index.ts"
18
- },
19
- "author": "MAHSERIN",
20
- "license": "MIT",
21
- "description": "",
22
- "devDependencies": {
23
- "@types/express": "^5.0.3",
24
- "@types/multer": "^2.0.0",
25
- "@types/node": "^24.5.2",
26
- "ts-node": "^10.9.2",
27
- "typescript": "^5.9.2"
28
- },
29
- "dependencies": {
30
- "axios": "^1.11.0",
31
- "cosmiconfig": "^9.0.0",
32
- "express": "^5.1.0",
33
- "jsonwebtoken": "^9.0.2",
34
- "mongoose": "^8.18.2",
35
- "multer": "^2.0.2",
36
- "translate": "^3.0.1",
37
- "yup": "^1.7.1"
38
- }
39
- }
1
+ {
2
+ "name": "speedly",
3
+ "version": "1.2.7",
4
+ "main": "dist/cjs/index.js",
5
+ "module": "dist/esm/index.js",
6
+ "types": "dist/esm/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/esm/index.js",
10
+ "require": "./dist/cjs/index.js"
11
+ }
12
+ },
13
+ "scripts": {
14
+ "build": "npm run build:cjs && npm run build:esm",
15
+ "build:cjs": "tsc -p tsconfig.cjs.json",
16
+ "build:esm": "tsc -p tsconfig.esm.json",
17
+ "dev": "ts-node src/index.ts"
18
+ },
19
+ "author": "MAHSERIN",
20
+ "license": "MIT",
21
+ "description": "",
22
+ "devDependencies": {
23
+ "@types/express": "^5.0.3",
24
+ "@types/multer": "^2.0.0",
25
+ "@types/node": "^24.5.2",
26
+ "ts-node": "^10.9.2",
27
+ "typescript": "^5.9.2"
28
+ },
29
+ "dependencies": {
30
+ "axios": "^1.11.0",
31
+ "express": "^5.1.0",
32
+ "jsonwebtoken": "^9.0.2",
33
+ "mongoose": "^8.18.2",
34
+ "multer": "^2.0.2",
35
+ "translate": "^3.0.1",
36
+ "yup": "^1.7.1"
37
+ }
38
+ }