@appsemble/node-utils 0.21.1 → 0.21.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.
- package/EmailQuotaExceededError.d.ts +3 -0
- package/EmailQuotaExceededError.js +8 -0
- package/README.md +3 -3
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +9 -3
- package/server/controllers/action.js +11 -2
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#  Appsemble Node Utilities
|
|
2
2
|
|
|
3
3
|
> NodeJS utilities used by Appsemble internally.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@appsemble/node-utils)
|
|
6
|
-
[](https://gitlab.com/appsemble/appsemble/-/releases/0.21.3)
|
|
7
7
|
[](https://prettier.io)
|
|
8
8
|
|
|
9
9
|
## Table of Contents
|
|
@@ -26,5 +26,5 @@ compatibility is not guaranteed.
|
|
|
26
26
|
|
|
27
27
|
## License
|
|
28
28
|
|
|
29
|
-
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.21.
|
|
29
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.21.3/LICENSE.md) ©
|
|
30
30
|
[Appsemble](https://appsemble.com)
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsemble/node-utils",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.3",
|
|
4
4
|
"description": "NodeJS utilities used by Appsemble internally.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -21,6 +21,12 @@
|
|
|
21
21
|
"author": "Appsemble <info@appsemble.com> (https://appsemble.com)",
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"type": "module",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": [
|
|
26
|
+
"./index.js",
|
|
27
|
+
"./index.ts"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
24
30
|
"files": [
|
|
25
31
|
"**/*.d.ts",
|
|
26
32
|
"**/*.js",
|
|
@@ -31,8 +37,8 @@
|
|
|
31
37
|
"test": "vitest"
|
|
32
38
|
},
|
|
33
39
|
"dependencies": {
|
|
34
|
-
"@appsemble/types": "0.21.
|
|
35
|
-
"@appsemble/utils": "0.21.
|
|
40
|
+
"@appsemble/types": "0.21.3",
|
|
41
|
+
"@appsemble/utils": "0.21.3",
|
|
36
42
|
"@formatjs/fast-memoize": "^2.0.0",
|
|
37
43
|
"@fortawesome/fontawesome-free": "^6.0.0",
|
|
38
44
|
"@hapi/boom": "^10.0.0",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { getRemapperContext, logger } from '@appsemble/node-utils';
|
|
2
2
|
import { defaultLocale, formatRequestAction, remap } from '@appsemble/utils';
|
|
3
|
-
import { badGateway, badRequest, methodNotAllowed, notFound } from '@hapi/boom';
|
|
3
|
+
import { badGateway, badRequest, methodNotAllowed, notFound, tooManyRequests } from '@hapi/boom';
|
|
4
4
|
import axios from 'axios';
|
|
5
5
|
import { get, pick } from 'lodash-es';
|
|
6
|
+
import { EmailQuotaExceededError } from '../../EmailQuotaExceededError.js';
|
|
6
7
|
import pkg from '../../package.json' assert { type: 'json' };
|
|
7
8
|
/**
|
|
8
9
|
* These response headers are forwarded when proxying requests.
|
|
@@ -21,7 +22,15 @@ async function handleEmail(ctx, app, action, options) {
|
|
|
21
22
|
}
|
|
22
23
|
const { email, reloadUser } = options;
|
|
23
24
|
await reloadUser({ context: ctx });
|
|
24
|
-
|
|
25
|
+
try {
|
|
26
|
+
await email({ action, data, mailer, user, options, context: ctx });
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (error instanceof EmailQuotaExceededError) {
|
|
30
|
+
throw tooManyRequests(error.message);
|
|
31
|
+
}
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
25
34
|
ctx.status = 204;
|
|
26
35
|
}
|
|
27
36
|
async function handleNotify(ctx, app, action, options) {
|