powr-sdk-api 2.0.9 → 2.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.
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 with projectId
22
- app.use('/admin', createAdminRoutes('67feef40059e70e9cf0db96b'));
21
+ // Mount admin routes (projectId from environment)
22
+ app.use('/admin', createAdminRoutes());
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 with projectId!
59
- app.use('/admin', createAdminRoutes('67feef40059e70e9cf0db96b'));
58
+ // One line integration!
59
+ app.use('/admin', createAdminRoutes());
60
60
 
61
61
  app.listen(3000);
62
62
  ```
@@ -17,14 +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 = projectId => {
20
+ const createAdminRoutes = () => {
21
21
  // Get config from environment variables
22
-
22
+ const {
23
+ getConfig
24
+ } = require('../config');
25
+ const config = getConfig();
23
26
  const router = express.Router();
24
27
 
25
28
  // Middleware to inject projectId into all requests
26
29
  router.use((req, res, next) => {
27
- req.projectId = projectId;
30
+ req.projectId = config.projectId;
28
31
  next();
29
32
  });
30
33
 
package/dist/config.js CHANGED
@@ -6,15 +6,17 @@
6
6
  const getConfig = () => {
7
7
  const config = {
8
8
  mongoUri: process.env.MONGODB_URI,
9
- jwtToken: process.env.JWT_TOKEN
9
+ projectId: process.env.PROJECT_ID,
10
+ jwtToken: process.env.JWT_TOKEN,
11
+ storageBucket: process.env.STORAGE_BUCKET
10
12
  };
11
13
 
12
14
  // Validate required configs
13
15
  if (!config.mongoUri) {
14
16
  throw new Error('MONGODB_URI environment variable is required');
15
17
  }
16
- if (!config.jwtToken) {
17
- throw new Error('JWT_TOKEN environment variable is required');
18
+ if (!config.projectId) {
19
+ throw new Error('PROJECT_ID environment variable is required');
18
20
  }
19
21
  return config;
20
22
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powr-sdk-api",
3
- "version": "2.0.9",
3
+ "version": "2.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",