diff --git a/src/types/schema.ts b/src/types.ts similarity index 100% rename from src/types/schema.ts rename to src/types.ts diff --git a/src/types/index.ts b/src/types/index.ts deleted file mode 100644 index 686fbd9..0000000 --- a/src/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./schema"; diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 0000000..e3f1461 --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,2 @@ +export * from "./logger"; +export * from "./utils"; diff --git a/src/utils/logger.ts b/src/utils/logger.ts new file mode 100644 index 0000000..3189494 --- /dev/null +++ b/src/utils/logger.ts @@ -0,0 +1,30 @@ +import chalk from "chalk"; + +export class Logger { + private _wrn: string; + private _err: string; + private _main: string; + + constructor() { + this._wrn = chalk.yellow("[WARN] "); + this._err = chalk.red("[ERROR] "); + + this._main = chalk.bold.gray("[Simple Review Server] "); + } + + log(text: any, args?: any): void { + args ? console.log(this._main + text, args) : console.log(this._main + text); + } + + warn(text: any, args?: any): void { + args ? console.warn(this._wrn + this._main + text, args) : console.warn(this._wrn + this._main + text); + } + + error(text: any, args?: any): void { + args ? console.error(this._err + this._main + text, args) : console.error(this._err + this._main + text); + } +} + +export const emp = chalk.green; +export const wrn = chalk.yellow; +export const err = chalk.red; diff --git a/src/utils.ts b/src/utils/utils.ts similarity index 92% rename from src/utils.ts rename to src/utils/utils.ts index 765e33a..6ccacc7 100644 --- a/src/utils.ts +++ b/src/utils/utils.ts @@ -1,5 +1,5 @@ import fs from "fs"; -import { Review } from "./types"; +import { Review } from "../types"; export const dir = "./persist/";