@metric-im/administrate 1.0.2 → 1.0.3

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.
Files changed (2) hide show
  1. package/multisite.mjs +10 -2
  2. package/package.json +1 -1
package/multisite.mjs CHANGED
@@ -211,6 +211,7 @@ export class MultiSite {
211
211
  static async attach(app,options) {
212
212
  const instance = new MultiSite(app,options);
213
213
  instance.config = new Config();
214
+
214
215
  // spawn declared sites
215
216
  if (fs.existsSync(resolve('./sites'))) {
216
217
  instance.sites = (fs.readdirSync(resolve('./sites'))).reduce((result,hostName)=>{
@@ -226,6 +227,7 @@ export class MultiSite {
226
227
  app.use('/',instance.routes());
227
228
  return instance;
228
229
  }
230
+
229
231
  routes() {
230
232
  const router = express.Router();
231
233
 
@@ -263,7 +265,7 @@ export class MultiSite {
263
265
  url: target,
264
266
  headers: headersToForward,
265
267
  data: payload,
266
- params: req.query,
268
+ // Don't pass params - req.url already contains query string
267
269
  validateStatus: () => true,
268
270
  timeout: 30000,
269
271
  responseType: 'stream'
@@ -285,7 +287,7 @@ export class MultiSite {
285
287
  url: target,
286
288
  headers: headersToForward,
287
289
  data: payload,
288
- params: req.query,
290
+ // Don't pass params - req.url already contains query string
289
291
  validateStatus: () => true,
290
292
  timeout: 30000,
291
293
  responseType: 'text'
@@ -338,6 +340,12 @@ export class Site {
338
340
  this.name = name;
339
341
  this.options = options;
340
342
  this.parent = parent;
343
+ try {
344
+ const envars = JSON.parse(process.env.SITE_ENV||{});
345
+ Object.assign(this.options.env,envars[this.name]||{});
346
+ } catch(e) {
347
+ console.log(`Unable to parse SITE_ENV... continuing: ${e.message}`);
348
+ }
341
349
  }
342
350
  static Spawn(name, options, parent) {
343
351
  const instance = new Site(name, options, parent);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metric-im/administrate",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Tools for site administration",
5
5
  "homepage": "https://github.com/metric-im/administrate#readme",
6
6
  "bugs": {