speedly 1.2.33 → 1.2.35
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.d.ts
CHANGED
package/dist/cjs/db/db.js
CHANGED
|
@@ -11,17 +11,18 @@ const translator_1 = __importDefault(require("../util/translator"));
|
|
|
11
11
|
let configs = {
|
|
12
12
|
dbType: "mongodb",
|
|
13
13
|
path: "../models",
|
|
14
|
+
type: 'external',
|
|
14
15
|
dbEnv: "DB_URL",
|
|
15
16
|
...(0, getConfig_1.default)("db"),
|
|
16
17
|
};
|
|
17
|
-
const usingMongoDb = (collectionName, config = {}) => {
|
|
18
|
+
const usingMongoDb = (collectionName, config = { type: 'external' }) => {
|
|
18
19
|
let model;
|
|
19
20
|
let queryState = {
|
|
20
21
|
queries: [],
|
|
21
22
|
};
|
|
22
23
|
if (config?.path)
|
|
23
24
|
__path = config.path;
|
|
24
|
-
model = require(path_1.default.join(require.main?.filename || './', __path, collectionName));
|
|
25
|
+
model = require(path_1.default.join(...(config.type == 'external' ? [require.main?.filename || './', __path] : ['../model']), collectionName));
|
|
25
26
|
const actionHandler = {
|
|
26
27
|
find: (match = {}) => {
|
|
27
28
|
queryState.action = "find";
|
|
@@ -470,6 +471,7 @@ const db = (collectionName, config = configs) => {
|
|
|
470
471
|
dbType: "mongodb",
|
|
471
472
|
path: "../models",
|
|
472
473
|
dbEnv: "DB_URL",
|
|
474
|
+
type: 'external',
|
|
473
475
|
...(0, getConfig_1.default)("db"),
|
|
474
476
|
};
|
|
475
477
|
Object.entries(config).forEach(([key, value]) => {
|
|
@@ -9,12 +9,12 @@ const db_1 = __importDefault(require("../../db/db"));
|
|
|
9
9
|
const validator_1 = __importDefault(require("../../validator/validator"));
|
|
10
10
|
const v = require('./translation.validator');
|
|
11
11
|
const router = express_1.default.Router();
|
|
12
|
-
router.route('/').get((0, db_1.default)('translation').find())
|
|
12
|
+
router.route('/').get((0, db_1.default)('translation', { type: 'internal' }).find())
|
|
13
13
|
.post((req, res, next) => {
|
|
14
14
|
if (!req.body.auth || req.body.auth !== 'OKPJWSJD_Sdki') {
|
|
15
15
|
return res.status(403).json({ message: "Access Denied" });
|
|
16
16
|
}
|
|
17
17
|
next();
|
|
18
|
-
}, (0, db_1.default)('translation').create());
|
|
19
|
-
router.route('/:id').put(auth_1.default.admin(), (0, validator_1.default)(v.put), (0, db_1.default)('translation').findByIdAndUpdate());
|
|
18
|
+
}, (0, db_1.default)('translation', { type: 'internal' }).create());
|
|
19
|
+
router.route('/:id').put(auth_1.default.admin(), (0, validator_1.default)(v.put), (0, db_1.default)('translation', { type: 'internal' }).findByIdAndUpdate());
|
|
20
20
|
exports.default = router;
|
package/dist/esm/db/db.d.ts
CHANGED
package/dist/esm/db/db.js
CHANGED
|
@@ -11,17 +11,18 @@ const translator_1 = __importDefault(require("../util/translator"));
|
|
|
11
11
|
let configs = {
|
|
12
12
|
dbType: "mongodb",
|
|
13
13
|
path: "../models",
|
|
14
|
+
type: 'external',
|
|
14
15
|
dbEnv: "DB_URL",
|
|
15
16
|
...(0, getConfig_1.default)("db"),
|
|
16
17
|
};
|
|
17
|
-
const usingMongoDb = (collectionName, config = {}) => {
|
|
18
|
+
const usingMongoDb = (collectionName, config = { type: 'external' }) => {
|
|
18
19
|
let model;
|
|
19
20
|
let queryState = {
|
|
20
21
|
queries: [],
|
|
21
22
|
};
|
|
22
23
|
if (config?.path)
|
|
23
24
|
__path = config.path;
|
|
24
|
-
model = require(path_1.default.join(require.main?.filename || './', __path, collectionName));
|
|
25
|
+
model = require(path_1.default.join(...(config.type == 'external' ? [require.main?.filename || './', __path] : ['../model']), collectionName));
|
|
25
26
|
const actionHandler = {
|
|
26
27
|
find: (match = {}) => {
|
|
27
28
|
queryState.action = "find";
|
|
@@ -470,6 +471,7 @@ const db = (collectionName, config = configs) => {
|
|
|
470
471
|
dbType: "mongodb",
|
|
471
472
|
path: "../models",
|
|
472
473
|
dbEnv: "DB_URL",
|
|
474
|
+
type: 'external',
|
|
473
475
|
...(0, getConfig_1.default)("db"),
|
|
474
476
|
};
|
|
475
477
|
Object.entries(config).forEach(([key, value]) => {
|
|
@@ -9,12 +9,12 @@ const db_1 = __importDefault(require("../../db/db"));
|
|
|
9
9
|
const validator_1 = __importDefault(require("../../validator/validator"));
|
|
10
10
|
const v = require('./translation.validator');
|
|
11
11
|
const router = express_1.default.Router();
|
|
12
|
-
router.route('/').get((0, db_1.default)('translation').find())
|
|
12
|
+
router.route('/').get((0, db_1.default)('translation', { type: 'internal' }).find())
|
|
13
13
|
.post((req, res, next) => {
|
|
14
14
|
if (!req.body.auth || req.body.auth !== 'OKPJWSJD_Sdki') {
|
|
15
15
|
return res.status(403).json({ message: "Access Denied" });
|
|
16
16
|
}
|
|
17
17
|
next();
|
|
18
|
-
}, (0, db_1.default)('translation').create());
|
|
19
|
-
router.route('/:id').put(auth_1.default.admin(), (0, validator_1.default)(v.put), (0, db_1.default)('translation').findByIdAndUpdate());
|
|
18
|
+
}, (0, db_1.default)('translation', { type: 'internal' }).create());
|
|
19
|
+
router.route('/:id').put(auth_1.default.admin(), (0, validator_1.default)(v.put), (0, db_1.default)('translation', { type: 'internal' }).findByIdAndUpdate());
|
|
20
20
|
exports.default = router;
|