powr-sdk-api 2.0.4 → 2.0.5

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.
@@ -4,6 +4,9 @@ const express = require("express");
4
4
  const router = express.Router();
5
5
  const multer = require('multer');
6
6
  const path = require('path');
7
+ const {
8
+ getDb
9
+ } = require('../services/dbService');
7
10
  const upload = multer({
8
11
  storage: multer.memoryStorage(),
9
12
  fileFilter: function (req, file, cb) {
@@ -22,7 +25,8 @@ const upload = multer({
22
25
  router.get("/powrform", async (req, res) => {
23
26
  const projectId = req.query.projectId;
24
27
  try {
25
- const collection = req.db.collection("powrForm");
28
+ const db = getDb();
29
+ const collection = db.collection("powrForm");
26
30
  const forms = await collection.find({
27
31
  projectId
28
32
  }).toArray();
@@ -56,7 +60,8 @@ router.get('/:formName', async (req, res) => {
56
60
  message: 'projectId is required as query parameter'
57
61
  });
58
62
  }
59
- const collection = req.db.collection("powrForm");
63
+ const db = getDb();
64
+ const collection = db.collection("powrForm");
60
65
  const formData = await collection.findOne({
61
66
  formName,
62
67
  projectId
@@ -94,7 +99,8 @@ router.post('/studentform', async (req, res) => {
94
99
  email,
95
100
  ...otherFormFields
96
101
  } = formData;
97
- const studentsFormCollection = req.db.collection('studentsForm');
102
+ const db = getDb();
103
+ const studentsFormCollection = db.collection('studentsForm');
98
104
  const existingForm = await studentsFormCollection.findOne({
99
105
  whatsapp: whatsapp,
100
106
  projectId: projectId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powr-sdk-api",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "Shared API core library for PowrStack projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",