express-sweet 1.0.35 → 1.0.37

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 (33) hide show
  1. package/CHANGELOG.md +66 -1
  2. package/dist/build.common.js +11 -11
  3. package/dist/build.esm.js +12 -12
  4. package/docs/index.html +321 -38
  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 +8 -7
  9. package/types/handlebars_helpers/math.d.ts +81 -0
  10. package/types/index.d.ts +7 -7
  11. package/types/interfaces/{AuthenticationOptions.d.ts → AuthenticationConfig.d.ts} +0 -14
  12. package/types/interfaces/BasicConfig.d.ts +74 -0
  13. package/types/interfaces/FaceMatch.d.ts +1 -1
  14. package/types/interfaces/{ViewOptions.d.ts → ViewConfig.d.ts} +2 -2
  15. package/types/interfaces/index.d.ts +9 -9
  16. package/types/middlewares/CORS.d.ts +0 -1
  17. package/types/middlewares/Environment.d.ts +0 -1
  18. package/types/middlewares/{ErrorHandling.d.ts → ErrorHandler.d.ts} +0 -1
  19. package/types/middlewares/Http.d.ts +0 -1
  20. package/types/middlewares/Local.d.ts +0 -1
  21. package/types/middlewares/View.d.ts +0 -1
  22. package/types/middlewares/index.d.ts +8 -8
  23. package/types/routing/Router.d.ts +0 -1
  24. package/types/routing/index.d.ts +1 -1
  25. package/types/services/Authentication.d.ts +0 -1
  26. package/types/services/index.d.ts +3 -3
  27. package/types/utils/index.d.ts +4 -0
  28. package/types/utils/loadAuthenticationConfig.d.ts +8 -0
  29. package/types/utils/loadBasicConfig.d.ts +8 -0
  30. package/types/utils/loadDatabaseConfig.d.ts +8 -0
  31. package/types/utils/loadViewConfig.d.ts +8 -0
  32. package/types/interfaces/Config.d.ts +0 -66
  33. /package/types/interfaces/{DatabaseOptions.d.ts → DatabaseConfig.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>
@@ -481,6 +481,18 @@
481
481
  <!--end:Menu link-->
482
482
  </div>
483
483
  <!--end:Menu item-->
484
+ <!--begin:Menu item-->
485
+ <div class="menu-item">
486
+ <!--begin:Menu link-->
487
+ <a class="menu-link" href="#view-math-helper">
488
+ <span class="menu-bullet">
489
+ <span class="bullet bullet-dot"></span>
490
+ </span>
491
+ <span class="menu-title">Math Helper</span>
492
+ </a>
493
+ <!--end:Menu link-->
494
+ </div>
495
+ <!--end:Menu item-->
484
496
  </div>
485
497
  <!--end:Menu sub-->
486
498
  </div>
@@ -1290,7 +1302,7 @@ npm start</code></pre>
1290
1302
  <!--begin::Body-->
1291
1303
  <tbody>
1292
1304
  <tr>
1293
- <td class="w-250px"><code>env_path</code></td>
1305
+ <td class="w-250px"><code>env_path: string</code></td>
1294
1306
  <td>
1295
1307
  The path to the environment configuration file (<code>.env</code>).<br>
1296
1308
  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 +1310,11 @@ npm start</code></pre>
1298
1310
  </td>
1299
1311
  </tr>
1300
1312
  <tr>
1301
- <td class="w-250px"><code>cors_enabled</code></td>
1313
+ <td class="w-250px"><code>cors_enabled: boolean</code></td>
1302
1314
  <td>Set to true to allow requests from another domain to the application.<br>The default is <code>false</code>.</td>
1303
1315
  </tr>
1304
1316
  <tr>
1305
- <td class="w-250px"><code>max_body_size</code></td>
1317
+ <td class="w-250px"><code>max_body_size: string|number</code></td>
1306
1318
  <td>
1307
1319
  Controls the maximum request body size.<br>
1308
1320
  If this is a number, then the value specifies the number of bytes.<br>
@@ -1311,11 +1323,11 @@ npm start</code></pre>
1311
1323
  </td>
1312
1324
  </tr>
1313
1325
  <tr>
1314
- <td class="w-250px"><code>router_dir</code></td>
1326
+ <td class="w-250px"><code>router_dir: string</code></td>
1315
1327
  <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
1328
  </tr>
1317
1329
  <tr>
1318
- <td class="w-250px"><code>default_router</code></td>
1330
+ <td class="w-250px"><code>default_router: string</code></td>
1319
1331
  <td>
1320
1332
  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
1333
  For example, to specify a default route, set <code>default_router</code> as follows.<br>
@@ -1366,7 +1378,7 @@ module.exports = router;</code></pre>
1366
1378
  </td>
1367
1379
  </tr>
1368
1380
  <tr>
1369
- <td class="w-250px"><code>rewrite_base_url</code></td>
1381
+ <td class="w-250px"><code>rewrite_base_url: (baseUrl: string) =&gt; string</code></td>
1370
1382
  <td>
1371
1383
  This is a hook that rewrites the base URL.<br>
1372
1384
  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 +1401,21 @@ module.exports = router;</code></pre>
1389
1401
  </td>
1390
1402
  </tr>
1391
1403
  <tr>
1392
- <td class="w-250px"><code>error_handler</code></td>
1404
+ <td class="w-250px"><code>is_ajax: (req: express.Request) =&gt; boolean</code></td>
1393
1405
  <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.
1406
+ How to determine if it is an ajax request.<br>
1407
+ The default is that if there is an XMLHttpRequest in the request header (<code>req.xhr</code>) returns <code>true</code>.<br><br>
1408
+ 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
1409
  <!--begin::Code-->
1397
1410
  <div class="py-5">
1398
1411
  <!--begin::Highlight-->
1399
1412
  <div class="highlight">
1400
1413
  <button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
1401
1414
  <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;);
