UNPKG

3.1 kBJavaScriptView Raw
1// © Copyright Mocoolka Corporation 2015,2017.
2// Node module: mocoolka-tools
3// LICENSE: MIT
4
5/** @module mocoolka-tools */
6const fileTools = require('./lib/file-tools.js');
7const arrayTools = require('./lib/array-tools.js');
8const formatTools = require('./lib/format-tools.js');
9const osTools = require('./lib/os-tools.js');
10const envTools = require('./lib/env-tools.js');
11const moduleTools = require('./lib/module-tools.js');
12const globalTools = require('./lib/global-tools.js');
13const objectTools = require('./lib/object-tools.js');
14const stringTools = require('./lib/string-tools.js');
15const errorTools = require('./lib/error-tools.js');
16const validTools = require('./lib/validation-tools.js');
17const typeTools = require('./lib/type-tools.js');
18const jsTools = require('./lib/file/js-tools.js');
19const jsonTools = require('./lib/file/json-tools.js');
20const ymlTools = require('./lib/file/yml-tools.js');
21const transformTools = require('./lib/transform-tools.js');
22const unitConvertTools = require('./lib/unit-convert.js');
23const watchFileTools = require('./lib/watch-file.js');
24const timerTools = require('./lib/timer-tools.js');
25const validationTools = require('./lib/validation-tools.js');
26const iteratorTools = require('./lib/iterator-tools');
27const 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}*/
62const 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
87module.exports = index;