@agranom/boykom-common 1.0.2 → 1.0.4
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/enums/grocery-category.enum.d.ts +1 -0
- package/dist/enums/grocery-category.enum.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.js +17 -0
- package/dist/providers/mongodb/index.d.ts +2 -0
- package/dist/providers/mongodb/index.js +18 -0
- package/dist/providers/mongodb/inject-database.d.ts +1 -0
- package/dist/providers/mongodb/inject-database.js +6 -0
- package/dist/providers/mongodb/mongodb.module.d.ts +14 -0
- package/dist/providers/mongodb/mongodb.module.js +85 -0
- package/package.json +5 -1
|
@@ -26,5 +26,6 @@ var GroceryCategory;
|
|
|
26
26
|
GroceryCategory["Fungi"] = "fungi";
|
|
27
27
|
GroceryCategory["Nuts"] = "nuts";
|
|
28
28
|
GroceryCategory["SemiProducts"] = "semi_products";
|
|
29
|
+
GroceryCategory["Recipe"] = "recipe";
|
|
29
30
|
GroceryCategory["Unknown"] = "unknown";
|
|
30
31
|
})(GroceryCategory || (exports.GroceryCategory = GroceryCategory = {}));
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './mongodb';
|
|
@@ -0,0 +1,17 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./mongodb"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./inject-database"), exports);
|
|
18
|
+
__exportStar(require("./mongodb.module"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const InjectDatabase: () => PropertyDecorator & ParameterDecorator;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
|
+
export declare class MongodbModule {
|
|
3
|
+
static forRootAsync({ uri }: {
|
|
4
|
+
uri: string | undefined;
|
|
5
|
+
}): {
|
|
6
|
+
module: typeof MongodbModule;
|
|
7
|
+
providers: {
|
|
8
|
+
provide: string;
|
|
9
|
+
useFactory: (logger: Logger) => Promise<import("mongodb").Db>;
|
|
10
|
+
inject: (typeof Logger)[];
|
|
11
|
+
}[];
|
|
12
|
+
exports: string[];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
36
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
39
|
+
};
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.MongodbModule = void 0;
|
|
42
|
+
const common_1 = require("@nestjs/common");
|
|
43
|
+
const mongodb_1 = require("mongodb");
|
|
44
|
+
let MongodbModule = (() => {
|
|
45
|
+
let _classDecorators = [(0, common_1.Global)(), (0, common_1.Module)({
|
|
46
|
+
providers: [common_1.Logger],
|
|
47
|
+
})];
|
|
48
|
+
let _classDescriptor;
|
|
49
|
+
let _classExtraInitializers = [];
|
|
50
|
+
let _classThis;
|
|
51
|
+
var MongodbModule = _classThis = class {
|
|
52
|
+
static forRootAsync({ uri }) {
|
|
53
|
+
if (!uri) {
|
|
54
|
+
throw new Error('uri is not defined');
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
module: MongodbModule,
|
|
58
|
+
providers: [
|
|
59
|
+
{
|
|
60
|
+
provide: 'DB',
|
|
61
|
+
useFactory: async (logger) => {
|
|
62
|
+
const client = new mongodb_1.MongoClient(uri);
|
|
63
|
+
logger.debug('Connecting to MongoDB...');
|
|
64
|
+
await client.connect();
|
|
65
|
+
logger.debug('MongoDB connected');
|
|
66
|
+
return client.db();
|
|
67
|
+
},
|
|
68
|
+
inject: [common_1.Logger],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
exports: ['DB'],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
__setFunctionName(_classThis, "MongodbModule");
|
|
76
|
+
(() => {
|
|
77
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
78
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
79
|
+
MongodbModule = _classThis = _classDescriptor.value;
|
|
80
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
81
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
82
|
+
})();
|
|
83
|
+
return MongodbModule = _classThis;
|
|
84
|
+
})();
|
|
85
|
+
exports.MongodbModule = MongodbModule;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agranom/boykom-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Boykom Common Library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -39,5 +39,9 @@
|
|
|
39
39
|
"rimraf": "^5.0.0",
|
|
40
40
|
"ts-jest": "^29.1.0",
|
|
41
41
|
"typescript": "^5.0.4"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@nestjs/common": ">=11.0.0",
|
|
45
|
+
"mongodb": ">=7.0.0"
|
|
42
46
|
}
|
|
43
47
|
}
|