powr-sdk-api 2.0.9 → 2.1.0
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/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
|
|