speedly 2.0.6 → 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/config/init.d.ts +2 -1
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +2 -3
- package/dist/cjs/kit/db/db.d.ts +2 -0
- package/dist/cjs/kit/db/db.js +30 -15
- package/dist/esm/config/init.d.ts +2 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -3
- package/dist/esm/kit/db/db.d.ts +2 -0
- package/dist/esm/kit/db/db.js +30 -15
- package/package.json +1 -1
|
@@ -8,8 +8,9 @@ type InitConfig = {
|
|
|
8
8
|
staticFiles?: boolean;
|
|
9
9
|
[key: string]: any;
|
|
10
10
|
};
|
|
11
|
+
export type InitFunction = (config?: InitConfig) => express.Express;
|
|
12
|
+
export type { InitConfig };
|
|
11
13
|
export default function speedly(config?: InitConfig): express.Express & {
|
|
12
14
|
speedlyConfig: InitConfig;
|
|
13
15
|
registerFallbacks: () => void;
|
|
14
16
|
};
|
|
15
|
-
export {};
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -3,12 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Router = void 0;
|
|
6
|
+
exports.speedly = exports.Router = void 0;
|
|
7
7
|
const init_1 = __importDefault(require("./config/init"));
|
|
8
|
+
exports.speedly = init_1.default;
|
|
8
9
|
// Export express types and classes
|
|
9
10
|
var express_1 = require("express");
|
|
10
11
|
Object.defineProperty(exports, "Router", { enumerable: true, get: function () { return express_1.Router; } });
|
|
11
12
|
// Override the default express() with our speedly`s functions
|
|
12
13
|
exports.default = init_1.default;
|
|
13
|
-
module.exports = init_1.default;
|
|
14
|
-
module.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]) => {
|
|
@@ -8,8 +8,9 @@ type InitConfig = {
|
|
|
8
8
|
staticFiles?: boolean;
|
|
9
9
|
[key: string]: any;
|
|
10
10
|
};
|
|
11
|
+
export type InitFunction = (config?: InitConfig) => express.Express;
|
|
12
|
+
export type { InitConfig };
|
|
11
13
|
export default function speedly(config?: InitConfig): express.Express & {
|
|
12
14
|
speedlyConfig: InitConfig;
|
|
13
15
|
registerFallbacks: () => void;
|
|
14
16
|
};
|
|
15
|
-
export {};
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -3,12 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Router = void 0;
|
|
6
|
+
exports.speedly = exports.Router = void 0;
|
|
7
7
|
const init_1 = __importDefault(require("./config/init"));
|
|
8
|
+
exports.speedly = init_1.default;
|
|
8
9
|
// Export express types and classes
|
|
9
10
|
var express_1 = require("express");
|
|
10
11
|
Object.defineProperty(exports, "Router", { enumerable: true, get: function () { return express_1.Router; } });
|
|
11
12
|
// Override the default express() with our speedly`s functions
|
|
12
13
|
exports.default = init_1.default;
|
|
13
|
-
module.exports = init_1.default;
|
|
14
|
-
module.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]) => {
|