powr-sdk-api 3.0.10 → 3.1.1

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.
@@ -14,7 +14,7 @@ router.get('/conversations', async (req, res) => {
14
14
  try {
15
15
  const userId = req.user.powrId;
16
16
  const userAccess = req.user.access;
17
- const projectId = req.query.projectId || req.projectId;
17
+ const projectId = req.projectId;
18
18
  console.log('Current user ID:', userId, 'Access:', userAccess, 'Project:', projectId);
19
19
  const db = await getDb();
20
20
  const conversations = await db.collection('conversations').find({
@@ -84,7 +84,7 @@ router.get('/conversations/:conversationId/messages', async (req, res) => {
84
84
  conversationId
85
85
  } = req.params;
86
86
  const userId = req.user.powrId;
87
- const projectId = req.query.projectId || req.projectId;
87
+ const projectId = req.projectId;
88
88
  const db = await getDb();
89
89
 
90
90
  // Verify user is part of conversation
@@ -310,7 +310,7 @@ router.get('/users', async (req, res) => {
310
310
  try {
311
311
  const userId = req.user.powrId;
312
312
  const userAccess = req.user.access;
313
- const projectId = req.query.projectId || req.projectId;
313
+ const projectId = req.projectId;
314
314
  console.log('Current user access level:', userAccess, 'Project:', projectId);
315
315
  const db = await getDb();
316
316
 
@@ -140,19 +140,15 @@ router.get('/getCount/:formName', async (req, res) => {
140
140
  const {
141
141
  formName
142
142
  } = req.params;
143
- const {
144
- projectId
145
- } = req.query;
143
+ const projectId = req.projectId;
146
144
  const db = await getDb();
147
145
  const studentsFormCollection = db.collection('studentsForm');
148
146
 
149
147
  // Build query object
150
148
  let query = {
151
- formName
149
+ formName,
150
+ projectId
152
151
  };
153
- if (projectId) {
154
- query.projectId = projectId;
155
- }
156
152
  const submissions = await studentsFormCollection.find(query).toArray();
157
153
  res.status(200).json({
158
154
  success: true,
@@ -85,9 +85,7 @@ router.post("/toggle", async (req, res) => {
85
85
 
86
86
  // Get all functions entries
87
87
  router.get('/', async (req, res) => {
88
- const {
89
- projectId
90
- } = req.query;
88
+ const projectId = req.projectId;
91
89
  try {
92
90
  const query = {
93
91
  projectId
@@ -116,9 +114,7 @@ router.get('/', async (req, res) => {
116
114
  // Create a new function
117
115
  router.post('/', async (req, res) => {
118
116
  try {
119
- const {
120
- projectId
121
- } = req.query;
117
+ const projectId = req.projectId;
122
118
  if (!projectId) {
123
119
  return res.status(400).json({
124
120
  success: false,
@@ -162,9 +158,7 @@ router.put('/:function', async (req, res) => {
162
158
  const {
163
159
  code
164
160
  } = req.body;
165
- const {
166
- projectId
167
- } = req.query;
161
+ const projectId = req.projectId;
168
162
  if (!projectId) {
169
163
  return res.status(400).json({
170
164
  success: false,
@@ -227,9 +221,7 @@ router.post("/:function", async (req, res) => {
227
221
  const {
228
222
  function: functionName
229
223
  } = req.params;
230
- const {
231
- projectId
232
- } = req.query;
224
+ const projectId = req.projectId;
233
225
  if (!projectId) {
234
226
  return res.status(400).json({
235
227
  success: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powr-sdk-api",
3
- "version": "3.0.10",
3
+ "version": "3.1.1",
4
4
  "description": "Shared API core library for PowrStack projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",