powr-sdk-api 2.3.2 → 2.3.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/config.js CHANGED
@@ -1,25 +1,9 @@
1
1
  "use strict";
2
2
 
3
- // Config for powr-sdk-api
4
- // Uses environment variables from host project
5
-
6
- const getConfig = () => {
7
- const config = {
8
- mongoUri: process.env.POWR_DB_URI,
9
- projectId: process.env.PROJECT_ID,
10
- jwtToken: process.env.JWT_TOKEN,
11
- storageBucket: process.env.STORAGE_BUCKET
12
- };
13
-
14
- // Validate required configs
15
- if (!config.mongoUri) {
16
- throw new Error('POWR_DB_URI environment variable is required');
17
- }
18
- if (!config.projectId) {
19
- throw new Error('PROJECT_ID environment variable is required');
20
- }
21
- return config;
3
+ const config = {
4
+ mongoUri: process.env.POWR_DB_URI,
5
+ projectId: process.env.PROJECT_ID,
6
+ jwtToken: process.env.JWT_TOKEN,
7
+ storageBucket: process.env.STORAGE_BUCKET
22
8
  };
23
- module.exports = {
24
- getConfig
25
- };
9
+ module.exports = config;
@@ -4,9 +4,7 @@ const jwt = require('jsonwebtoken');
4
4
  const {
5
5
  ObjectId
6
6
  } = require('mongodb');
7
- const {
8
- config
9
- } = require('../config');
7
+ const config = require('../config');
10
8
  const generateJWTToken = user => {
11
9
  return jwt.sign({
12
10
  userId: user._id
@@ -36,20 +34,17 @@ const verifyToken = async (req, res, next) => {
36
34
 
37
35
  // Attach user info to request object
38
36
  req.user = {
39
- powrId: new ObjectId(decoded.userId),
40
- // powr-base user ID
41
- access: 1 // Default access level for API users
37
+ powrId: decoded.userId // powr-base user ID
42
38
  };
43
39
  console.log("Authenticated user:", {
44
- powrId: req.user.powrId,
45
- access: req.user.access
40
+ powrId: req.user.powrId
46
41
  });
47
42
  next();
48
43
  } catch (error) {
49
44
  console.error("Error in auth middleware:", error);
50
45
  return res.status(401).json({
51
46
  success: false,
52
- message: "Invalid token."
47
+ message: error.message
53
48
  });
54
49
  }
55
50
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powr-sdk-api",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
4
4
  "description": "Shared API core library for PowrStack projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",