express-sweet 1.0.35 → 1.0.36

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 (32) hide show
  1. package/CHANGELOG.md +45 -1
  2. package/dist/build.common.js +12 -12
  3. package/dist/build.esm.js +12 -12
  4. package/docs/index.html +41 -36
  5. package/package.json +1 -1
  6. package/types/database/index.d.ts +3 -3
  7. package/types/exceptions/index.d.ts +5 -5
  8. package/types/handlebars_helpers/index.d.ts +6 -6
  9. package/types/index.d.ts +7 -7
  10. package/types/interfaces/{AuthenticationOptions.d.ts → AuthenticationConfig.d.ts} +0 -14
  11. package/types/interfaces/BasicConfig.d.ts +74 -0
  12. package/types/interfaces/FaceMatch.d.ts +1 -1
  13. package/types/interfaces/index.d.ts +9 -9
  14. package/types/middlewares/CORS.d.ts +0 -1
  15. package/types/middlewares/Environment.d.ts +0 -1
  16. package/types/middlewares/{ErrorHandling.d.ts → ErrorHandler.d.ts} +0 -1
  17. package/types/middlewares/Http.d.ts +0 -1
  18. package/types/middlewares/Local.d.ts +0 -1
  19. package/types/middlewares/View.d.ts +0 -1
  20. package/types/middlewares/index.d.ts +8 -8
  21. package/types/routing/Router.d.ts +0 -1
  22. package/types/routing/index.d.ts +1 -1
  23. package/types/services/Authentication.d.ts +0 -1
  24. package/types/services/index.d.ts +3 -3
  25. package/types/utils/index.d.ts +4 -0
  26. package/types/utils/loadAuthenticationConfig.d.ts +8 -0
  27. package/types/utils/loadBasicConfig.d.ts +8 -0
  28. package/types/utils/loadDatabaseConfig.d.ts +8 -0
  29. package/types/utils/loadViewConfig.d.ts +8 -0
  30. package/types/interfaces/Config.d.ts +0 -66
  31. /package/types/interfaces/{DatabaseOptions.d.ts → DatabaseConfig.d.ts} +0 -0
  32. /package/types/interfaces/{ViewOptions.d.ts → ViewConfig.d.ts} +0 -0
package/docs/index.html CHANGED
@@ -81,7 +81,7 @@
81
81
  <!--begin::Title-->
82
82
  <h1 class="page-heading d-flex text-dark fw-bold fs-3 justify-content-center align-items-baseline my-0">
83
83
  <!-- <h1 class="page-heading d-flex text-dark fw-bold fs-3 flex-column justify-content-center my-0"> -->
84
- DevDocs<a href="#changelog" class="badge fw-semibold fs-7 px-2 ms-2 bg-body text-dark text-hover-primary shadow-sm">v1.0.35</a>
84
+ DevDocs<a href="#changelog" class="badge fw-semibold fs-7 px-2 ms-2 bg-body text-dark text-hover-primary shadow-sm">v1.0.36</a>
85
85
  </h1>
86
86
  <!--end::Title-->
87
87
  </div>
@@ -1290,7 +1290,7 @@ npm start</code></pre>
1290
1290
  <!--begin::Body-->
1291
1291
  <tbody>
1292
1292
  <tr>
1293
- <td class="w-250px"><code>env_path</code></td>
1293
+ <td class="w-250px"><code>env_path: string</code></td>
1294
1294
  <td>
1295
1295
  The path to the environment configuration file (<code>.env</code>).<br>
1296
1296
  When you start the Express Sweet application, the contents of the environment configuration file are automatically read and saved in <code>process.env</code>.<br>
@@ -1298,11 +1298,11 @@ npm start</code></pre>
1298
1298
  </td>
1299
1299
  </tr>
1300
1300
  <tr>
1301
- <td class="w-250px"><code>cors_enabled</code></td>
1301
+ <td class="w-250px"><code>cors_enabled: boolean</code></td>
1302
1302
  <td>Set to true to allow requests from another domain to the application.<br>The default is <code>false</code>.</td>
1303
1303
  </tr>
1304
1304
  <tr>
1305
- <td class="w-250px"><code>max_body_size</code></td>
1305
+ <td class="w-250px"><code>max_body_size: string|number</code></td>
1306
1306
  <td>
1307
1307
  Controls the maximum request body size.<br>
1308
1308
  If this is a number, then the value specifies the number of bytes.<br>
@@ -1311,11 +1311,11 @@ npm start</code></pre>
1311
1311
  </td>
