@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.
@@ -0,0 +1,3 @@
1
+ export declare class EmailQuotaExceededError extends Error {
2
+ constructor(message: string);
3
+ }
@@ -0,0 +1,8 @@
1
+ export class EmailQuotaExceededError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.name = 'EmailQuotaExceededError';
5
+ Error.captureStackTrace(this, EmailQuotaExceededError);
6
+ }
7
+ }
8
+ //# sourceMappingURL=EmailQuotaExceededError.js.map
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.21.1/config/assets/logo.svg) Appsemble Node Utilities
1
+ # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.21.3/config/assets/logo.svg) Appsemble Node Utilities
2
2
 
3
3
  > NodeJS utilities used by Appsemble internally.
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@appsemble/node-utils)](https://www.npmjs.com/package/@appsemble/node-utils)
6
- [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.21.1/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.21.1)
6
+ [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.21.3/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.21.3)
7
7
  [![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](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.1/LICENSE.md) ©
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
@@ -30,3 +30,4 @@ export * from './server/routes/appRouter/iconHandler.js';
30
30
  export * from './server/controllers/index.js';
31
31
  export * from './server/types.js';
32
32
  export * from './koa.js';
33
+ export * from './EmailQuotaExceededError.js';
package/index.js CHANGED
@@ -30,4 +30,5 @@ export * from './server/routes/appRouter/iconHandler.js';
30
30
  export * from './server/controllers/index.js';
31
31
  export * from './server/types.js';
32
32
  export * from './koa.js';
33
+ export * from './EmailQuotaExceededError.js';
33
34
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/node-utils",
3
- "version": "0.21.1",
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.1",
35
- "@appsemble/utils": "0.21.1",
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
- await email({ action, data, mailer, user, options, context: ctx });
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) {