powr-sdk-api 2.0.7 → 2.0.9
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/README.md +4 -4
- package/dist/admin/forms.js +4 -8
- package/dist/admin/index.js +7 -1
- package/dist/admin/ratings.js +6 -6
- package/package.json +67 -67
package/README.md
CHANGED
|
@@ -18,8 +18,8 @@ const { createAdminRoutes } = require('powr-sdk-api');
|
|
|
18
18
|
|
|
19
19
|
const app = express();
|
|
20
20
|
|
|
21
|
-
// Mount admin routes
|
|
22
|
-
app.use('/admin', createAdminRoutes());
|
|
21
|
+
// Mount admin routes with projectId
|
|
22
|
+
app.use('/admin', createAdminRoutes('67feef40059e70e9cf0db96b'));
|
|
23
23
|
|
|
24
24
|
app.listen(3000);
|
|
25
25
|
```
|
|
@@ -55,8 +55,8 @@ const { createAdminRoutes } = require('powr-sdk-api');
|
|
|
55
55
|
|
|
56
56
|
const app = express();
|
|
57
57
|
|
|
58
|
-
// One line integration!
|
|
59
|
-
app.use('/admin', createAdminRoutes());
|
|
58
|
+
// One line integration with projectId!
|
|
59
|
+
app.use('/admin', createAdminRoutes('67feef40059e70e9cf0db96b'));
|
|
60
60
|
|
|
61
61
|
app.listen(3000);
|
|
62
62
|
```
|
package/dist/admin/forms.js
CHANGED
|
@@ -23,7 +23,7 @@ const upload = multer({
|
|
|
23
23
|
|
|
24
24
|
// GET all powrForm data based on projectId
|
|
25
25
|
router.get("/powrform", async (req, res) => {
|
|
26
|
-
const projectId = req.
|
|
26
|
+
const projectId = req.projectId;
|
|
27
27
|
try {
|
|
28
28
|
const db = await getDb();
|
|
29
29
|
const collection = db.collection("powrForm");
|
|
@@ -51,13 +51,11 @@ router.get('/:formName', async (req, res) => {
|
|
|
51
51
|
const {
|
|
52
52
|
formName
|
|
53
53
|
} = req.params;
|
|
54
|
-
const
|
|
55
|
-
projectId
|
|
56
|
-
} = req.query;
|
|
54
|
+
const projectId = req.projectId;
|
|
57
55
|
if (!projectId) {
|
|
58
56
|
return res.status(400).json({
|
|
59
57
|
success: false,
|
|
60
|
-
message: 'projectId is required
|
|
58
|
+
message: 'projectId is required'
|
|
61
59
|
});
|
|
62
60
|
}
|
|
63
61
|
const db = await getDb();
|
|
@@ -90,9 +88,7 @@ router.get('/:formName', async (req, res) => {
|
|
|
90
88
|
router.post('/studentform', async (req, res) => {
|
|
91
89
|
try {
|
|
92
90
|
const formData = req.body;
|
|
93
|
-
const
|
|
94
|
-
projectId
|
|
95
|
-
} = req.query;
|
|
91
|
+
const projectId = req.projectId;
|
|
96
92
|
const {
|
|
97
93
|
whatsapp,
|
|
98
94
|
formName,
|
package/dist/admin/index.js
CHANGED
|
@@ -17,11 +17,17 @@ const authRoutes = require('./auth');
|
|
|
17
17
|
const blogsRoutes = require('./blogs');
|
|
18
18
|
const slidesRoutes = require('./slides');
|
|
19
19
|
const notificationsRoutes = require('./notifications');
|
|
20
|
-
const createAdminRoutes =
|
|
20
|
+
const createAdminRoutes = projectId => {
|
|
21
21
|
// Get config from environment variables
|
|
22
22
|
|
|
23
23
|
const router = express.Router();
|
|
24
24
|
|
|
25
|
+
// Middleware to inject projectId into all requests
|
|
26
|
+
router.use((req, res, next) => {
|
|
27
|
+
req.projectId = projectId;
|
|
28
|
+
next();
|
|
29
|
+
});
|
|
30
|
+
|
|
25
31
|
// Mount all route modules
|
|
26
32
|
router.use('/comments', commentsRoutes);
|
|
27
33
|
// router.use('/files', filesRoutes); // Commented out for now
|
package/dist/admin/ratings.js
CHANGED
|
@@ -12,12 +12,12 @@ const {
|
|
|
12
12
|
//add ratings
|
|
13
13
|
router.post("/", async (req, res) => {
|
|
14
14
|
const {
|
|
15
|
-
projectId,
|
|
16
15
|
itemId,
|
|
17
16
|
rating,
|
|
18
17
|
review,
|
|
19
18
|
userId
|
|
20
19
|
} = req.body;
|
|
20
|
+
const projectId = req.projectId;
|
|
21
21
|
if (!rating || !review) {
|
|
22
22
|
return res.status(400).json({
|
|
23
23
|
success: false,
|
|
@@ -61,14 +61,14 @@ router.post("/", async (req, res) => {
|
|
|
61
61
|
//get ratings
|
|
62
62
|
router.get("/", async (req, res) => {
|
|
63
63
|
const {
|
|
64
|
-
projectId,
|
|
65
64
|
itemId,
|
|
66
65
|
userId
|
|
67
66
|
} = req.query;
|
|
67
|
+
const projectId = req.projectId;
|
|
68
68
|
if (!projectId) {
|
|
69
69
|
return res.status(400).json({
|
|
70
70
|
success: false,
|
|
71
|
-
message: "projectId is required
|
|
71
|
+
message: "projectId is required."
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
try {
|
|
@@ -103,9 +103,9 @@ router.get("/", async (req, res) => {
|
|
|
103
103
|
// delete ratings
|
|
104
104
|
router.delete("/", async (req, res) => {
|
|
105
105
|
const {
|
|
106
|
-
ratingId
|
|
107
|
-
projectId
|
|
106
|
+
ratingId
|
|
108
107
|
} = req.query;
|
|
108
|
+
const projectId = req.projectId;
|
|
109
109
|
if (!ratingId || !projectId) {
|
|
110
110
|
return res.status(400).json({
|
|
111
111
|
success: false,
|
|
@@ -140,9 +140,9 @@ router.delete("/", async (req, res) => {
|
|
|
140
140
|
// Calculate average rating
|
|
141
141
|
router.get("/average", async (req, res) => {
|
|
142
142
|
const {
|
|
143
|
-
projectId,
|
|
144
143
|
itemId
|
|
145
144
|
} = req.query;
|
|
145
|
+
const projectId = req.projectId;
|
|
146
146
|
if (!projectId || !itemId) {
|
|
147
147
|
return res.status(400).json({
|
|
148
148
|
success: false,
|
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.9",
|
|
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
|
+
}
|