@plusscommunities/pluss-core-aws 1.5.0 → 1.5.2

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.
@@ -0,0 +1,16 @@
1
+ const getRef = require("../common/getRef");
2
+
3
+ module.exports = async (site, key) => {
4
+ return new Promise((resolve, reject) => {
5
+ getRef("sites", "Id", site)
6
+ .then((item) => {
7
+ if (item && item.Settings) {
8
+ return resolve(item.Settings[key]);
9
+ }
10
+ return resolve(undefined);
11
+ })
12
+ .catch((error) => {
13
+ return resolve(undefined);
14
+ });
15
+ });
16
+ };
@@ -0,0 +1,11 @@
1
+ const getSiteSetting = require("../../db/auth/getSiteSetting");
2
+
3
+ module.exports = async (site, key, expectedValue) => {
4
+ return new Promise(async (resolve) => {
5
+ if (!site) {
6
+ return resolve(false);
7
+ }
8
+ const siteSetting = await getSiteSetting(site, key);
9
+ return resolve(siteSetting === expectedValue);
10
+ });
11
+ };
@@ -1,22 +1,29 @@
1
- const replaceErrors = (key, value) => {
2
- if (value instanceof Error) {
3
- var error = {};
4
- Object.getOwnPropertyNames(value).forEach(function (key) {
5
- error[key] = value[key];
6
- });
7
- return error;
8
- }
9
- return value;
1
+ const getCircularReplacer = () => {
2
+ const seen = new WeakSet();
3
+ return (key, value) => {
4
+ if (value instanceof Error) {
5
+ var error = {};
6
+ Object.getOwnPropertyNames(value).forEach((key) => {
7
+ error[key] = value[key];
8
+ });
9
+ return error;
10
+ } else if (typeof value === "object" && value !== null) {
11
+ if (seen.has(value)) return;
12
+ seen.add(value);
13
+ }
14
+ return value;
15
+ };
10
16
  };
11
17
 
12
18
  module.exports = (statusCode, body) => {
13
19
  if ([400, 402, 422].includes(statusCode)) console.error(body);
20
+ const jsonBody = JSON.stringify(body.error || body, getCircularReplacer());
14
21
  return {
15
22
  statusCode,
16
23
  headers: {
17
24
  "Content-Type": "application/json",
18
25
  "Access-Control-Allow-Origin": "*",
19
26
  },
20
- body: JSON.stringify(body, replaceErrors),
27
+ body: jsonBody,
21
28
  };
22
29
  };
@@ -13,7 +13,7 @@ module.exports = async (
13
13
  excludeClientBranding = false,
14
14
  brandingImage = null,
15
15
  bcc = null,
16
- }
16
+ } = {}
17
17
  ) => {
18
18
  const { communityConfig, serverlessConfig } = getConfig();
19
19
 
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-core-aws",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "Core extension package for Pluss Communities platform",
5
5
  "scripts": {
6
6
  "betapatch": "npm version prepatch --preid=beta",
7
7
  "patch": "npm version patch",
8
- "betaupload": "npm publish --access public --tag beta",
8
+ "betaupload": "npm i && npm i && npm publish --access public --tag beta",
9
9
  "betaupload:p": "npm run betapatch && npm run betaupload",
10
- "upload": "npm publish --access public",
10
+ "upload": "npm i && npm i && npm publish --access public",
11
11
  "upload:p": "npm run patch && npm run upload"
12
12
  },
13
13
  "author": "Phillip Suh",