@routr/dispatcher 2.0.8-alpha.2 → 2.0.8-alpha.21

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.
@@ -27,18 +27,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.getConfig = void 0;
30
- const fs_1 = __importDefault(require("fs"));
31
30
  const schema_1 = require("./schema");
32
31
  const ajv_1 = __importDefault(require("ajv"));
33
32
  const E = __importStar(require("fp-ts/Either"));
33
+ const common_1 = require("@routr/common");
34
34
  const ajv = new ajv_1.default();
35
35
  const validate = ajv.compile(schema_1.schema);
36
36
  const getConfig = (path) => {
37
- const c = JSON.parse(fs_1.default.readFileSync(path, "utf8"));
37
+ const c = common_1.Helper.readConfigFile(path);
38
38
  if (!validate(Object.assign({}, c))) {
39
39
  return E.left(new Error(JSON.stringify(validate.errors[0].message)));
40
40
  }
41
- // convert funcMatch to actual functions
41
+ // Convert funcMatch to actual functions
42
42
  const processors = c.spec.processors.map((p) => {
43
43
  const { ref, addr, methods, matchFunc } = p;
44
44
  return { ref, addr, methods, matchFunc: eval(`(${matchFunc})`) };
@@ -12,16 +12,9 @@ export declare const schema: {
12
12
  description: string;
13
13
  type: string;
14
14
  };
15
- metadata: {
15
+ ref: {
16
16
  description: string;
17
17
  type: string;
18
- properties: {
19
- ref: {
20
- description: string;
21
- type: string;
22
- };
23
- };
24
- required: string[];
25
18
  };
26
19
  spec: {
27
20
  description: string;
@@ -33,16 +33,9 @@ exports.schema = {
33
33
  description: "Resource version",
34
34
  type: "string"
35
35
  },
36
- metadata: {
37
- description: "Resource metadata",
38
- type: "object",
39
- properties: {
40
- ref: {
41
- description: "EdgePort reference",
42
- type: "string"
43
- }
44
- },
45
- required: ["ref"]
36
+ ref: {
37
+ description: "EdgePort reference",
38
+ type: "string"
46
39
  },
47
40
  spec: {
48
41
  description: "Operations spec for EdgePort",
@@ -96,5 +89,5 @@ exports.schema = {
96
89
  }
97
90
  }
98
91
  },
99
- required: ["kind", "metadata", "spec", "apiVersion"]
92
+ required: ["kind", "ref", "spec", "apiVersion"]
100
93
  };
@@ -5,10 +5,10 @@ const errors_1 = require("./errors");
5
5
  const hasMethod = (config, request) => config.methods.includes(request.method);
6
6
  exports.hasMethod = hasMethod;
7
7
  // TODO: We need a way to test the matching function
8
- const filter = (request, config) => (0, exports.hasMethod)(config, request) && (config === null || config === void 0 ? void 0 : config.matchFunc(request));
8
+ const filter = (request, config) => (0, exports.hasMethod)(config, request) && config.matchFunc(request);
9
9
  exports.filter = filter;
10
10
  const findProcessor = (list) => (request) => {
11
11
  var _a;
12
- return (_a = list.find((config) => (0, exports.filter)(request, config))) !== null && _a !== void 0 ? _a : new errors_1.NotMatchingProcessorFound(request === null || request === void 0 ? void 0 : request.ref);
12
+ return (_a = list.find((config) => (0, exports.filter)(request, config))) !== null && _a !== void 0 ? _a : new errors_1.NotMatchingProcessorFound(request.ref);
13
13
  };
14
14
  exports.findProcessor = findProcessor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/dispatcher",
3
- "version": "2.0.8-alpha.2",
3
+ "version": "2.0.8-alpha.21",
4
4
  "description": "Receives SIP messages and forwards them to the corresponding Message Processor",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/routr#readme",
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@fonoster/logger": "0.3.18",
29
- "@grpc/grpc-js": "^1.5.9",
29
+ "@grpc/grpc-js": "^1.8.4",
30
30
  "@opentelemetry/api": "^1.0.4",
31
31
  "@opentelemetry/exporter-jaeger": "^1.0.4",
32
32
  "@opentelemetry/instrumentation": "^0.27.0",
@@ -35,7 +35,7 @@
35
35
  "@opentelemetry/sdk-trace-base": "^1.0.4",
36
36
  "@opentelemetry/sdk-trace-node": "^1.0.4",
37
37
  "@opentelemetry/semantic-conventions": "^1.0.4",
38
- "@routr/common": "^2.0.8-alpha.2",
38
+ "@routr/common": "^2.0.8-alpha.21",
39
39
  "ajv": "^6.12.6",
40
40
  "fp-ts": "^2.11.8"
41
41
  },
@@ -46,5 +46,5 @@
46
46
  "bugs": {
47
47
  "url": "https://github.com/fonoster/routr/issues"
48
48
  },
49
- "gitHead": "28ab976b0ef8b5cd34e278ea6fda13c518d7d052"
49
+ "gitHead": "1841d2d8d51bebfdc3af7e81435064e81b176449"
50
50
  }