diff --git a/README.md b/README.md index 5052c865fd75fd4d3592a133e24b784eae9aa1d9..4a1610285cc2e134f71e1cb57b0861c9a4cfcb68 100755 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Add default metaroutes to express app ## Usage -`const metaRoutes = require('@libs/metaroutes');` +`const metaRoutes = require('@libs/metaroutes');` or `import metaRoutes from './metaRoutes';` `metaRoutes(app, { version, config, isServiceReady, metricsEndpoint }, routeOptions);` Where: diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8773a0502730b9ec94b5ec9210254869f8a5ffbe --- /dev/null +++ b/index.d.ts @@ -0,0 +1,27 @@ +// Import express types for app and RequestHandler +import { Express, RequestHandler } from 'express'; + +interface MetaRoutesOptions { + enableVersion?: boolean; + enableConfig?: boolean; + enableHealth?: boolean; + enableReady?: boolean; + enableMetrics?: boolean; +} + +interface Config { + _show: () => object; // Adjust according to the actual method signature +} + +interface MetaRouteDependencies { + version: string; + config: Config; + isServiceReady: () => boolean; + metricsEndpoint: RequestHandler; +} + +// Declaration of the metaRoutes function +declare function metaRoutes(app: Express, dependencies: MetaRouteDependencies, routeOptions?: MetaRoutesOptions): void; + +// Export the metaRoutes function to match your JS export +export = metaRoutes; \ No newline at end of file diff --git a/package.json b/package.json index 372aebd4426b9e5f35338fcfd3cac034fab02a84..3b443f34756d53fa74964f2197372285083de586 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@libs/metaroutes", - "version": "1.1.0", + "version": "1.2.0", "description": "Add default metaroutes to express app", "main": "index.js", "scripts": {