1312
1312
  </tr>
1313
1313
  <tr>
1314
- <td class="w-250px"><code>router_dir</code></td>
1314
+ <td class="w-250px"><code>router_dir: string</code></td>
1315
1315
  <td>The directory path where the routes module is located.<br>The default is the <code>routes</code> directory directly under the application root.</td>
1316
1316
  </tr>
1317
1317
  <tr>
1318
- <td class="w-250px"><code>default_router</code></td>
1318
+ <td class="w-250px"><code>default_router: string</code></td>
1319
1319
  <td>
1320
1320
  Express Sweet can be told to load a default router when a URI is not present, as will be the case when root URL (<code>/</code>) is requested.<br>
1321
1321
  For example, to specify a default route, set <code>default_router</code> as follows.<br>
@@ -1366,7 +1366,7 @@ module.exports = router;</code></pre>
1366
1366
  </td>
1367
1367
  </tr>
1368
1368
  <tr>
1369
- <td class="w-250px"><code>rewrite_base_url</code></td>
1369
+ <td class="w-250px"><code>rewrite_base_url: (baseUrl: string) =&gt; string</code></td>
1370
1370
  <td>
1371
1371
  This is a hook that rewrites the base URL.<br>
1372
1372
  If you want to rewrite the app.locals.baseUrl property and the view&#039;s baseUrl variable, use this hook to return a new base URL.<br>
@@ -1389,18 +1389,21 @@ module.exports = router;</code></pre>
1389
1389
  </td>
1390
1390
  </tr>
1391
1391
  <tr>
1392
- <td class="w-250px"><code>error_handler</code></td>
1392
+ <td class="w-250px"><code>is_ajax: (req: express.Request) =&gt; boolean</code></td>
1393
1393
  <td>
1394
- This is a hook for error handling.<br>
1395
- For example, you can use it when you want to send an external notification of the error received by this hook.
1394
+ How to determine if it is an ajax request.<br>
1395
+ The default is that if there is an XMLHttpRequest in the request header (<code>req.xhr</code>) returns <code>true</code>.<br><br>
1396
+ For example, if there is no XMLHttpRequest in req(<code>express.Request</code>) and the Ajax endpoint starts with <code>/api</code>, a custom Ajax decision can be made like &quot;<code>return /^\/api\//.test(req.path)</code>&quot;.<br>
1396
1397
  <!--begin::Code-->
1397
1398
  <div class="py-5">
1398
1399
  <!--begin::Highlight-->
1399
1400
  <div class="highlight">
1400
1401
  <button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
1401
1402
  <div class="highlight-code">