1415
+ <pre class="language-javascript"><code class="language-javascript">is_ajax: req =&gt; {
1416
+ // If the request URL begins with /api, it is assumed to be Ajax.
1417
+ return /^\/api/.test(req.path);
1418
+ // return !!req.xhr;
1404
1419
  }</code></pre>
1405
1420
  </div>
1406
1421
  </div>
@@ -1409,6 +1424,32 @@ module.exports = router;</code></pre>
1409
1424
  <!--end::Code-->
1410
1425
  </td>
1411
1426
  </tr>
1427
+ <tr>
1428
+ <td class="w-250px"><code>hook_handle_error: (err: any, req: express.Request, res: express.Response, next: express.NextFunction) =&gt; void</code></td>
1429
+ <td>
1430
+ Hooks the default behavior on request errors.<br>
1431
+ If unset, simply returns an error HTTP status. (<code>res.status(err.status||500).end();</code>)
1432
+ <!--begin::Code-->
1433
+ <div class="py-5">
1434
+ <!--begin::Highlight-->
1435
+ <div class="highlight">
1436
+ <button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
1437
+ <div class="highlight-code">
1438
+ <pre class="language-javascript"><code class="language-javascript">hook_handle_error: (err, req, res, next) =&gt; {
1439
+ if (err.status === 404)
1440
+ // If the URL cannot be found, a 404 error screen (views/error-404.hbs) is displayed.
1441
+ res.render(&#039;error-404&#039;);
1442
+ else
1443
+ // For other errors, unknown error screen (views/error-unknown.hbs) is displayed.
1444
+ res.render(&#039;error-unknown&#039;);
1445
+ },</code></pre>
1446
+ </div>
1447
+ </div>
1448
+ <!--end::Highlight-->
1449
+ </div>
1450
+ <!--end::Code-->
1451
+ </td>
1452
+ </tr>
1412
1453
  </tbody>
1413
1454
  <!--end::Body-->
1414
1455
  </table>
@@ -1826,7 +1867,7 @@ module.exports = router;</code></pre>
1826
1867
  <td>Extension for templates and partials files.<br>The default is <code>.hbs</code>.</td>
1827
1868
  </tr>
1828
1869
  <tr>
1829
- <td class="w-250px"><code>beforeRender: (req: express.Request, res: express.Response) =&gt; void</code></td>
1870
+ <td class="w-250px"><code>beforeRender: (req: express.Request, res: express.Response) =&gt; Promise&lt;void&gt;|void</code></td>
1830
1871
  <td>
1831
1872
  Hook function just before the view is rendered.<br>
1832
1873
  For example, you can set your own local variables that can be used within the view.<br>
@@ -1846,7 +1887,7 @@ module.exports = router;</code></pre>
1846
1887
  * res.locals.message = &#039;Hello World&#039;;
1847
1888
  * }
1848
1889
  *
1849
- * @type {(res: express.Response) =&gt; void}
1890
+ * @type {(res: express.Response) =&gt; Promise&lt;void&gt;|void}
1850
1891
  */
1851
1892
  beforeRender: (req, res) =&gt; {
1852
1893
  res.locals.message = &#039;Hello World&#039;;
@@ -3264,6 +3305,272 @@ Else
3264
3305
  <!--end::Table wrapper-->
3265
3306
  </div>
3266
3307
  <!--end::Table-->
3308
+
3309
+
3310
+
3311
+
3312
+ <!--begin::Block-->
3313
+ <h2 id="view-math-helper" class="text-gray-700 py-5 fw-normal">Math Helper</h2>
3314
+ <!--end::Block-->
3315
+ <!--begin::Table-->
3316
+ <div class="py-2">
3317
+ <!--begin::Table wrapper-->
3318
+ <div class="table-responsive border rounded">
3319
+ <!--begin::Table-->
3320
+ <table class="table table-striped mb-0 g-6">
3321
+ <!--begin::Head-->
3322
+ <thead>
3323
+ <tr class="fs-4 fw-bold p-6">
3324
+ <th class="min-w-200px">Function</th>
3325
+ <th>Description</th>
3326
+ </tr>
3327
+ </thead>
3328
+ <!--end::Head-->
3329
+ <!--begin::Body-->
3330
+ <tbody>
3331
+ <tr>
3332
+ <td class="w-250px"><code>add()</code></td>
3333
+ <td>
3334
+ Calculates the sum of two numbers.
3335
+ <!--begin::Parameters-->
3336
+ <div class="py-5">
3337
+ <p>Parameters:</p>
3338
+ <ul>
3339
+ <li><code>val1: number|string</code> The first number.</li>
3340
+ <li><code>val2: number|string</code> The second number.</li>
3341
+ </ul>
3342
+ </div>
3343
+ <!--end::Parameters-->
3344
+ <!--begin::Return value-->
3345
+ <div class="py-5">
3346
+ <p>Return value:</p>
3347
+ <code>number</code>
3348
+ </div>
3349
+ <!--end::Return value-->
3350
+ <!--begin::Code-->
3351
+ <div class="py-5">
3352
+ <!--begin::Highlight-->
3353
+ <div class="highlight">
3354
+ <button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
3355
+ <div class="highlight-code">
3356
+ <pre class="language-javascript"><code class="language-javascript">{{!-- results in: 3 --}}
3357
+ {{add 1 2}}</code></pre>
3358
+ </div>
3359
+ </div>
3360
+ <!--end::Highlight-->
3361
+ </div>
3362
+ <!--end::Code-->
3363
+ </td>
3364
+ </tr>
3365
+ <tr>
3366
+ <td class="w-250px"><code>sub()</code></td>
3367
+ <td>
3368
+ Calculates the difference of the given values.
3369
+ <!--begin::Parameters-->
3370
+ <div class="py-5">
3371
+ <p>Parameters:</p>
3372
+ <ul>
3373
+ <li><code>val1: number|string</code> The first number.</li>
3374
+ <li><code>val2: number|string</code> The second number.</li>
3375
+ </ul>
3376
+ </div>
3377
+ <!--end::Parameters-->
3378
+ <!--begin::Return value-->
3379
+ <div class="py-5">
3380
+ <p>Return value:</p>
3381
+ <code>number</code>
3382
+ </div>
3383
+ <!--end::Return value-->
3384
+ <!--begin::Code-->
3385
+ <div class="py-5">
3386
+ <!--begin::Highlight-->
3387
+ <div class="highlight">
3388
+ <button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
3389
+ <div class="highlight-code">
3390
+ <pre class="language-javascript"><code class="language-javascript">{{!-- results in: 3 --}}
3391
+ {{sub 5 2}}</code></pre>
3392
+ </div>
3393
+ </div>
3394
+ <!--end::Highlight-->
3395
+ </div>
3396
+ <!--end::Code-->
3397
+ </td>
3398
+ </tr>
3399
+ <tr>
3400
+ <td class="w-250px"><code>multiply()</code></td>
3401
+ <td>
3402
+ Calculate the multiplication of the given values.
3403
+ <!--begin::Parameters-->
3404
+ <div class="py-5">
3405
+ <p>Parameters:</p>
3406
+ <ul>
3407
+ <li><code>val1: number|string</code> The first number.</li>
3408
+ <li><code>val2: number|string</code> The second number.</li>
3409
+ </ul>
3410
+ </div>
3411
+ <!--end::Parameters-->
3412
+ <!--begin::Return value-->
3413
+ <div class="py-5">
3414
+ <p>Return value:</p>
3415
+ <code>number</code>
3416
+ </div>
3417
+ <!--end::Return value-->
3418
+ <!--begin::Code-->
3419
+ <div class="py-5">
3420
+ <!--begin::Highlight-->
3421
+ <div class="highlight">
3422
+ <button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
3423
+ <div class="highlight-code">
3424
+ <pre class="language-javascript"><code class="language-javascript">{{!-- results in: 10 --}}
3425
+ {{multiply 5 2}}</code></pre>
3426
+ </div>
3427
+ </div>
3428
+ <!--end::Highlight-->
3429
+ </div>
3430
+ <!--end::Code-->
3431
+ </td>
3432
+ </tr>
3433
+ <tr>
3434
+ <td class="w-250px"><code>divide()</code></td>
3435
+ <td>
3436
+ Compute the division of the given values.
3437
+ <!--begin::Parameters-->
3438
+ <div class="py-5">
3439
+ <p>Parameters:</p>
3440
+ <ul>
3441
+ <li><code>val1: number|string</code> The first number.</li>
3442
+ <li><code>val2: number|string</code> The second number.</li>
3443
+ </ul>
3444
+ </div>
3445
+ <!--end::Parameters-->
3446
+ <!--begin::Return value-->
3447
+ <div class="py-5">
3448
+ <p>Return value:</p>
3449
+ <code>number</code>
3450
+ </div>
3451
+ <!--end::Return value-->
3452
+ <!--begin::Code-->
3453
+ <div class="py-5">
3454
+ <!--begin::Highlight-->
3455
+ <div class="highlight">
3456
+ <button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
3457
+ <div class="highlight-code">
3458
+ <pre class="language-javascript"><code class="language-javascript">{{!-- results in: 5 --}}
3459
+ {{divide 10 2}}</code></pre>
3460
+ </div>
3461
+ </div>
3462
+ <!--end::Highlight-->
3463
+ </div>
3464
+ <!--end::Code-->
3465
+ </td>
3466
+ </tr>
3467
+ <tr>
3468
+ <td class="w-250px"><code>ceil()</code></td>
3469
+ <td>
3470
+ Round up the value.
3471
+ <!--begin::Parameters-->
3472
+ <div class="py-5">
3473
+ <p>Parameters:</p>
3474
+ <ul>
3475
+ <li><code>val: number|string</code> Number to be rounded to nearest greater integer.</li>
3476
+ </ul>
3477
+ </div>
3478
+ <!--end::Parameters-->
3479
+ <!--begin::Return value-->
3480
+ <div class="py-5">
3481
+ <p>Return value:</p>
3482
+ <code>number</code>
3483
+ </div>
3484
+ <!--end::Return value-->
3485
+ <!--begin::Code-->
3486
+ <div class="py-5">
3487
+ <!--begin::Highlight-->
3488
+ <div class="highlight">
3489
+ <button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
3490
+ <div class="highlight-code">
3491
+ <pre class="language-javascript"><code class="language-javascript">{{!-- results in: 6 --}}
3492
+ {{ceil 5.6}}</code></pre>
3493
+ </div>
3494
+ </div>
3495
+ <!--end::Highlight-->
3496
+ </div>
3497
+ <!--end::Code-->
3498
+ </td>
3499
+ </tr>
3500
+ <tr>
3501
+ <td class="w-250px"><code>floor()</code></td>
3502
+ <td>
3503
+ Rounds down a number.
3504
+ <!--begin::Parameters-->
3505
+ <div class="py-5">
3506
+ <p>Parameters:</p>
3507
+ <ul>
3508
+ <li><code>val: number|string</code> Number to be rounded to nearest lower integer.</li>
3509
+ </ul>
3510
+ </div>
3511
+ <!--end::Parameters-->
3512
+ <!--begin::Return value-->
3513
+ <div class="py-5">
3514
+ <p>Return value:</p>
3515
+ <code>number</code>
3516
+ </div>
3517
+ <!--end::Return value-->
3518
+ <!--begin::Code-->
3519
+ <div class="py-5">
3520
+ <!--begin::Highlight-->
3521
+ <div class="highlight">
3522
+ <button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
3523
+ <div class="highlight-code">
3524
+ <pre class="language-javascript"><code class="language-javascript">{{!-- results in: 5 --}}
3525
+ {{floor 5.6}}</code></pre>
3526
+ </div>
3527
+ </div>
3528
+ <!--end::Highlight-->
3529
+ </div>
3530
+ <!--end::Code-->
3531
+ </td>
3532
+ </tr>
3533
+ <tr>
3534
+ <td class="w-250px"><code>abs()</code></td>
3535
+ <td>
3536
+ Returns an absolute value.
3537
+ <!--begin::Parameters-->
3538
+ <div class="py-5">
3539
+ <p>Parameters:</p>
3540
+ <ul>
3541
+ <li><code>val: number|string</code> Number to perform absolute value operation on.</li>
3542
+ </ul>
3543
+ </div>
3544
+ <!--end::Parameters-->
3545
+ <!--begin::Return value-->
3546
+ <div class="py-5">
3547
+ <p>Return value:</p>
3548
+ <code>number</code>
3549
+ </div>
3550
+ <!--end::Return value-->
3551
+ <!--begin::Code-->
3552
+ <div class="py-5">
3553
+ <!--begin::Highlight-->
3554
+ <div class="highlight">
3555
+ <button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
3556
+ <div class="highlight-code">
3557
+ <pre class="language-javascript"><code class="language-javascript">{{!-- results in: 5.6 --}}
3558
+ {{abs -5.6}}</code></pre>
3559
+ </div>
3560
+ </div>
3561
+ <!--end::Highlight-->
3562
+ </div>
3563
+ <!--end::Code-->
3564
+ </td>
3565
+ </tr>
3566
+ </tbody>
3567
+ <!--end::Body-->
3568
+ </table>
3569
+ <!--end::Table-->
3570
+ </div>
3571
+ <!--end::Table wrapper-->
3572
+ </div>
3573
+ <!--end::Table-->
3267
3574
  </div>
3268
3575
  <!--end::Section-->
3269
3576
  </div>
@@ -5900,30 +6207,6 @@ failure_redirect: (req, res) =&gt; {
5900
6207
  The default is 24 hours (<code>86400000</code> milliseconds).
5901
6208
  </td>
5902
6209
  </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
6210
  </tbody>
5928
6211
  <!--end::Body-->
5929
6212
  </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.37",
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,8 @@
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';
7
- export { html, object, string, comparison, date, 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
+ import * as math from '~/handlebars_helpers/math';
8
+ export { html, object, string, comparison, date, number, math, };
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Calculates the sum of two numbers.
3
+ *
4
+ * @example
5
+ * {{!-- results in: 3 --}}
6
+ * {{add 1 2}}
7
+ *
8
+ * @param {number|string} val1 The first number.
9
+ * @param {number|string} val2 The second number.
10
+ * @returns {number}
11
+ */
12
+ export declare function add(val1: number | string, val2: number | string): number;
13
+ /**
14
+ * Calculates the difference of the given values.
15
+ *
16
+ * @example
17
+ * {{!-- results in: 3 --}}
18
+ * {{sub 5 2}}
19
+ *
20
+ * @param {number|string} val1 The first number.
21
+ * @param {number|string} val2 The second number.
22
+ * @returns {number}
23
+ */
24
+ export declare function sub(val1: number | string, val2: number | string): number;
25
+ /**
26
+ * Calculate the multiplication of the given values.
27
+ *
28
+ * @example
29
+ * {{!-- results in: 10 --}}
30
+ * {{multiply 5 2}}
31
+ *
32
+ * @param {number|string} val1 The first number.
33
+ * @param {number|string} val2 The second number.
34
+ * @returns {number}
35
+ */
36
+ export declare function multiply(val1: number | string, val2: number | string): number;
37
+ /**
38
+ * Compute the division of the given values.
39
+ *
40
+ * @example
41
+ * {{!-- results in: 5 --}}
42
+ * {{divide 10 2}}
43
+ *
44
+ * @param {number|string} val1 The first number.
45
+ * @param {number|string} val2 The second number.
46
+ * @returns {number}
47
+ */
48
+ export declare function divide(val1: number | string, val2: number | string): number;
49
+ /**
50
+ * Round up the value.
51
+ *
52
+ * @example
53
+ * {{!-- results in: 6 --}}
54
+ * {{ceil 5.6}}
55
+ *
56
+ * @param {number|string} val Number to be rounded to nearest greater integer.
57
+ * @returns {number}
58
+ */
59
+ export declare function ceil(val: number | string): number;
60
+ /**
61
+ * Rounds down a number.
62
+ *
63
+ * @example
64
+ * {{!-- results in: 5 --}}
65
+ * {{floor 5.6}}
66
+ *
67
+ * @param {number|string} val Number to be rounded to nearest lower integer.
68
+ * @returns {number}
69
+ */
70
+ export declare function floor(val: number | string): number;
71
+ /**
72
+ * Returns an absolute value.
73
+ *
74
+ * @example
75
+ * {{!-- results in: 5.6 --}}
76
+ * {{abs -5.6}}
77
+ *
78
+ * @param {number} val Number to perform absolute value operation on.
79
+ * @returns {number}
80
+ */
81
+ export declare function abs(val: number | string): 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
  }