first commit
This commit is contained in:
19
source/config/config.ts
Normal file
19
source/config/config.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
interface IConfig {
|
||||
base_url: string;
|
||||
schedule: string[];
|
||||
delay: number;
|
||||
row_per_batch: number;
|
||||
}
|
||||
const j_config = JSON.parse(
|
||||
readFileSync("./config-accounting.json").toString()
|
||||
);
|
||||
|
||||
const config: IConfig = {
|
||||
base_url: j_config["base_url"],
|
||||
schedule: j_config["schedule"],
|
||||
delay: j_config["delay"],
|
||||
row_per_batch: j_config["row_per_batch"],
|
||||
};
|
||||
export default config;
|
||||
48
source/config/logging.ts
Normal file
48
source/config/logging.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import moment from "moment";
|
||||
|
||||
const getTimeStamp = (): string => {
|
||||
const dt = moment().format("yyyy-MM-DD HH:mm:ss");
|
||||
return dt;
|
||||
};
|
||||
|
||||
const info = (namespace: string, message: string, object?: any) => {
|
||||
if (object) {
|
||||
console.log(
|
||||
`[${getTimeStamp()}] [INFO] [${namespace}] [${message}]`,
|
||||
object
|
||||
);
|
||||
} else {
|
||||
console.log(`[${getTimeStamp()}] [INFO] [${namespace}] [${message}]`);
|
||||
}
|
||||
};
|
||||
|
||||
const warning = (namespace: string, message: string, object?: any) => {
|
||||
if (object) {
|
||||
console.log(
|
||||
`[${getTimeStamp()}] [WARNING] [${namespace}] [${message}]`,
|
||||
object
|
||||
);
|
||||
} else {
|
||||
console.log(`[${getTimeStamp()}] [WARNING] [${namespace}] [${message}]`);
|
||||
}
|
||||
};
|
||||
|
||||
const error = (namespace: string, message: string, object?: any) => {
|
||||
if (object) {
|
||||
console.log(
|
||||
`[${getTimeStamp()}] [ERROR] [${namespace}] [${message}]`,
|
||||
object
|
||||
);
|
||||
} else {
|
||||
console.log(`[${getTimeStamp()}] [ERROR] [${namespace}] [${message}]`);
|
||||
}
|
||||
};
|
||||
|
||||
const delay = (time: number) => new Promise((res) => setTimeout(res, time));
|
||||
|
||||
export default {
|
||||
info,
|
||||
warning,
|
||||
error,
|
||||
delay,
|
||||
};
|
||||
Reference in New Issue
Block a user