1402
- <pre class="language-javascript"><code class="language-javascript">error_handler: async err =&gt; {
1403
- console.error(&#039;Error received&#039;);
1403
+ <pre class="language-javascript"><code class="language-javascript">is_ajax: req =&gt; {
1404
+ // If the request URL begins with /api, it is assumed to be Ajax.
1405
+ return /^\/api/.test(req.path);
1406
+ // return !!req.xhr;
1404
1407
  }</code></pre>
1405
1408
  </div>
1406
1409
  </div>
@@ -1409,6 +1412,32 @@ module.exports = router;</code></pre>
1409
1412
  <!--end::Code-->
1410
1413
  </td>
1411
1414
  </tr>
1415
+ <tr>
1416
+ <td class="w-250px"><code>hook_handle_error: (err: any, req: express.Request, res: express.Response, next: express.NextFunction) =&gt; void</code></td>
1417
+ <td>
1418
+ Hooks the default behavior on request errors.<br>
1419
+ If unset, simply returns an error HTTP status. (<code>res.status(err.status||500).end();</code>)
1420
+ <!--begin::Code-->
1421
+ <div class="py-5">
1422
+ <!--begin::Highlight-->
1423
+ <div class="highlight">
1424
+ <button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
1425
+ <div class="highlight-code">
1426
+ <pre class="language-javascript"><code class="language-javascript">hook_handle_error: (err, req, res, next) =&gt; {
1427
+ if (err.status === 404)
1428
+ // If the URL cannot be found, a 404 error screen (views/error-404.hbs) is displayed.
1429
+ res.render(&#039;error-404&#039;);
1430
+ else
1431
+ // For other errors, unknown error screen (views/error-unknown.hbs) is displayed.
1432
+ res.render(&#039;error-unknown&#039;);
1433
+ },</code></pre>
1434
+ </div>
1435
+ </div>
1436
+ <!--end::Highlight-->
1437
+ </div>
1438
+ <!--end::Code-->
1439
+ </td>
1440
+ </tr>
1412
1441
  </tbody>
1413
1442
  <!--end::Body-->
1414
1443
  </table>
@@ -5900,30 +5929,6 @@ failure_redirect: (req, res) =&gt; {
5900
5929
  The default is 24 hours (<code>86400000</code> milliseconds).
5901
5930
  </td>
5902
5931
  </tr>
5903
- <tr>
5904
- <td class="w-250px"><code>is_ajax: (req: express.Request) =&gt; boolean</code></td>
5905
- <td>
5906
- How to determine if it is an ajax request.<br>
5907
- The default is that if there is an XMLHttpRequest in the request header (<code>req.xhr</code>) returns <code>true</code>.<br><br>
5908
- For example, if there is no XMLHttpRequest in req(<code>express.Request</code>) and the Ajax endpoint starts with <code>/api</code>, a custom Ajax decision can be made like &quot;<code>return /^\/api\//.test(req.path)</code>&quot;.<br>
5909
- <!--begin::Code-->
5910
- <div class="py-5">
5911
- <!--begin::Highlight-->
5912
- <div class="highlight">
5913
- <button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
5914
- <div class="highlight-code">
5915
- <pre class="language-javascript"><code class="language-javascript">is_ajax: req =&gt; {
5916
- // If the request URL begins with /api, it is assumed to be Ajax.
5917
- return /^\/api/.test(req.path);
5918
- // return !!req.xhr;
5919
- }</code></pre>
5920
- </div>
5921
- </div>
5922
- <!--end::Highlight-->
5923
- </div>
5924
- <!--end::Code-->
5925
- </td>
5926
- </tr>
5927
5932
  </tbody>
5928
5933
  <!--end::Body-->
5929
5934
  </table>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-sweet",
3
- "version": "1.0.35",
3
+ "version": "1.0.36",
4
4
  "description": "Express framework extension.",
5
5
  "main": "dist/build.common.js",
6
6
  "module": "dist/build.esm.js",
@@ -1,4 +1,4 @@
1
- import Database from './Database';
2
- import Model from './Model';
3
- import loadModels from './loadModels';
1
+ import Database from '~/database/Database';
2
+ import Model from '~/database/Model';
3
+ import loadModels from '~/database/loadModels';
4
4
  export { Database, Model, loadModels };
@@ -1,6 +1,6 @@
1
- import CollectionCreationError from './CollectionCreationError';
2
- import CollectionDeletionError from './CollectionDeletionError';
3
- import FaceIndexError from './FaceIndexError';
4
- import MissingFaceInImageError from './MissingFaceInImageError';
5
- import MultipleFacesInImageError from './MultipleFacesInImageError';
1
+ import CollectionCreationError from '~/exceptions/CollectionCreationError';
2
+ import CollectionDeletionError from '~/exceptions/CollectionDeletionError';
3
+ import FaceIndexError from '~/exceptions/FaceIndexError';
4
+ import MissingFaceInImageError from '~/exceptions/MissingFaceInImageError';
5
+ import MultipleFacesInImageError from '~/exceptions/MultipleFacesInImageError';
6
6
  export { CollectionCreationError, CollectionDeletionError, FaceIndexError, MissingFaceInImageError, MultipleFacesInImageError, };
@@ -1,7 +1,7 @@
1
- import * as html from './html';
2
- import * as object from './object';
3
- import * as string from './string';
4
- import * as comparison from './comparison';
5
- import * as date from './date';
6
- import * as number from './number';
1
+ import * as html from '~/handlebars_helpers/html';
2
+ import * as object from '~/handlebars_helpers/object';
3
+ import * as string from '~/handlebars_helpers/string';
4
+ import * as comparison from '~/handlebars_helpers/comparison';
5
+ import * as date from '~/handlebars_helpers/date';
6
+ import * as number from '~/handlebars_helpers/number';
7
7
  export { html, object, string, comparison, date, number, };
package/types/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import mount from './mount';
2
- import * as database from './database';
3
- import * as services from './services';
4
- import * as utils from './utils';
5
- import * as middlewares from './middlewares';
6
- import * as exceptions from './exceptions';
7
- import * as interfaces from './interfaces';
1
+ import mount from '~/mount';
2
+ import * as database from '~/database';
3
+ import * as services from '~/services';
4
+ import * as utils from '~/utils';
5
+ import * as middlewares from '~/middlewares';
6
+ import * as exceptions from '~/exceptions';
7
+ import * as interfaces from '~/interfaces';
8
8
  export { mount, database, services, utils, middlewares, exceptions, interfaces };
@@ -105,18 +105,4 @@ export default interface {
105
105
  * @type {number}
106
106
  */
107
107
  expiration: number;
108
- /**
109
- * How to determine if it is an ajax request.
110
- * The default is that if there is an XMLHttpRequest in the request header (req.xhr) returns true.
111
- * For example, if there is no XMLHttpRequest in req(express.Request) and the Ajax endpoint starts with /api, a custom Ajax decision can be made like "return /^\/api\//.test(req.path)".
112
- *
113
- * @type {(req: express.Request) => boolean}
114
- * @example
115
- * is_ajax: req => {
116
- * // If the request URL begins with /api, it is assumed to be Ajax.
117
- * return /^\/api/.test(req.path);
118
- * // return !!req.xhr;
119
- * }
120
- */
121
- is_ajax: (req: express.Request) => boolean;
122
108
  }
@@ -0,0 +1,74 @@
1
+ import express from 'express';
2
+ /**
3
+ * Express Sweet basic configuration interface.
4
+ */
5
+ export default interface {
6
+ /**
7
+ * Environment variable file (.env) path, defaults to none (undefined).
8
+ * @type {string}
9
+ */
10
+ env_path?: string;
11
+ /**
12
+ * CORS permission, defaults to invalid (false).
13
+ * @type {{enabled: boolean}}
14
+ */
15
+ cors_enabled?: boolean;
16
+ /**
17
+ * Maximum body size you can request, defaults to `100kb`.
18
+ * @type {string|number}
19
+ */
20
+ max_body_size?: string | number;
21
+ /**
22
+ * Absolute path to the router directory, defaults to `<application root directory>/routes`.
23
+ * @type {string}
24
+ */
25
+ router_dir?: string;
26
+ /**
27
+ * The endpoint to run when the root URL is requested, defaults to none (undefined).
28
+ * @type {string}
29
+ */
30
+ default_router?: string;
31
+ /**
32
+ * This is a hook that rewrites the base URL.
33
+ * If you want to rewrite the app.locals.baseUrl property and the view's baseUrl variable, use this hook to return a new base URL.
34
+ * The default value is the referrer's origin (eg https://example.com).
35
+ *
36
+ * @example
37
+ * rewrite_base_url: baseUrl => {
38
+ * return `${baseUrl}/admin`;
39
+ * }
40
+ *
41
+ * @type {(baseUrl: string): string}
42
+ */
43
+ rewrite_base_url?: (baseUrl: string) => string;
44
+ /**
45
+ * How to determine if it is an ajax request.
46
+ * The default is that if there is an XMLHttpRequest in the request header (req.xhr) returns true.
47
+ * For example, if there is no XMLHttpRequest in req(express.Request) and the Ajax endpoint starts with /api, a custom Ajax decision can be made like "return /^\/api\//.test(req.path)".
48
+ *
49
+ * @type {(req: express.Request) => boolean}
50
+ * @example
51
+ * is_ajax: req => {
52
+ * // If the request URL begins with /api, it is assumed to be Ajax.
53
+ * return /^\/api/.test(req.path);
54
+ * // return !!req.xhr;
55
+ * }
56
+ */
57
+ is_ajax: (req: express.Request) => boolean;
58
+ /**
59
+ * Hooks the default behavior on request errors.
60
+ * If unset, simply returns an error HTTP status. (<code>res.status(err.status||500).end();</code>)
61
+ *
62
+ * @type {(err: any, req: express.Request, res: express.Response, next: express.NextFunction) => void}
63
+ * @example
64
+ * hook_handle_error: (err, req, res, next) => {
65
+ * if (err.status === 404)
66
+ * // If the URL cannot be found, a 404 error screen (views/error-404.hbs) is displayed.
67
+ * res.render('error-404');
68
+ * else
69
+ * // For other errors, unknown error screen (views/error-unknown.hbs) is displayed.
70
+ * res.render('error-unknown');
71
+ * },
72
+ */
73
+ hook_handle_error?: (err: any, req: express.Request, res: express.Response, next: express.NextFunction) => void;
74
+ }
@@ -1,4 +1,4 @@
1
- import BoundingBox from './BoundingBox';
1
+ import BoundingBox from '~/interfaces/BoundingBox';
2
2
  /**
3
3
  * This is the metadata structure of the bounding box coordinates, reliability (the bounding box contains a face), face ID, etc. returned by the searchFaces(), listFaces() methods, etc.
4
4
  */
@@ -1,9 +1,9 @@
1
- import AuthenticationOptions from './AuthenticationOptions';
2
- import Config from './Config';
3
- import DatabaseOptions from './DatabaseOptions';
4
- import FaceMatch from './FaceMatch';
5
- import BoundingBox from './BoundingBox';
6
- import RekognitionOptions from './RekognitionOptions';
7
- import SesOptions from './SesOptions';
8
- import ViewOptions from './ViewOptions';
9
- export { AuthenticationOptions, Config, DatabaseOptions, FaceMatch, BoundingBox, RekognitionOptions, SesOptions, ViewOptions };
1
+ import AuthenticationConfig from '~/interfaces/AuthenticationConfig';
2
+ import BasicConfig from '~/interfaces/BasicConfig';
3
+ import DatabaseConfig from '~/interfaces/DatabaseConfig';
4
+ import FaceMatch from '~/interfaces/FaceMatch';
5
+ import BoundingBox from '~/interfaces/BoundingBox';
6
+ import RekognitionOptions from '~/interfaces/RekognitionOptions';
7
+ import SesOptions from '~/interfaces/SesOptions';
8
+ import ViewConfig from '~/interfaces/ViewConfig';
9
+ export { AuthenticationConfig, BasicConfig, DatabaseConfig, FaceMatch, BoundingBox, RekognitionOptions, SesOptions, ViewConfig };
@@ -3,7 +3,6 @@ import express from 'express';
3
3
  * Enables the CORS.
4
4
  */
5
5
  export default class {
6
- #private;
7
6
  /**
8
7
  * Mount on application.
9
8
  */
@@ -3,7 +3,6 @@
3
3
  * Read the environment variable file in options.path and set it in "process.env".
4
4
  */
5
5
  export default class {
6
- #private;
7
6
  /**
8
7
  * Mount on application.
9
8
  */
@@ -3,7 +3,6 @@ import express from 'express';
3
3
  * Error handling.
4
4
  */
5
5
  export default class {
6
- #private;
7
6
  /**
8
7
  * Mount on application.
9
8
  */
@@ -3,7 +3,6 @@ import express from 'express';
3
3
  * Defines all the requisites in HTTP.
4
4
  */
5
5
  export default class {
6
- #private;
7
6
  /**
8
7
  * Mount on application.
9
8
  */
@@ -6,7 +6,6 @@ import express from 'express';
6
6
  * baseUrl: The base URL for this application.
7
7
  */
8
8
  export default class {
9
- #private;
10
9
  /**
11
10
  * Mount on application.
12
11
  */
@@ -3,7 +3,6 @@ import express from 'express';
3
3
  * Enable Handlebars template engine.
4
4
  */
5
5
  export default class {
6
- #private;
7
6
  /**
8
7
  * Mount on application.
9
8
  */
@@ -1,8 +1,8 @@
1
- import CORS from './CORS';
2
- import Environment from './Environment';
3
- import Global from './Global';
4
- import Http from './Http';
5
- import Local from './Local';
6
- import View from './View';
7
- import ErrorHandling from './ErrorHandling';
8
- export { CORS, Environment, Global, Http, Local, View, ErrorHandling };
1
+ import CORS from '~/middlewares/CORS';
2
+ import Environment from '~/middlewares/Environment';
3
+ import Global from '~/middlewares/Global';
4
+ import Http from '~/middlewares/Http';
5
+ import Local from '~/middlewares/Local';
6
+ import View from '~/middlewares/View';
7
+ import ErrorHandler from '~/middlewares/ErrorHandler';
8
+ export { CORS, Environment, Global, Http, Local, View, ErrorHandler, };
@@ -6,7 +6,6 @@ import express from 'express';
6
6
  * For example, if you have "routes/api/users.js", you can request the method in "user.js (ts)" with the base URL as "https:////api/users".
7
7
  */
8
8
  export default class {
9
- #private;
10
9
  /**
11
10
  * Mount on application.
12
11
  */
@@ -1,2 +1,2 @@
1
- import Router from './Router';
1
+ import Router from '~/routing/Router';
2
2
  export { Router };
@@ -3,7 +3,6 @@ import express from 'express';
3
3
  * User authentication service.
4
4
  */
5
5
  export default class {
6
- #private;
7
6
  /**
8
7
  * Authenticate the user.
9
8
  *
@@ -1,4 +1,4 @@
1
- import AWSRekognitionClient from './AWSRekognitionClient';
2
- import Authentication from './Authentication';
3
- import AWSSesClient from './AWSSesClient';
1
+ import AWSRekognitionClient from '~/services/AWSRekognitionClient';
2
+ import Authentication from '~/services/Authentication';
3
+ import AWSSesClient from '~/services/AWSSesClient';
4
4
  export { AWSRekognitionClient, Authentication, AWSSesClient, };
@@ -4,5 +4,9 @@ declare const _default: {
4
4
  isFunction: (value: any) => boolean;
5
5
  isObject: (value: any) => boolean;
6
6
  isString: (value: any) => boolean;
7
+ loadAuthenticationConfig: () => import("../interfaces").AuthenticationConfig;
8
+ loadBasicConfig: () => import("../interfaces").BasicConfig;
9
+ loadDatabaseConfig: () => import("sequelize").Options;
10
+ loadViewConfig: () => import("../interfaces").ViewConfig;
7
11
  };
8
12
  export default _default;
@@ -0,0 +1,8 @@
1
+ import AuthenticationConfig from '~/interfaces/AuthenticationConfig';
2
+ /**
3
+ * Get Authentication configuration (config/authentication).
4
+ *
5
+ * @return {AuthenticationConfig} Loaded configuration.
6
+ */
7
+ declare const _default: () => AuthenticationConfig;
8
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import BasicConfig from '~/interfaces/BasicConfig';
2
+ /**
3
+ * Get basic configuration (config/config).
4
+ *
5
+ * @return {BasicConfig} Loaded configuration.
6
+ */
7
+ declare const _default: () => BasicConfig;
8
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import sequelize from 'sequelize';
2
+ /**
3
+ * Get database configuration (config/database).
4
+ *
5
+ * @return {sequelize.Options} Loaded configuration.
6
+ */
7
+ declare const _default: () => sequelize.Options;
8
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import ViewConfig from '~/interfaces/ViewConfig';
2
+ /**
3
+ * Get view configuration (config/view).
4
+ *
5
+ * @return {ViewConfig} Loaded configuration.
6
+ */
7
+ declare const _default: () => ViewConfig;
8
+ export default _default;
@@ -1,66 +0,0 @@
1
- /**
2
- * Express Sweet basic configuration interface.
3
- */
4
- export default interface {
5
- /**
6
- * Environment variable file (.env) path, defaults to none (undefined).
7
- * @type {string}
8
- */
9
- env_path?: string;
10
- /**
11
- * CORS permission, defaults to invalid (false).
12
- * @type {{enabled: boolean}}
13
- */
14
- cors_enabled?: boolean;
15
- /**
16
- * Maximum body size you can request, defaults to `100kb`.
17
- * @type {string|number}
18
- */
19
- max_body_size?: string | number;
20
- /**
21
- * Absolute path to the router directory, defaults to `<application root directory>/routes`.
22
- * @type {string}
23
- */
24
- router_dir?: string;
25
- /**
26
- * The endpoint to run when the root URL is requested, defaults to none (undefined).
27
- * @type {string}
28
- */
29
- default_router?: string;
30
- /**
31
- * This is a hook that rewrites the base URL.
32
- * If you want to rewrite the app.locals.baseUrl property and the view's baseUrl variable, use this hook to return a new base URL.
33
- * The default value is the referrer's origin (eg https://example.com).
34
- *
35
- * @example
36
- * rewrite_base_url: baseUrl => {
37
- * return `${baseUrl}/admin`;
38
- * }
39
- *
40
- * @type {(baseUrl: string): string}
41
- */
42
- rewrite_base_url?: (baseUrl: string) => string;
43
- /**
44
- * This is a hook for error handling.
45
- * For example, you can use it when you want to send an external notification of the error received by this hook.
46
- *
47
- * @example
48
- * error_handler: async err => {
49
- * // Notify system administrator of error.
50
- * return new Promise((resolve, reject) => {
51
- * const sendmail = require('sendmail')();
52
- * sendmail({
53
- * from: 'no-reply@example.com',
54
- * to: 'administrator@example.com',
55
- * subject: 'Error occurred',
56
- * text: err.message
57
- * }, err => {
58
- * err ? reject(err) : resolve();
59
- * });
60
- * });
61
- * }
62
- *
63
- * @type {(err: any): void|Promise<void>}
64
- */
65
- error_handler?: (err: any) => void | Promise<void>;
66
- }