1 | // © Copyright Mocoolka Corporation 2015,2017.
|
2 | // Node module: mocoolka-tools
|
3 | // LICENSE: MIT
|
4 |
|
5 | /** @module mocoolka-tools */
|
6 | const fileTools = require('./lib/file-tools.js');
|
7 | const arrayTools = require('./lib/array-tools.js');
|
8 | const formatTools = require('./lib/format-tools.js');
|
9 | const osTools = require('./lib/os-tools.js');
|
10 | const envTools = require('./lib/env-tools.js');
|
11 | const moduleTools = require('./lib/module-tools.js');
|
12 | const globalTools = require('./lib/global-tools.js');
|
13 | const objectTools = require('./lib/object-tools.js');
|
14 | const stringTools = require('./lib/string-tools.js');
|
15 | const errorTools = require('./lib/error-tools.js');
|
16 | const validTools = require('./lib/validation-tools.js');
|
17 | const typeTools = require('./lib/type-tools.js');
|
18 | const jsTools = require('./lib/file/js-tools.js');
|
19 | const jsonTools = require('./lib/file/json-tools.js');
|
20 | const ymlTools = require('./lib/file/yml-tools.js');
|
21 | const transformTools = require('./lib/transform-tools.js');
|
22 | const unitConvertTools = require('./lib/unit-convert.js');
|
23 | const watchFileTools = require('./lib/watch-file.js');
|
24 | const timerTools = require('./lib/timer-tools.js');
|
25 | const validationTools = require('./lib/validation-tools.js');
|
26 | const iteratorTools = require('./lib/iterator-tools');
|
27 | const serviceTools = require('./lib/service-tools');
|
28 |
|
29 | /**
|
30 | * init mocoolka-tools
|
31 | * @param {string} root - root path
|
32 | * @param {string} [lang] - Language ID.
|
33 | * It tries to use App language OS language, then falls back to 'en'
|
34 | */
|
35 | /*const init = (root, language)=> {
|
36 | fileTools.init(root);
|
37 | i18nTools.init(root, language);
|
38 |
|
39 | };*/
|
40 |
|
41 | /*const errorHandler = () =>{
|
42 | logger.logError(err).then(sendMailToAdminIfCritical).then(saveInOpsQueueIfCritical).then(determineIfOperationalError);
|
43 | //deciding whether to crash when an uncaught exception arrives
|
44 | //Assuming developers mark known operational errors with error.isOperational=true, read best practice #3
|
45 | process.on('uncaughtException', function(error) {
|
46 | errorManagement.handler.handleError(error);
|
47 | if(!errorManagement.handler.isTrustedError(error))
|
48 | process.exit(1)
|
49 | });
|
50 |
|
51 | process.on('unhandledRejection', function (reason, p) {
|
52 | //I just caught an unhandled promise rejection, since we already have fallback handler for unhandled errors (see below), let throw and let him handle that
|
53 | throw reason;
|
54 | });
|
55 | process.on('uncaughtException', function (error) {
|
56 | //I just received an error that was never handled, time to handle it and then decide whether a restart is needed
|
57 | errorManagement.handler.handleError(error);
|
58 | if (!errorManagement.handler.isTrustedError(error))
|
59 | process.exit(1);
|
60 | });
|
61 | }*/
|
62 | const index = {
|
63 | jsTools,
|
64 | jsonTools,
|
65 | ymlTools,
|
66 | fileTools,
|
67 | arrayTools,
|
68 | formatTools,
|
69 | osTools,
|
70 | envTools,
|
71 | moduleTools,
|
72 | globalTools,
|
73 | objectTools,
|
74 | stringTools,
|
75 | errorTools,
|
76 | validTools,
|
77 | typeTools,
|
78 | transformTools,
|
79 | unitConvertTools,
|
80 | watchFileTools,
|
81 | timerTools,
|
82 | validationTools,
|
83 | iteratorTools,
|
84 | serviceTools,
|
85 | };
|
86 |
|
87 | module.exports = index;
|