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 +4 -4
- package/dist/admin/index.js +6 -3
- package/dist/config.js +5 -3
- package/package.json +1 -1
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 (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
|
|
59
|
-
app.use('/admin', createAdminRoutes(
|
|
58
|
+
// One line integration!
|
|
59
|
+
app.use('/admin', createAdminRoutes());
|
|
60
60
|
|
|
61
61
|
app.listen(3000);
|
|
62
62
|
```
|
package/dist/admin/index.js
CHANGED
|
@@ -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 =
|
|
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
|
-
|
|
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.
|
|
17
|
-
throw new Error('
|
|
18
|
+
if (!config.projectId) {
|
|
19
|
+
throw new Error('PROJECT_ID environment variable is required');
|
|
18
20
|
}
|
|
19
21
|
return config;
|
|
20
22
|
};
|