powr-sdk-api 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/admin/ratings.js +8 -4
- package/dist/services/mongo.js +3 -2
- package/package.json +67 -67
package/dist/admin/ratings.js
CHANGED
|
@@ -33,7 +33,8 @@ router.post("/", async (req, res) => {
|
|
|
33
33
|
createdAt: new Date()
|
|
34
34
|
};
|
|
35
35
|
try {
|
|
36
|
-
const
|
|
36
|
+
const db = await getDb();
|
|
37
|
+
const result = await db.collection("ratings").insertOne(ratingData);
|
|
37
38
|
if (result && result.insertedId) {
|
|
38
39
|
console.log("ratings added with ID:", result.insertedId);
|
|
39
40
|
return res.status(200).json({
|
|
@@ -77,7 +78,8 @@ router.get("/", async (req, res) => {
|
|
|
77
78
|
if (itemId) query.itemId = itemId;
|
|
78
79
|
if (userId) query.userId = userId;
|
|
79
80
|
console.log("Filter....:", query);
|
|
80
|
-
const
|
|
81
|
+
const db = await getDb();
|
|
82
|
+
const ratingData = await db.collection("ratings").find(query).toArray();
|
|
81
83
|
if (!ratingData || ratingData.length === 0) {
|
|
82
84
|
console.log("Data not found.");
|
|
83
85
|
return res.status(200).json({
|
|
@@ -111,7 +113,8 @@ router.delete("/", async (req, res) => {
|
|
|
111
113
|
});
|
|
112
114
|
}
|
|
113
115
|
try {
|
|
114
|
-
const
|
|
116
|
+
const db = await getDb();
|
|
117
|
+
const result = await db.collection("ratings").deleteOne({
|
|
115
118
|
_id: new ObjectId(ratingId),
|
|
116
119
|
projectId: projectId
|
|
117
120
|
});
|
|
@@ -147,7 +150,8 @@ router.get("/average", async (req, res) => {
|
|
|
147
150
|
});
|
|
148
151
|
}
|
|
149
152
|
try {
|
|
150
|
-
const
|
|
153
|
+
const db = await getDb();
|
|
154
|
+
const result = await db.collection("ratings").aggregate([{
|
|
151
155
|
$match: {
|
|
152
156
|
projectId,
|
|
153
157
|
itemId
|
package/dist/services/mongo.js
CHANGED
|
@@ -7,13 +7,14 @@ const {
|
|
|
7
7
|
MongoClient
|
|
8
8
|
} = require('mongodb');
|
|
9
9
|
const {
|
|
10
|
-
|
|
10
|
+
getConfig
|
|
11
11
|
} = require('../config');
|
|
12
12
|
let client = null;
|
|
13
13
|
let db = null;
|
|
14
14
|
const connectDB = async () => {
|
|
15
|
+
const config = getConfig();
|
|
15
16
|
if (!config.mongoUri) {
|
|
16
|
-
throw new Error('
|
|
17
|
+
throw new Error('MONGODB_URI environment variable is required');
|
|
17
18
|
}
|
|
18
19
|
try {
|
|
19
20
|
client = new MongoClient(config.mongoUri);
|
package/package.json
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "powr-sdk-api",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "Shared API core library for PowrStack projects",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist",
|
|
9
|
-
"README.md"
|
|
10
|
-
],
|
|
11
|
-
"scripts": {
|
|
12
|
-
"test": "jest --passWithNoTests",
|
|
13
|
-
"lint": "eslint .",
|
|
14
|
-
"build": "babel src -d dist",
|
|
15
|
-
"prepare": "npm run build",
|
|
16
|
-
"prepublishOnly": "npm run test"
|
|
17
|
-
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"api",
|
|
20
|
-
"express",
|
|
21
|
-
"middleware",
|
|
22
|
-
"error-handling",
|
|
23
|
-
"response-formatting",
|
|
24
|
-
"logging",
|
|
25
|
-
"swagger",
|
|
26
|
-
"documentation"
|
|
27
|
-
],
|
|
28
|
-
"author": "PowrStack",
|
|
29
|
-
"license": "ISC",
|
|
30
|
-
"repository": {
|
|
31
|
-
"type": "git",
|
|
32
|
-
"url": "git+https://github.com/powrstack/powr-sdk-api.git"
|
|
33
|
-
},
|
|
34
|
-
"bugs": {
|
|
35
|
-
"url": "https://github.com/powrstack/powr-sdk-api/issues"
|
|
36
|
-
},
|
|
37
|
-
"homepage": "https://github.com/powrstack/powr-sdk-api#readme",
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"@aws-sdk/client-s3": "^3.787.0",
|
|
40
|
-
"@google-cloud/storage": "^7.16.0",
|
|
41
|
-
"express": "^4.18.2",
|
|
42
|
-
"jsonwebtoken": "^9.0.2",
|
|
43
|
-
"swagger-jsdoc": "^6.2.8",
|
|
44
|
-
"swagger-ui-express": "^5.0.0",
|
|
45
|
-
"winston": "^3.17.0",
|
|
46
|
-
"mongodb": "^6.3.0",
|
|
47
|
-
"multer": "^1.4.5-lts.1",
|
|
48
|
-
"bcrypt": "^5.1.1"
|
|
49
|
-
},
|
|
50
|
-
"devDependencies": {
|
|
51
|
-
"@babel/cli": "^7.23.9",
|
|
52
|
-
"@babel/core": "^7.24.0",
|
|
53
|
-
"@babel/preset-env": "^7.24.0",
|
|
54
|
-
"@types/express": "^4.17.21",
|
|
55
|
-
"@types/swagger-jsdoc": "^6.0.4",
|
|
56
|
-
"@types/swagger-ui-express": "^4.1.6",
|
|
57
|
-
"eslint": "^8.57.0",
|
|
58
|
-
"jest": "^29.7.0",
|
|
59
|
-
"typescript": "^5.3.3"
|
|
60
|
-
},
|
|
61
|
-
"peerDependencies": {
|
|
62
|
-
"express": "^4.18.2"
|
|
63
|
-
},
|
|
64
|
-
"engines": {
|
|
65
|
-
"node": ">=14.0.0"
|
|
66
|
-
}
|
|
67
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "powr-sdk-api",
|
|
3
|
+
"version": "2.0.8",
|
|
4
|
+
"description": "Shared API core library for PowrStack projects",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "jest --passWithNoTests",
|
|
13
|
+
"lint": "eslint .",
|
|
14
|
+
"build": "babel src -d dist",
|
|
15
|
+
"prepare": "npm run build",
|
|
16
|
+
"prepublishOnly": "npm run test"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"api",
|
|
20
|
+
"express",
|
|
21
|
+
"middleware",
|
|
22
|
+
"error-handling",
|
|
23
|
+
"response-formatting",
|
|
24
|
+
"logging",
|
|
25
|
+
"swagger",
|
|
26
|
+
"documentation"
|
|
27
|
+
],
|
|
28
|
+
"author": "PowrStack",
|
|
29
|
+
"license": "ISC",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/powrstack/powr-sdk-api.git"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/powrstack/powr-sdk-api/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/powrstack/powr-sdk-api#readme",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@aws-sdk/client-s3": "^3.787.0",
|
|
40
|
+
"@google-cloud/storage": "^7.16.0",
|
|
41
|
+
"express": "^4.18.2",
|
|
42
|
+
"jsonwebtoken": "^9.0.2",
|
|
43
|
+
"swagger-jsdoc": "^6.2.8",
|
|
44
|
+
"swagger-ui-express": "^5.0.0",
|
|
45
|
+
"winston": "^3.17.0",
|
|
46
|
+
"mongodb": "^6.3.0",
|
|
47
|
+
"multer": "^1.4.5-lts.1",
|
|
48
|
+
"bcrypt": "^5.1.1"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@babel/cli": "^7.23.9",
|
|
52
|
+
"@babel/core": "^7.24.0",
|
|
53
|
+
"@babel/preset-env": "^7.24.0",
|
|
54
|
+
"@types/express": "^4.17.21",
|
|
55
|
+
"@types/swagger-jsdoc": "^6.0.4",
|
|
56
|
+
"@types/swagger-ui-express": "^4.1.6",
|
|
57
|
+
"eslint": "^8.57.0",
|
|
58
|
+
"jest": "^29.7.0",
|
|
59
|
+
"typescript": "^5.3.3"
|
|
60
|
+
},
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"express": "^4.18.2"
|
|
63
|
+
},
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">=14.0.0"
|
|
66
|
+
}
|
|
67
|
+
}
|