diff --git a/node/README.md b/node/README.md index d81af7a..e7650f5 100644 --- a/node/README.md +++ b/node/README.md @@ -90,7 +90,7 @@ interface HitCounterConfig { ## Usage ```ts -import { HitCounter, ImageHitCounterRenderer } from "./hit-counter"; +import { HitCounter } from "./hit-counter"; // default config @@ -113,13 +113,14 @@ defaultHitCounterConfig = { secondaryTextColorRGB: { r: 0, g: 255, b: 0 }, numberColorRGB: { r: 255, g: 255, b: 255 }, frameColorRGB: { r: 255, g: 0, b: 0 }, - drawFrame: true, - renderer: ImageHitCounterRenderer + drawFrame: true }; // the default config will be used, but you can pass a custom config object as -// the second argument to the HitCounter constructor -const hitCounter = new HitCounter(ImageHitCounterRenderer); +// the first argument to the HitCounter constructor +// e.g. const hitCounter = new HitCounter(customConfig); +// the second argument is reserved for the renderer, but currently only the ImageHitCounterRenderer is implemented +const hitCounter = new HitCounter(); // increment the hit counter hitCounter.increment(); // async function diff --git a/node/src/hit-counter.ts b/node/src/hit-counter.ts index c6a5d5c..7ee0c7b 100644 --- a/node/src/hit-counter.ts +++ b/node/src/hit-counter.ts @@ -346,12 +346,12 @@ class HitCounter { /** * Creates an instance of HitCounter. * - * @param {Type} renderer - * The hit counter renderer. * @param {HitCounterConfig} [config=defaultHitCounterConfig] - * The hit counter configuration. + * The hit counter configuration. Defaults to defaultHitCounterConfig. + * @param {Type} renderer + * The hit counter renderer. Defaults to ImageHitCounterRenderer. */ - constructor(renderer: Type, config: HitCounterConfig = defaultHitCounterConfig) { + constructor(config: HitCounterConfig = defaultHitCounterConfig, renderer: Type = ImageHitCounterRenderer) { config = { ...defaultHitCounterConfig, ...config }; this.config = config; this.renderer = new renderer(this, config); diff --git a/node/src/index.ts b/node/src/index.ts index c3647a6..0f5eeee 100644 --- a/node/src/index.ts +++ b/node/src/index.ts @@ -1,9 +1,9 @@ import express, { Express, Request, Response } from "express"; -import { HitCounter, ImageHitCounterRenderer } from "./hit-counter"; +import { HitCounter } from "./hit-counter"; const app: Express = express(); const PORT: number = 8000; -const hitCounter = new HitCounter(ImageHitCounterRenderer); +const hitCounter = new HitCounter(); const imageMimeType = hitCounter.getMimeType(); app.get("/", (req: Request, res: Response) => {