build: trident-sync prepare

This commit is contained in:
xiaojunnuo
2023-01-29 13:44:19 +08:00
parent dcd1023a39
commit 07a45b4530
589 changed files with 36886 additions and 2 deletions
@@ -0,0 +1,12 @@
const log4js = require('log4js');
const level = process.env.NODE_ENV === 'development' ? 'debug' : 'info';
const path = require('path');
const filename = path.join('/logs/server.log');
log4js.configure({
appenders: {
std: { type: 'stdout', level: 'debug' },
file: { type: 'file', pattern: 'yyyy-MM-dd', daysToKeep: 3, filename },
},
categories: { default: { appenders: ['std'], level } },
});
export const logger = log4js.getLogger('fast');
@@ -0,0 +1,43 @@
const numbers = '0123456789';
const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
const specials = '~!@#$%^*()_+-=[]{}|;:,./<>?';
/**
* Generate random string
* @param {Number} length
* @param {Object} options
*/
function randomStr(length, options) {
length || (length = 8);
options || (options = {});
let chars = '';
let result = '';
if (options === true) {
chars = numbers + letters;
} else if (typeof options === 'string') {
chars = options;
} else {
if (options.numbers !== false) {
chars += typeof options.numbers === 'string' ? options.numbers : numbers;
}
if (options.letters !== false) {
chars += typeof options.letters === 'string' ? options.letters : letters;
}
if (options.specials) {
chars +=
typeof options.specials === 'string' ? options.specials : specials;
}
}
while (length > 0) {
length--;
result += chars[Math.floor(Math.random() * chars.length)];
}
return result;
}
export const RandomUtil = { randomStr };