speedly 2.0.7 → 2.0.8
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/index.d.ts +5 -4
- package/dist/cjs/index.js +5 -37
- package/dist/cjs/kit/db/db.d.ts +2 -0
- package/dist/cjs/kit/db/db.js +30 -15
- package/dist/esm/index.d.ts +5 -4
- package/dist/esm/index.js +5 -37
- package/dist/esm/kit/db/db.d.ts +2 -0
- package/dist/esm/kit/db/db.js +30 -15
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
1
|
+
import speedly from "./config/init";
|
|
2
|
+
export { Request, Response, NextFunction, Application, Router, RequestHandler, ErrorRequestHandler, } from "express";
|
|
3
|
+
export type { InitConfig } from "./config/init";
|
|
4
|
+
export { speedly };
|
|
5
|
+
export default speedly;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,45 +1,13 @@
|
|
|
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
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
38
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.speedly = exports.Router = void 0;
|
|
39
7
|
const init_1 = __importDefault(require("./config/init"));
|
|
8
|
+
exports.speedly = init_1.default;
|
|
40
9
|
// Export express types and classes
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Object.assign(exportObject, init_1.default);
|
|
10
|
+
var express_1 = require("express");
|
|
11
|
+
Object.defineProperty(exports, "Router", { enumerable: true, get: function () { return express_1.Router; } });
|
|
44
12
|
// Override the default express() with our speedly`s functions
|
|
45
|
-
exports.default =
|
|
13
|
+
exports.default = init_1.default;
|
package/dist/cjs/kit/db/db.d.ts
CHANGED
package/dist/cjs/kit/db/db.js
CHANGED
|
@@ -14,6 +14,8 @@ let configs = {
|
|
|
14
14
|
path: "../models",
|
|
15
15
|
type: "external",
|
|
16
16
|
dbEnv: "DB_URL",
|
|
17
|
+
first: false,
|
|
18
|
+
response: true,
|
|
17
19
|
...(0, getConfig_1.default)("db"),
|
|
18
20
|
};
|
|
19
21
|
const usingMongoDb = (collectionName, config = { type: "external" }) => {
|
|
@@ -485,21 +487,32 @@ const usingMongoDb = (collectionName, config = { type: "external" }) => {
|
|
|
485
487
|
: []);
|
|
486
488
|
}
|
|
487
489
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
490
|
+
if (config?.response) {
|
|
491
|
+
const action = queryState.action?.match(/create|update|delet/i)?.[0] || "find";
|
|
492
|
+
if (queryState.action == "aggregate" && config.first && data[0]?.content.length)
|
|
493
|
+
data[0].content.length = data[0].content[0];
|
|
494
|
+
const resBody = queryState.action == "aggregate"
|
|
495
|
+
? {
|
|
496
|
+
message: config?.message ||
|
|
497
|
+
`the ${collectionName} was found successfully`,
|
|
498
|
+
content: [],
|
|
499
|
+
...data[0],
|
|
500
|
+
}
|
|
501
|
+
: {
|
|
502
|
+
content: data,
|
|
503
|
+
...{
|
|
504
|
+
detail: Object.keys(detail).length ? detail : undefined,
|
|
505
|
+
},
|
|
506
|
+
message: config?.message ||
|
|
507
|
+
`the ${collectionName} was ${action == "find" ? "found" : action + "ed"}`,
|
|
508
|
+
};
|
|
509
|
+
res.success
|
|
510
|
+
? res.success(200, resBody)
|
|
511
|
+
: res.status(200).json(resBody);
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
next();
|
|
515
|
+
}
|
|
503
516
|
}
|
|
504
517
|
}
|
|
505
518
|
catch (err) {
|
|
@@ -579,6 +592,8 @@ const db = (collectionName, config = configs) => {
|
|
|
579
592
|
path: "../models",
|
|
580
593
|
dbEnv: "DB_URL",
|
|
581
594
|
type: "external",
|
|
595
|
+
first: false,
|
|
596
|
+
response: true,
|
|
582
597
|
...(0, getConfig_1.default)("db"),
|
|
583
598
|
};
|
|
584
599
|
Object.entries(config).forEach(([key, value]) => {
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
1
|
+
import speedly from "./config/init";
|
|
2
|
+
export { Request, Response, NextFunction, Application, Router, RequestHandler, ErrorRequestHandler, } from "express";
|
|
3
|
+
export type { InitConfig } from "./config/init";
|
|
4
|
+
export { speedly };
|
|
5
|
+
export default speedly;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,45 +1,13 @@
|
|
|
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
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
38
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.speedly = exports.Router = void 0;
|
|
39
7
|
const init_1 = __importDefault(require("./config/init"));
|
|
8
|
+
exports.speedly = init_1.default;
|
|
40
9
|
// Export express types and classes
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Object.assign(exportObject, init_1.default);
|
|
10
|
+
var express_1 = require("express");
|
|
11
|
+
Object.defineProperty(exports, "Router", { enumerable: true, get: function () { return express_1.Router; } });
|
|
44
12
|
// Override the default express() with our speedly`s functions
|
|
45
|
-
exports.default =
|
|
13
|
+
exports.default = init_1.default;
|
package/dist/esm/kit/db/db.d.ts
CHANGED
package/dist/esm/kit/db/db.js
CHANGED
|
@@ -14,6 +14,8 @@ let configs = {
|
|
|
14
14
|
path: "../models",
|
|
15
15
|
type: "external",
|
|
16
16
|
dbEnv: "DB_URL",
|
|
17
|
+
first: false,
|
|
18
|
+
response: true,
|
|
17
19
|
...(0, getConfig_1.default)("db"),
|
|
18
20
|
};
|
|
19
21
|
const usingMongoDb = (collectionName, config = { type: "external" }) => {
|
|
@@ -485,21 +487,32 @@ const usingMongoDb = (collectionName, config = { type: "external" }) => {
|
|
|
485
487
|
: []);
|
|
486
488
|
}
|
|
487
489
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
490
|
+
if (config?.response) {
|
|
491
|
+
const action = queryState.action?.match(/create|update|delet/i)?.[0] || "find";
|
|
492
|
+
if (queryState.action == "aggregate" && config.first && data[0]?.content.length)
|
|
493
|
+
data[0].content.length = data[0].content[0];
|
|
494
|
+
const resBody = queryState.action == "aggregate"
|
|
495
|
+
? {
|
|
496
|
+
message: config?.message ||
|
|
497
|
+
`the ${collectionName} was found successfully`,
|
|
498
|
+
content: [],
|
|
499
|
+
...data[0],
|
|
500
|
+
}
|
|
501
|
+
: {
|
|
502
|
+
content: data,
|
|
503
|
+
...{
|
|
504
|
+
detail: Object.keys(detail).length ? detail : undefined,
|
|
505
|
+
},
|
|
506
|
+
message: config?.message ||
|
|
507
|
+
`the ${collectionName} was ${action == "find" ? "found" : action + "ed"}`,
|
|
508
|
+
};
|
|
509
|
+
res.success
|
|
510
|
+
? res.success(200, resBody)
|
|
511
|
+
: res.status(200).json(resBody);
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
next();
|
|
515
|
+
}
|
|
503
516
|
}
|
|
504
517
|
}
|
|
505
518
|
catch (err) {
|
|
@@ -579,6 +592,8 @@ const db = (collectionName, config = configs) => {
|
|
|
579
592
|
path: "../models",
|
|
580
593
|
dbEnv: "DB_URL",
|
|
581
594
|
type: "external",
|
|
595
|
+
first: false,
|
|
596
|
+
response: true,
|
|
582
597
|
...(0, getConfig_1.default)("db"),
|
|
583
598
|
};
|
|
584
599
|
Object.entries(config).forEach(([key, value]) => {
|