mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
chore: lib-server
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
import log4js from 'log4js';
|
||||
import path from 'path';
|
||||
const level = process.env.NODE_ENV === 'development' ? 'debug' : 'info';
|
||||
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('server');
|
||||
@@ -1,6 +1,6 @@
|
||||
const numbers = '0123456789';
|
||||
const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||
const specials = '~!@#$%^*()_+-=[]{}|;:,./<>?';
|
||||
const numbers = "0123456789";
|
||||
const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
const specials = "~!@#$%^*()_+-=[]{}|;:,./<>?";
|
||||
|
||||
/**
|
||||
* Generate random string
|
||||
@@ -11,24 +11,24 @@ function randomStr(length, options?) {
|
||||
length || (length = 8);
|
||||
options || (options = {});
|
||||
|
||||
let chars = '';
|
||||
let result = '';
|
||||
let chars = "";
|
||||
let result = "";
|
||||
|
||||
if (options === true) {
|
||||
chars = numbers + letters;
|
||||
} else if (typeof options === 'string') {
|
||||
} else if (typeof options === "string") {
|
||||
chars = options;
|
||||
} else {
|
||||
if (options.numbers !== false) {
|
||||
chars += typeof options.numbers === 'string' ? options.numbers : numbers;
|
||||
chars += typeof options.numbers === "string" ? options.numbers : numbers;
|
||||
}
|
||||
|
||||
if (options.letters !== false) {
|
||||
chars += typeof options.letters === 'string' ? options.letters : letters;
|
||||
chars += typeof options.letters === "string" ? options.letters : letters;
|
||||
}
|
||||
|
||||
if (options.specials) {
|
||||
chars += typeof options.specials === 'string' ? options.specials : specials;
|
||||
chars += typeof options.specials === "string" ? options.specials : specials;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user