@abinashpatri/orchestrator 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Abinash Patri
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,301 @@
1
+ # @abinashpatri/orchestrator
2
+
3
+ Reusable TypeScript/JavaScript toolkit for service registration, service
4
+ discovery, and API gateway routing.
5
+
6
+ Works in both ESM and CommonJS projects with full TypeScript type support.
7
+
8
+ Core APIs (`createConsulClient`, `registerService`, `deregisterService`, `getServiceUrl`) are framework-agnostic.
9
+ Express gateway APIs are available from the subpath `@abinashpatri/orchestrator/express`.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @abinashpatri/orchestrator
15
+ ```
16
+
17
+ For Express gateway adapter, install peer dependencies in your microservice:
18
+
19
+ ```bash
20
+ npm install express http-proxy-middleware
21
+ ```
22
+
23
+ ## Prerequisites
24
+
25
+ - Consul agent is running and reachable
26
+ - your services expose a health endpoint (default: `/health`)
27
+ - Node.js 18+ recommended
28
+
29
+ ---
30
+
31
+ ## Step-by-step usage (modern way)
32
+
33
+ ## 1) Create a Consul client
34
+
35
+ ```ts
36
+ import { createConsulClient } from "@abinashpatri/orchestrator";
37
+
38
+ const consul = createConsulClient({
39
+ host: process.env.CONSUL_HOST ?? "127.0.0.1",
40
+ port: Number(process.env.CONSUL_PORT ?? 8500),
41
+ token: process.env.CONSUL_HTTP_TOKEN, // optional
42
+ secure: process.env.CONSUL_SECURE === "true", // optional
43
+ });
44
+ ```
45
+
46
+ ## 2) Register your service
47
+
48
+ ```ts
49
+ import { registerService } from "@abinashpatri/orchestrator";
50
+
51
+ const serviceId = await registerService(consul, {
52
+ serviceName: "user-service",
53
+ serviceId: `user-service-${process.pid}`, // optional (auto-generated if not provided)
54
+ address: "127.0.0.1",
55
+ port: 3001,
56
+ tags: ["v1", "public"], // optional
57
+ healthPath: "/health", // optional, default: /health
58
+ healthInterval: "10s", // optional, default: 10s
59
+ healthTimeout: "5s", // optional, default: 5s
60
+ deregisterCriticalServiceAfter: "30s", // optional, default: 30s
61
+ });
62
+ ```
63
+
64
+ ## 3) Discover another service URL
65
+
66
+ ```ts
67
+ import { getServiceUrl } from "@abinashpatri/orchestrator";
68
+
69
+ const paymentServiceUrl = await getServiceUrl(consul, "payment-service");
70
+ // Example output: http://127.0.0.1:4002
71
+ ```
72
+
73
+ By default, discovery returns a random healthy instance (simple load balancing).
74
+
75
+ ## 4) Build an API gateway app
76
+
77
+ ```ts
78
+ import { createGatewayApp } from "@abinashpatri/orchestrator/express";
79
+
80
+ const app = createGatewayApp(consul, {
81
+ healthPath: "/health",
82
+ routes: [
83
+ { serviceName: "user-service", routePrefix: "/api/users" },
84
+ { serviceName: "payment-service", routePrefix: "/api/payments" },
85
+ { serviceName: "notification-service" }, // defaults to /api/notification-service
86
+ ],
87
+ });
88
+
89
+ const server = app.listen(4000, () => {
90
+ console.log("Gateway running on :4000");
91
+ });
92
+ ```
93
+
94
+ ## 5) Graceful shutdown (important for production)
95
+
96
+ ```ts
97
+ import { deregisterService } from "@abinashpatri/orchestrator";
98
+
99
+ function shutdown(signal: string) {
100
+ return async () => {
101
+ console.log(`Received ${signal}, shutting down...`);
102
+
103
+ server.close(async () => {
104
+ try {
105
+ await deregisterService(consul, serviceId);
106
+ } finally {
107
+ process.exit(0);
108
+ }
109
+ });
110
+ };
111
+ }
112
+
113
+ process.on("SIGINT", shutdown("SIGINT"));
114
+ process.on("SIGTERM", shutdown("SIGTERM"));
115
+ ```
116
+
117
+ ---
118
+
119
+ ## Full TypeScript example
120
+
121
+ ```ts
122
+ import {
123
+ createConsulClient,
124
+ registerService,
125
+ deregisterService,
126
+ getServiceUrl,
127
+ } from "@abinashpatri/orchestrator";
128
+ import { createGatewayApp } from "@abinashpatri/orchestrator/express";
129
+
130
+ const consul = createConsulClient({
131
+ host: process.env.CONSUL_HOST ?? "127.0.0.1",
132
+ port: Number(process.env.CONSUL_PORT ?? 8500),
133
+ token: process.env.CONSUL_HTTP_TOKEN,
134
+ });
135
+
136
+ const serviceId = await registerService(consul, {
137
+ serviceName: "api-gateway-service",
138
+ address: "127.0.0.1",
139
+ port: 4000,
140
+ healthPath: "/health",
141
+ });
142
+
143
+ const app = createGatewayApp(consul, {
144
+ routes: [
145
+ { serviceName: "user-service", routePrefix: "/api/users" },
146
+ { serviceName: "notification-service", routePrefix: "/api/notifications" },
147
+ ],
148
+ });
149
+
150
+ app.get("/where-is-user-service", async (_req, res) => {
151
+ try {
152
+ const url = await getServiceUrl(consul, "user-service");
153
+ res.json({ service: "user-service", url });
154
+ } catch (error) {
155
+ const message = error instanceof Error ? error.message : "Unknown error";
156
+ res.status(503).json({ error: message });
157
+ }
158
+ });
159
+
160
+ const server = app.listen(4000, () => {
161
+ console.log("API gateway listening on port 4000");
162
+ });
163
+
164
+ async function cleanup() {
165
+ await deregisterService(consul, serviceId);
166
+ }
167
+
168
+ process.on("SIGINT", async () => {
169
+ server.close(async () => {
170
+ await cleanup();
171
+ process.exit(0);
172
+ });
173
+ });
174
+
175
+ process.on("SIGTERM", async () => {
176
+ server.close(async () => {
177
+ await cleanup();
178
+ process.exit(0);
179
+ });
180
+ });
181
+ ```
182
+
183
+ ---
184
+
185
+ ## JavaScript (CommonJS) usage
186
+
187
+ ```js
188
+ const {
189
+ createConsulClient,
190
+ registerService,
191
+ getServiceUrl,
192
+ deregisterService,
193
+ } = require("@abinashpatri/orchestrator");
194
+ const { createGatewayApp } = require("@abinashpatri/orchestrator/express");
195
+
196
+ async function main() {
197
+ const consul = createConsulClient({
198
+ host: "127.0.0.1",
199
+ port: 8500,
200
+ token: process.env.CONSUL_HTTP_TOKEN,
201
+ });
202
+
203
+ const serviceId = await registerService(consul, {
204
+ serviceName: "api-gateway-service",
205
+ address: "127.0.0.1",
206
+ port: 4000,
207
+ });
208
+
209
+ const app = createGatewayApp(consul, {
210
+ routes: [{ serviceName: "user-service", routePrefix: "/api/users" }],
211
+ });
212
+
213
+ app.get("/discover-user-service", async (_req, res) => {
214
+ const url = await getServiceUrl(consul, "user-service");
215
+ res.json({ url });
216
+ });
217
+
218
+ const server = app.listen(4000);
219
+
220
+ process.on("SIGINT", async () => {
221
+ server.close(async () => {
222
+ await deregisterService(consul, serviceId);
223
+ process.exit(0);
224
+ });
225
+ });
226
+ }
227
+
228
+ main().catch((err) => {
229
+ console.error(err);
230
+ process.exit(1);
231
+ });
232
+ ```
233
+
234
+ ---
235
+
236
+ ## API reference
237
+
238
+ ### `createConsulClient(options?)`
239
+
240
+ Creates and returns a Consul client.
241
+
242
+ `options`:
243
+
244
+ - `host?: string` (default: `127.0.0.1`)
245
+ - `port?: number` (default: `8500`)
246
+ - `token?: string`
247
+ - `secure?: boolean` (default: `false`)
248
+
249
+ ### `registerService(consulClient, options)`
250
+
251
+ Registers a service and returns the final `serviceId`.
252
+
253
+ `options`:
254
+
255
+ - `serviceName: string` (required)
256
+ - `serviceId?: string`
257
+ - `address: string` (required)
258
+ - `port: number` (required)
259
+ - `tags?: string[]`
260
+ - `healthPath?: string` (default: `/health`)
261
+ - `healthInterval?: string` (default: `10s`)
262
+ - `healthTimeout?: string` (default: `5s`)
263
+ - `deregisterCriticalServiceAfter?: string` (default: `30s`)
264
+
265
+ ### `deregisterService(consulClient, serviceId)`
266
+
267
+ Removes a registered service from Consul.
268
+
269
+ ### `getServiceUrl(consulClient, serviceName, options?)`
270
+
271
+ Returns one discovered service URL, such as `http://127.0.0.1:3001`.
272
+
273
+ `options`:
274
+
275
+ - `passing?: boolean` (default: `true`)
276
+
277
+ ### `createServiceProxy(consulClient, options)` (from `@abinashpatri/orchestrator/express`)
278
+
279
+ Creates an Express middleware that resolves service target dynamically via Consul.
280
+
281
+ `options`:
282
+
283
+ - `serviceName: string` (required)
284
+ - `routePrefix?: string` (default: `/api/${serviceName}`)
285
+
286
+ ### `createGatewayApp(consulClient, options)` (from `@abinashpatri/orchestrator/express`)
287
+
288
+ Creates an Express app and mounts service proxies for all routes.
289
+
290
+ `options`:
291
+
292
+ - `routes: Array<{ serviceName: string; routePrefix?: string }>` (required)
293
+ - `healthPath?: string` (default: `/health`)
294
+
295
+ ---
296
+
297
+ ## Notes
298
+
299
+ - If Consul returns `host.docker.internal`, the library auto-resolves it to `127.0.0.1` for host-local calls.
300
+ - Keep service names consistent across registration and discovery.
301
+ - For production, always use graceful shutdown to avoid stale Consul registrations.
@@ -0,0 +1,2 @@
1
+ function c(t){return t==="host.docker.internal"?"127.0.0.1":t}async function a(t,n,o={}){let r=await t.health.service({service:n,passing:o.passing??!0});if(!r.length)throw new Error(`No healthy instance found for "${n}"`);let e=r[Math.floor(Math.random()*r.length)],i=c(e.Service.Address),s=e.Service.Port;return`http://${i}:${String(s)}`}export{a};
2
+ //# sourceMappingURL=chunk-24OKBTEJ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/discover.ts"],"sourcesContent":["import type { ConsulClient } from \"./consul\";\nimport type { ServiceDiscoveryOptions } from \"./types\";\n\nfunction normalizeHost(address: string): string {\n return address === \"host.docker.internal\" ? \"127.0.0.1\" : address;\n}\n\nexport async function getServiceUrl(\n consulClient: ConsulClient,\n serviceName: string,\n options: ServiceDiscoveryOptions = {},\n): Promise<string> {\n const services = await consulClient.health.service({\n service: serviceName,\n passing: options.passing ?? true,\n });\n\n if (!services.length) {\n throw new Error(`No healthy instance found for \"${serviceName}\"`);\n }\n\n const randomInstance = services[Math.floor(Math.random() * services.length)];\n const host = normalizeHost(randomInstance.Service.Address);\n const port = randomInstance.Service.Port;\n\n return `http://${host}:${String(port)}`;\n}\n"],"mappings":"AAGA,SAASA,EAAcC,EAAyB,CAC9C,OAAOA,IAAY,uBAAyB,YAAcA,CAC5D,CAEA,eAAsBC,EACpBC,EACAC,EACAC,EAAmC,CAAC,EACnB,CACjB,IAAMC,EAAW,MAAMH,EAAa,OAAO,QAAQ,CACjD,QAASC,EACT,QAASC,EAAQ,SAAW,EAC9B,CAAC,EAED,GAAI,CAACC,EAAS,OACZ,MAAM,IAAI,MAAM,kCAAkCF,CAAW,GAAG,EAGlE,IAAMG,EAAiBD,EAAS,KAAK,MAAM,KAAK,OAAO,EAAIA,EAAS,MAAM,CAAC,EACrEE,EAAOR,EAAcO,EAAe,QAAQ,OAAO,EACnDE,EAAOF,EAAe,QAAQ,KAEpC,MAAO,UAAUC,CAAI,IAAI,OAAOC,CAAI,CAAC,EACvC","names":["normalizeHost","address","getServiceUrl","consulClient","serviceName","options","services","randomInstance","host","port"]}
@@ -0,0 +1,39 @@
1
+ import Consul from 'consul';
2
+
3
+ interface ConsulClientOptions {
4
+ host?: string;
5
+ port?: number;
6
+ token?: string;
7
+ secure?: boolean;
8
+ }
9
+ interface ServiceDiscoveryOptions {
10
+ passing?: boolean;
11
+ }
12
+ interface ServiceRegistrationOptions {
13
+ serviceName: string;
14
+ serviceId?: string;
15
+ address: string;
16
+ port: number;
17
+ tags?: string[];
18
+ healthPath?: string;
19
+ healthInterval?: string;
20
+ healthTimeout?: string;
21
+ deregisterCriticalServiceAfter?: string;
22
+ }
23
+ interface GatewayRoute {
24
+ serviceName: string;
25
+ routePrefix?: string;
26
+ }
27
+ interface ServiceProxyOptions {
28
+ serviceName: string;
29
+ routePrefix?: string;
30
+ }
31
+ interface GatewayOptions {
32
+ routes: GatewayRoute[];
33
+ healthPath?: string;
34
+ }
35
+
36
+ type ConsulClient = InstanceType<typeof Consul>;
37
+ declare function createConsulClient(options?: ConsulClientOptions): ConsulClient;
38
+
39
+ export { type ConsulClient as C, type GatewayOptions as G, type ServiceProxyOptions as S, type GatewayRoute as a, type ServiceDiscoveryOptions as b, type ServiceRegistrationOptions as c, type ConsulClientOptions as d, createConsulClient as e };
@@ -0,0 +1,39 @@
1
+ import Consul from 'consul';
2
+
3
+ interface ConsulClientOptions {
4
+ host?: string;
5
+ port?: number;
6
+ token?: string;
7
+ secure?: boolean;
8
+ }
9
+ interface ServiceDiscoveryOptions {
10
+ passing?: boolean;
11
+ }
12
+ interface ServiceRegistrationOptions {
13
+ serviceName: string;
14
+ serviceId?: string;
15
+ address: string;
16
+ port: number;
17
+ tags?: string[];
18
+ healthPath?: string;
19
+ healthInterval?: string;
20
+ healthTimeout?: string;
21
+ deregisterCriticalServiceAfter?: string;
22
+ }
23
+ interface GatewayRoute {
24
+ serviceName: string;
25
+ routePrefix?: string;
26
+ }
27
+ interface ServiceProxyOptions {
28
+ serviceName: string;
29
+ routePrefix?: string;
30
+ }
31
+ interface GatewayOptions {
32
+ routes: GatewayRoute[];
33
+ healthPath?: string;
34
+ }
35
+
36
+ type ConsulClient = InstanceType<typeof Consul>;
37
+ declare function createConsulClient(options?: ConsulClientOptions): ConsulClient;
38
+
39
+ export { type ConsulClient as C, type GatewayOptions as G, type ServiceProxyOptions as S, type GatewayRoute as a, type ServiceDiscoveryOptions as b, type ServiceRegistrationOptions as c, type ConsulClientOptions as d, createConsulClient as e };
@@ -0,0 +1,9 @@
1
+ import { Express, RequestHandler } from 'express';
2
+ import { C as ConsulClient, G as GatewayOptions, S as ServiceProxyOptions } from './consul-D2-fKyU6.mjs';
3
+ export { a as GatewayRoute } from './consul-D2-fKyU6.mjs';
4
+ import 'consul';
5
+
6
+ declare function createServiceProxy(consulClient: ConsulClient, options: ServiceProxyOptions): RequestHandler;
7
+ declare function createGatewayApp(consulClient: ConsulClient, options: GatewayOptions): Express;
8
+
9
+ export { GatewayOptions, ServiceProxyOptions, createGatewayApp, createServiceProxy };
@@ -0,0 +1,9 @@
1
+ import { Express, RequestHandler } from 'express';
2
+ import { C as ConsulClient, G as GatewayOptions, S as ServiceProxyOptions } from './consul-D2-fKyU6.js';
3
+ export { a as GatewayRoute } from './consul-D2-fKyU6.js';
4
+ import 'consul';
5
+
6
+ declare function createServiceProxy(consulClient: ConsulClient, options: ServiceProxyOptions): RequestHandler;
7
+ declare function createGatewayApp(consulClient: ConsulClient, options: GatewayOptions): Express;
8
+
9
+ export { GatewayOptions, ServiceProxyOptions, createGatewayApp, createServiceProxy };
@@ -0,0 +1,2 @@
1
+ "use strict";var g=Object.create;var a=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var d=(e,t)=>{for(var r in t)a(e,r,{get:t[r],enumerable:!0})},l=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of P(t))!w.call(e,o)&&o!==r&&a(e,o,{get:()=>t[o],enumerable:!(n=x(t,o))||n.enumerable});return e};var C=(e,t,r)=>(r=e!=null?g(S(e)):{},l(t||!e||!e.__esModule?a(r,"default",{value:e,enumerable:!0}):r,e)),O=e=>l(a({},"__esModule",{value:!0}),e);var G={};d(G,{createGatewayApp:()=>h,createServiceProxy:()=>u});module.exports=O(G);var f=C(require("express")),m=require("http-proxy-middleware");function $(e){return e==="host.docker.internal"?"127.0.0.1":e}async function y(e,t,r={}){let n=await e.health.service({service:t,passing:r.passing??!0});if(!n.length)throw new Error(`No healthy instance found for "${t}"`);let o=n[Math.floor(Math.random()*n.length)],s=$(o.Service.Address),c=o.Service.Port;return`http://${s}:${String(c)}`}function p(e){return e.startsWith("/")?e:`/${e}`}function u(e,t){let n=`^${p(t.routePrefix??`/api/${t.serviceName}`)}`;return async(o,s,c)=>{try{let i=await y(e,t.serviceName);return(0,m.createProxyMiddleware)({target:i,changeOrigin:!0,pathRewrite:{[n]:""}})(o,s,c)}catch(i){let v=i instanceof Error?i.message:"Service discovery failed";s.status(503).json({service:t.serviceName,error:v})}}}function h(e,t){let r=(0,f.default)(),n=p(t.healthPath??"/health");r.get(n,(o,s)=>{s.status(200).send("OK")});for(let o of t.routes){let s=p(o.routePrefix??`/api/${o.serviceName}`);r.use(s,u(e,{...o,routePrefix:s}))}return r}0&&(module.exports={createGatewayApp,createServiceProxy});
2
+ //# sourceMappingURL=express.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/express.ts","../src/gateway.ts","../src/discover.ts"],"sourcesContent":["export { createGatewayApp, createServiceProxy } from \"./gateway\";\n\nexport type { GatewayOptions, GatewayRoute, ServiceProxyOptions } from \"./types\";\n","import express, { type Express, type RequestHandler } from \"express\";\nimport { createProxyMiddleware } from \"http-proxy-middleware\";\nimport type { ConsulClient } from \"./consul\";\nimport { getServiceUrl } from \"./discover\";\nimport type { GatewayOptions, ServiceProxyOptions } from \"./types\";\n\nfunction normalizePrefix(prefix: string): string {\n return prefix.startsWith(\"/\") ? prefix : `/${prefix}`;\n}\n\nexport function createServiceProxy(\n consulClient: ConsulClient,\n options: ServiceProxyOptions,\n): RequestHandler {\n const routePrefix = normalizePrefix(options.routePrefix ?? `/api/${options.serviceName}`);\n const pathPrefixPattern = `^${routePrefix}`;\n\n return async (req, res, next) => {\n try {\n const target = await getServiceUrl(consulClient, options.serviceName);\n\n return createProxyMiddleware({\n target,\n changeOrigin: true,\n pathRewrite: {\n [pathPrefixPattern]: \"\",\n },\n })(req, res, next);\n } catch (error) {\n const message = error instanceof Error ? error.message : \"Service discovery failed\";\n res.status(503).json({\n service: options.serviceName,\n error: message,\n });\n }\n };\n}\n\nexport function createGatewayApp(consulClient: ConsulClient, options: GatewayOptions): Express {\n const app = express();\n const healthPath = normalizePrefix(options.healthPath ?? \"/health\");\n\n app.get(healthPath, (_req, res) => {\n res.status(200).send(\"OK\");\n });\n\n for (const route of options.routes) {\n const routePrefix = normalizePrefix(route.routePrefix ?? `/api/${route.serviceName}`);\n app.use(routePrefix, createServiceProxy(consulClient, { ...route, routePrefix }));\n }\n\n return app;\n}\n","import type { ConsulClient } from \"./consul\";\nimport type { ServiceDiscoveryOptions } from \"./types\";\n\nfunction normalizeHost(address: string): string {\n return address === \"host.docker.internal\" ? \"127.0.0.1\" : address;\n}\n\nexport async function getServiceUrl(\n consulClient: ConsulClient,\n serviceName: string,\n options: ServiceDiscoveryOptions = {},\n): Promise<string> {\n const services = await consulClient.health.service({\n service: serviceName,\n passing: options.passing ?? true,\n });\n\n if (!services.length) {\n throw new Error(`No healthy instance found for \"${serviceName}\"`);\n }\n\n const randomInstance = services[Math.floor(Math.random() * services.length)];\n const host = normalizeHost(randomInstance.Service.Address);\n const port = randomInstance.Service.Port;\n\n return `http://${host}:${String(port)}`;\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,EAAA,uBAAAC,IAAA,eAAAC,EAAAJ,GCAA,IAAAK,EAA2D,sBAC3DC,EAAsC,iCCEtC,SAASC,EAAcC,EAAyB,CAC9C,OAAOA,IAAY,uBAAyB,YAAcA,CAC5D,CAEA,eAAsBC,EACpBC,EACAC,EACAC,EAAmC,CAAC,EACnB,CACjB,IAAMC,EAAW,MAAMH,EAAa,OAAO,QAAQ,CACjD,QAASC,EACT,QAASC,EAAQ,SAAW,EAC9B,CAAC,EAED,GAAI,CAACC,EAAS,OACZ,MAAM,IAAI,MAAM,kCAAkCF,CAAW,GAAG,EAGlE,IAAMG,EAAiBD,EAAS,KAAK,MAAM,KAAK,OAAO,EAAIA,EAAS,MAAM,CAAC,EACrEE,EAAOR,EAAcO,EAAe,QAAQ,OAAO,EACnDE,EAAOF,EAAe,QAAQ,KAEpC,MAAO,UAAUC,CAAI,IAAI,OAAOC,CAAI,CAAC,EACvC,CDpBA,SAASC,EAAgBC,EAAwB,CAC/C,OAAOA,EAAO,WAAW,GAAG,EAAIA,EAAS,IAAIA,CAAM,EACrD,CAEO,SAASC,EACdC,EACAC,EACgB,CAEhB,IAAMC,EAAoB,IADNL,EAAgBI,EAAQ,aAAe,QAAQA,EAAQ,WAAW,EAAE,CAC/C,GAEzC,MAAO,OAAOE,EAAKC,EAAKC,IAAS,CAC/B,GAAI,CACF,IAAMC,EAAS,MAAMC,EAAcP,EAAcC,EAAQ,WAAW,EAEpE,SAAO,yBAAsB,CAC3B,OAAAK,EACA,aAAc,GACd,YAAa,CACX,CAACJ,CAAiB,EAAG,EACvB,CACF,CAAC,EAAEC,EAAKC,EAAKC,CAAI,CACnB,OAASG,EAAO,CACd,IAAMC,EAAUD,aAAiB,MAAQA,EAAM,QAAU,2BACzDJ,EAAI,OAAO,GAAG,EAAE,KAAK,CACnB,QAASH,EAAQ,YACjB,MAAOQ,CACT,CAAC,CACH,CACF,CACF,CAEO,SAASC,EAAiBV,EAA4BC,EAAkC,CAC7F,IAAMU,KAAM,EAAAC,SAAQ,EACdC,EAAahB,EAAgBI,EAAQ,YAAc,SAAS,EAElEU,EAAI,IAAIE,EAAY,CAACC,EAAMV,IAAQ,CACjCA,EAAI,OAAO,GAAG,EAAE,KAAK,IAAI,CAC3B,CAAC,EAED,QAAWW,KAASd,EAAQ,OAAQ,CAClC,IAAMe,EAAcnB,EAAgBkB,EAAM,aAAe,QAAQA,EAAM,WAAW,EAAE,EACpFJ,EAAI,IAAIK,EAAajB,EAAmBC,EAAc,CAAE,GAAGe,EAAO,YAAAC,CAAY,CAAC,CAAC,CAClF,CAEA,OAAOL,CACT","names":["express_exports","__export","createGatewayApp","createServiceProxy","__toCommonJS","import_express","import_http_proxy_middleware","normalizeHost","address","getServiceUrl","consulClient","serviceName","options","services","randomInstance","host","port","normalizePrefix","prefix","createServiceProxy","consulClient","options","pathPrefixPattern","req","res","next","target","getServiceUrl","error","message","createGatewayApp","app","express","healthPath","_req","route","routePrefix"]}
@@ -0,0 +1,2 @@
1
+ import{a as c}from"./chunk-24OKBTEJ.mjs";import f from"express";import{createProxyMiddleware as m}from"http-proxy-middleware";function n(e){return e.startsWith("/")?e:`/${e}`}function p(e,r){let i=`^${n(r.routePrefix??`/api/${r.serviceName}`)}`;return async(o,t,u)=>{try{let s=await c(e,r.serviceName);return m({target:s,changeOrigin:!0,pathRewrite:{[i]:""}})(o,t,u)}catch(s){let y=s instanceof Error?s.message:"Service discovery failed";t.status(503).json({service:r.serviceName,error:y})}}}function x(e,r){let a=f(),i=n(r.healthPath??"/health");a.get(i,(o,t)=>{t.status(200).send("OK")});for(let o of r.routes){let t=n(o.routePrefix??`/api/${o.serviceName}`);a.use(t,p(e,{...o,routePrefix:t}))}return a}export{x as createGatewayApp,p as createServiceProxy};
2
+ //# sourceMappingURL=express.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/gateway.ts"],"sourcesContent":["import express, { type Express, type RequestHandler } from \"express\";\nimport { createProxyMiddleware } from \"http-proxy-middleware\";\nimport type { ConsulClient } from \"./consul\";\nimport { getServiceUrl } from \"./discover\";\nimport type { GatewayOptions, ServiceProxyOptions } from \"./types\";\n\nfunction normalizePrefix(prefix: string): string {\n return prefix.startsWith(\"/\") ? prefix : `/${prefix}`;\n}\n\nexport function createServiceProxy(\n consulClient: ConsulClient,\n options: ServiceProxyOptions,\n): RequestHandler {\n const routePrefix = normalizePrefix(options.routePrefix ?? `/api/${options.serviceName}`);\n const pathPrefixPattern = `^${routePrefix}`;\n\n return async (req, res, next) => {\n try {\n const target = await getServiceUrl(consulClient, options.serviceName);\n\n return createProxyMiddleware({\n target,\n changeOrigin: true,\n pathRewrite: {\n [pathPrefixPattern]: \"\",\n },\n })(req, res, next);\n } catch (error) {\n const message = error instanceof Error ? error.message : \"Service discovery failed\";\n res.status(503).json({\n service: options.serviceName,\n error: message,\n });\n }\n };\n}\n\nexport function createGatewayApp(consulClient: ConsulClient, options: GatewayOptions): Express {\n const app = express();\n const healthPath = normalizePrefix(options.healthPath ?? \"/health\");\n\n app.get(healthPath, (_req, res) => {\n res.status(200).send(\"OK\");\n });\n\n for (const route of options.routes) {\n const routePrefix = normalizePrefix(route.routePrefix ?? `/api/${route.serviceName}`);\n app.use(routePrefix, createServiceProxy(consulClient, { ...route, routePrefix }));\n }\n\n return app;\n}\n"],"mappings":"yCAAA,OAAOA,MAAoD,UAC3D,OAAS,yBAAAC,MAA6B,wBAKtC,SAASC,EAAgBC,EAAwB,CAC/C,OAAOA,EAAO,WAAW,GAAG,EAAIA,EAAS,IAAIA,CAAM,EACrD,CAEO,SAASC,EACdC,EACAC,EACgB,CAEhB,IAAMC,EAAoB,IADNL,EAAgBI,EAAQ,aAAe,QAAQA,EAAQ,WAAW,EAAE,CAC/C,GAEzC,MAAO,OAAOE,EAAKC,EAAKC,IAAS,CAC/B,GAAI,CACF,IAAMC,EAAS,MAAMC,EAAcP,EAAcC,EAAQ,WAAW,EAEpE,OAAOO,EAAsB,CAC3B,OAAAF,EACA,aAAc,GACd,YAAa,CACX,CAACJ,CAAiB,EAAG,EACvB,CACF,CAAC,EAAEC,EAAKC,EAAKC,CAAI,CACnB,OAASI,EAAO,CACd,IAAMC,EAAUD,aAAiB,MAAQA,EAAM,QAAU,2BACzDL,EAAI,OAAO,GAAG,EAAE,KAAK,CACnB,QAASH,EAAQ,YACjB,MAAOS,CACT,CAAC,CACH,CACF,CACF,CAEO,SAASC,EAAiBX,EAA4BC,EAAkC,CAC7F,IAAMW,EAAMC,EAAQ,EACdC,EAAajB,EAAgBI,EAAQ,YAAc,SAAS,EAElEW,EAAI,IAAIE,EAAY,CAACC,EAAMX,IAAQ,CACjCA,EAAI,OAAO,GAAG,EAAE,KAAK,IAAI,CAC3B,CAAC,EAED,QAAWY,KAASf,EAAQ,OAAQ,CAClC,IAAMgB,EAAcpB,EAAgBmB,EAAM,aAAe,QAAQA,EAAM,WAAW,EAAE,EACpFJ,EAAI,IAAIK,EAAalB,EAAmBC,EAAc,CAAE,GAAGgB,EAAO,YAAAC,CAAY,CAAC,CAAC,CAClF,CAEA,OAAOL,CACT","names":["express","createProxyMiddleware","normalizePrefix","prefix","createServiceProxy","consulClient","options","pathPrefixPattern","req","res","next","target","getServiceUrl","createProxyMiddleware","error","message","createGatewayApp","app","express","healthPath","_req","route","routePrefix"]}
@@ -0,0 +1,10 @@
1
+ import { C as ConsulClient, b as ServiceDiscoveryOptions, c as ServiceRegistrationOptions } from './consul-D2-fKyU6.mjs';
2
+ export { d as ConsulClientOptions, e as createConsulClient } from './consul-D2-fKyU6.mjs';
3
+ import 'consul';
4
+
5
+ declare function getServiceUrl(consulClient: ConsulClient, serviceName: string, options?: ServiceDiscoveryOptions): Promise<string>;
6
+
7
+ declare function registerService(consulClient: ConsulClient, options: ServiceRegistrationOptions): Promise<string>;
8
+ declare function deregisterService(consulClient: ConsulClient, serviceId: string): Promise<void>;
9
+
10
+ export { ConsulClient, ServiceDiscoveryOptions, ServiceRegistrationOptions, deregisterService, getServiceUrl, registerService };
@@ -0,0 +1,10 @@
1
+ import { C as ConsulClient, b as ServiceDiscoveryOptions, c as ServiceRegistrationOptions } from './consul-D2-fKyU6.js';
2
+ export { d as ConsulClientOptions, e as createConsulClient } from './consul-D2-fKyU6.js';
3
+ import 'consul';
4
+
5
+ declare function getServiceUrl(consulClient: ConsulClient, serviceName: string, options?: ServiceDiscoveryOptions): Promise<string>;
6
+
7
+ declare function registerService(consulClient: ConsulClient, options: ServiceRegistrationOptions): Promise<string>;
8
+ declare function deregisterService(consulClient: ConsulClient, serviceId: string): Promise<void>;
9
+
10
+ export { ConsulClient, ServiceDiscoveryOptions, ServiceRegistrationOptions, deregisterService, getServiceUrl, registerService };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";var g=Object.create;var s=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var r in e)s(t,r,{get:e[r],enumerable:!0})},a=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of C(e))!d.call(t,i)&&i!==r&&s(t,i,{get:()=>e[i],enumerable:!(n=m(e,i))||n.enumerable});return t};var S=(t,e,r)=>(r=t!=null?g(f(t)):{},a(e||!t||!t.__esModule?s(r,"default",{value:t,enumerable:!0}):r,t)),x=t=>a(s({},"__esModule",{value:!0}),t);var $={};y($,{createConsulClient:()=>p,deregisterService:()=>v,getServiceUrl:()=>u,registerService:()=>h});module.exports=x($);var l=S(require("consul"));function p(t={}){let{host:e="127.0.0.1",port:r=8500,token:n,secure:i=!1}=t;return new l.default({host:e,port:r,secure:i,defaults:n?{token:n}:void 0})}function O(t){return t==="host.docker.internal"?"127.0.0.1":t}async function u(t,e,r={}){let n=await t.health.service({service:e,passing:r.passing??!0});if(!n.length)throw new Error(`No healthy instance found for "${e}"`);let i=n[Math.floor(Math.random()*n.length)],o=O(i.Service.Address),c=i.Service.Port;return`http://${o}:${String(c)}`}async function h(t,e){let r=e.serviceId??`${e.serviceName}-${process.pid}`,n=e.healthPath??"/health",i=e.healthInterval??"10s",o=e.healthTimeout??"5s",c=e.deregisterCriticalServiceAfter??"30s";return await t.agent.service.register({id:r,name:e.serviceName,address:e.address,port:e.port,tags:e.tags,check:{name:`${e.serviceName}-health`,http:`http://${e.address}:${String(e.port)}${n}`,interval:i,timeout:o,deregistercriticalserviceafter:c}}),r}async function v(t,e){await t.agent.service.deregister(e)}0&&(module.exports={createConsulClient,deregisterService,getServiceUrl,registerService});
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/consul.ts","../src/discover.ts","../src/register.ts"],"sourcesContent":["export { createConsulClient } from \"./consul\";\nexport type { ConsulClient } from \"./consul\";\n\nexport { getServiceUrl } from \"./discover\";\nexport { registerService, deregisterService } from \"./register\";\n\nexport type {\n ConsulClientOptions,\n ServiceDiscoveryOptions,\n ServiceRegistrationOptions,\n} from \"./types\";\n","import Consul from \"consul\";\nimport type { ConsulClientOptions } from \"./types\";\n\nexport type ConsulClient = InstanceType<typeof Consul>;\n\nexport function createConsulClient(options: ConsulClientOptions = {}): ConsulClient {\n const { host = \"127.0.0.1\", port = 8500, token, secure = false } = options;\n\n return new Consul({\n host,\n port,\n secure,\n defaults: token ? { token } : undefined,\n });\n}\n","import type { ConsulClient } from \"./consul\";\nimport type { ServiceDiscoveryOptions } from \"./types\";\n\nfunction normalizeHost(address: string): string {\n return address === \"host.docker.internal\" ? \"127.0.0.1\" : address;\n}\n\nexport async function getServiceUrl(\n consulClient: ConsulClient,\n serviceName: string,\n options: ServiceDiscoveryOptions = {},\n): Promise<string> {\n const services = await consulClient.health.service({\n service: serviceName,\n passing: options.passing ?? true,\n });\n\n if (!services.length) {\n throw new Error(`No healthy instance found for \"${serviceName}\"`);\n }\n\n const randomInstance = services[Math.floor(Math.random() * services.length)];\n const host = normalizeHost(randomInstance.Service.Address);\n const port = randomInstance.Service.Port;\n\n return `http://${host}:${String(port)}`;\n}\n","import type { ConsulClient } from \"./consul\";\nimport type { ServiceRegistrationOptions } from \"./types\";\n\nexport async function registerService(\n consulClient: ConsulClient,\n options: ServiceRegistrationOptions,\n): Promise<string> {\n const serviceId = options.serviceId ?? `${options.serviceName}-${process.pid}`;\n const healthPath = options.healthPath ?? \"/health\";\n const healthInterval = options.healthInterval ?? \"10s\";\n const healthTimeout = options.healthTimeout ?? \"5s\";\n const deregisterAfter = options.deregisterCriticalServiceAfter ?? \"30s\";\n\n await consulClient.agent.service.register({\n id: serviceId,\n name: options.serviceName,\n address: options.address,\n port: options.port,\n tags: options.tags,\n check: {\n name: `${options.serviceName}-health`,\n http: `http://${options.address}:${String(options.port)}${healthPath}`,\n interval: healthInterval,\n timeout: healthTimeout,\n deregistercriticalserviceafter: deregisterAfter,\n },\n });\n\n return serviceId;\n}\n\nexport async function deregisterService(\n consulClient: ConsulClient,\n serviceId: string,\n): Promise<void> {\n await consulClient.agent.service.deregister(serviceId);\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,EAAA,sBAAAC,EAAA,kBAAAC,EAAA,oBAAAC,IAAA,eAAAC,EAAAN,GCAA,IAAAO,EAAmB,qBAKZ,SAASC,EAAmBC,EAA+B,CAAC,EAAiB,CAClF,GAAM,CAAE,KAAAC,EAAO,YAAa,KAAAC,EAAO,KAAM,MAAAC,EAAO,OAAAC,EAAS,EAAM,EAAIJ,EAEnE,OAAO,IAAI,EAAAK,QAAO,CAChB,KAAAJ,EACA,KAAAC,EACA,OAAAE,EACA,SAAUD,EAAQ,CAAE,MAAAA,CAAM,EAAI,MAChC,CAAC,CACH,CCXA,SAASG,EAAcC,EAAyB,CAC9C,OAAOA,IAAY,uBAAyB,YAAcA,CAC5D,CAEA,eAAsBC,EACpBC,EACAC,EACAC,EAAmC,CAAC,EACnB,CACjB,IAAMC,EAAW,MAAMH,EAAa,OAAO,QAAQ,CACjD,QAASC,EACT,QAASC,EAAQ,SAAW,EAC9B,CAAC,EAED,GAAI,CAACC,EAAS,OACZ,MAAM,IAAI,MAAM,kCAAkCF,CAAW,GAAG,EAGlE,IAAMG,EAAiBD,EAAS,KAAK,MAAM,KAAK,OAAO,EAAIA,EAAS,MAAM,CAAC,EACrEE,EAAOR,EAAcO,EAAe,QAAQ,OAAO,EACnDE,EAAOF,EAAe,QAAQ,KAEpC,MAAO,UAAUC,CAAI,IAAI,OAAOC,CAAI,CAAC,EACvC,CCvBA,eAAsBC,EACpBC,EACAC,EACiB,CACjB,IAAMC,EAAYD,EAAQ,WAAa,GAAGA,EAAQ,WAAW,IAAI,QAAQ,GAAG,GACtEE,EAAaF,EAAQ,YAAc,UACnCG,EAAiBH,EAAQ,gBAAkB,MAC3CI,EAAgBJ,EAAQ,eAAiB,KACzCK,EAAkBL,EAAQ,gCAAkC,MAElE,aAAMD,EAAa,MAAM,QAAQ,SAAS,CACxC,GAAIE,EACJ,KAAMD,EAAQ,YACd,QAASA,EAAQ,QACjB,KAAMA,EAAQ,KACd,KAAMA,EAAQ,KACd,MAAO,CACL,KAAM,GAAGA,EAAQ,WAAW,UAC5B,KAAM,UAAUA,EAAQ,OAAO,IAAI,OAAOA,EAAQ,IAAI,CAAC,GAAGE,CAAU,GACpE,SAAUC,EACV,QAASC,EACT,+BAAgCC,CAClC,CACF,CAAC,EAEMJ,CACT,CAEA,eAAsBK,EACpBP,EACAE,EACe,CACf,MAAMF,EAAa,MAAM,QAAQ,WAAWE,CAAS,CACvD","names":["index_exports","__export","createConsulClient","deregisterService","getServiceUrl","registerService","__toCommonJS","import_consul","createConsulClient","options","host","port","token","secure","Consul","normalizeHost","address","getServiceUrl","consulClient","serviceName","options","services","randomInstance","host","port","registerService","consulClient","options","serviceId","healthPath","healthInterval","healthTimeout","deregisterAfter","deregisterService"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import{a}from"./chunk-24OKBTEJ.mjs";import c from"consul";function l(t={}){let{host:e="127.0.0.1",port:r=8500,token:i,secure:s=!1}=t;return new c({host:e,port:r,secure:s,defaults:i?{token:i}:void 0})}async function p(t,e){let r=e.serviceId??`${e.serviceName}-${process.pid}`,i=e.healthPath??"/health",s=e.healthInterval??"10s",n=e.healthTimeout??"5s",o=e.deregisterCriticalServiceAfter??"30s";return await t.agent.service.register({id:r,name:e.serviceName,address:e.address,port:e.port,tags:e.tags,check:{name:`${e.serviceName}-health`,http:`http://${e.address}:${String(e.port)}${i}`,interval:s,timeout:n,deregistercriticalserviceafter:o}}),r}async function u(t,e){await t.agent.service.deregister(e)}export{l as createConsulClient,u as deregisterService,a as getServiceUrl,p as registerService};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/consul.ts","../src/register.ts"],"sourcesContent":["import Consul from \"consul\";\nimport type { ConsulClientOptions } from \"./types\";\n\nexport type ConsulClient = InstanceType<typeof Consul>;\n\nexport function createConsulClient(options: ConsulClientOptions = {}): ConsulClient {\n const { host = \"127.0.0.1\", port = 8500, token, secure = false } = options;\n\n return new Consul({\n host,\n port,\n secure,\n defaults: token ? { token } : undefined,\n });\n}\n","import type { ConsulClient } from \"./consul\";\nimport type { ServiceRegistrationOptions } from \"./types\";\n\nexport async function registerService(\n consulClient: ConsulClient,\n options: ServiceRegistrationOptions,\n): Promise<string> {\n const serviceId = options.serviceId ?? `${options.serviceName}-${process.pid}`;\n const healthPath = options.healthPath ?? \"/health\";\n const healthInterval = options.healthInterval ?? \"10s\";\n const healthTimeout = options.healthTimeout ?? \"5s\";\n const deregisterAfter = options.deregisterCriticalServiceAfter ?? \"30s\";\n\n await consulClient.agent.service.register({\n id: serviceId,\n name: options.serviceName,\n address: options.address,\n port: options.port,\n tags: options.tags,\n check: {\n name: `${options.serviceName}-health`,\n http: `http://${options.address}:${String(options.port)}${healthPath}`,\n interval: healthInterval,\n timeout: healthTimeout,\n deregistercriticalserviceafter: deregisterAfter,\n },\n });\n\n return serviceId;\n}\n\nexport async function deregisterService(\n consulClient: ConsulClient,\n serviceId: string,\n): Promise<void> {\n await consulClient.agent.service.deregister(serviceId);\n}\n"],"mappings":"oCAAA,OAAOA,MAAY,SAKZ,SAASC,EAAmBC,EAA+B,CAAC,EAAiB,CAClF,GAAM,CAAE,KAAAC,EAAO,YAAa,KAAAC,EAAO,KAAM,MAAAC,EAAO,OAAAC,EAAS,EAAM,EAAIJ,EAEnE,OAAO,IAAIF,EAAO,CAChB,KAAAG,EACA,KAAAC,EACA,OAAAE,EACA,SAAUD,EAAQ,CAAE,MAAAA,CAAM,EAAI,MAChC,CAAC,CACH,CCXA,eAAsBE,EACpBC,EACAC,EACiB,CACjB,IAAMC,EAAYD,EAAQ,WAAa,GAAGA,EAAQ,WAAW,IAAI,QAAQ,GAAG,GACtEE,EAAaF,EAAQ,YAAc,UACnCG,EAAiBH,EAAQ,gBAAkB,MAC3CI,EAAgBJ,EAAQ,eAAiB,KACzCK,EAAkBL,EAAQ,gCAAkC,MAElE,aAAMD,EAAa,MAAM,QAAQ,SAAS,CACxC,GAAIE,EACJ,KAAMD,EAAQ,YACd,QAASA,EAAQ,QACjB,KAAMA,EAAQ,KACd,KAAMA,EAAQ,KACd,MAAO,CACL,KAAM,GAAGA,EAAQ,WAAW,UAC5B,KAAM,UAAUA,EAAQ,OAAO,IAAI,OAAOA,EAAQ,IAAI,CAAC,GAAGE,CAAU,GACpE,SAAUC,EACV,QAASC,EACT,+BAAgCC,CAClC,CACF,CAAC,EAEMJ,CACT,CAEA,eAAsBK,EACpBP,EACAE,EACe,CACf,MAAMF,EAAa,MAAM,QAAQ,WAAWE,CAAS,CACvD","names":["Consul","createConsulClient","options","host","port","token","secure","registerService","consulClient","options","serviceId","healthPath","healthInterval","healthTimeout","deregisterAfter","deregisterService"]}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@abinashpatri/orchestrator",
3
+ "version": "1.0.0",
4
+ "description": "Reusable TypeScript/JavaScript service discovery and API gateway toolkit",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "require": "./dist/index.js",
12
+ "import": "./dist/index.mjs"
13
+ },
14
+ "./express": {
15
+ "types": "./dist/express.d.ts",
16
+ "require": "./dist/express.js",
17
+ "import": "./dist/express.mjs"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "scripts": {
24
+ "build": "tsup",
25
+ "dev": "tsup --watch",
26
+ "typecheck": "tsc --noEmit",
27
+ "prepublishOnly": "npm run typecheck && npm run build"
28
+ },
29
+ "keywords": [
30
+ "consul",
31
+ "service-discovery",
32
+ "api-gateway",
33
+ "orchestrator",
34
+ "typescript"
35
+ ],
36
+ "author": "Abinash Patri",
37
+ "license": "MIT",
38
+ "type": "commonjs",
39
+ "devDependencies": {
40
+ "@types/express": "^5.0.6",
41
+ "@types/node": "^25.5.0",
42
+ "eslint": "^10.1.0",
43
+ "express": "^5.1.0",
44
+ "http-proxy-middleware": "^3.0.5",
45
+ "prettier": "^3.8.1",
46
+ "tsup": "^8.5.1",
47
+ "typescript": "^5.9.3"
48
+ },
49
+ "peerDependencies": {
50
+ "express": ">=4.18.0",
51
+ "http-proxy-middleware": ">=3.0.0"
52
+ },
53
+ "peerDependenciesMeta": {
54
+ "express": {
55
+ "optional": true
56
+ },
57
+ "http-proxy-middleware": {
58
+ "optional": true
59
+ }
60
+ },
61
+ "dependencies": {
62
+ "consul": "^2.0.1"
63
+ }
64
+ }