@routr/connect 2.0.5-alpha.10
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 +21 -0
- package/dist/runner.d.ts +2 -0
- package/dist/runner.js +36 -0
- package/dist/service.d.ts +2 -0
- package/dist/service.js +41 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.js +2 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +24 -0
- package/package.json +41 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 Fonoster Inc
|
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/dist/runner.d.ts
ADDED
package/dist/runner.js
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
"use strict";
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
5
|
+
};
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
7
|
+
/*
|
8
|
+
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
9
|
+
* http://github.com/fonoster/routr
|
10
|
+
*
|
11
|
+
* This file is part of Routr
|
12
|
+
*
|
13
|
+
* Licensed under the MIT License (the "License");
|
14
|
+
* you may not use this file except in compliance with
|
15
|
+
* the License. You may obtain a copy of the License at
|
16
|
+
*
|
17
|
+
* https://opensource.org/licenses/MIT
|
18
|
+
*
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
20
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
22
|
+
* See the License for the specific language governing permissions and
|
23
|
+
* limitations under the License.
|
24
|
+
*/
|
25
|
+
const logger_1 = __importDefault(require("@fonoster/logger"));
|
26
|
+
const service_1 = __importDefault(require("./service"));
|
27
|
+
if (process.env.LOCATION_ADDR) {
|
28
|
+
service_1.default({
|
29
|
+
bindAddr: process.env.BIND_ADDR || "0.0.0.0:51904",
|
30
|
+
locationAddr: process.env.LOCATION_ADDR
|
31
|
+
});
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
logger_1.default.error("environment variable LOCATION_ADDR is required but was not found");
|
35
|
+
process.exit(1);
|
36
|
+
}
|
package/dist/service.js
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const location_1 = require("@routr/location");
|
16
|
+
const utils_1 = require("./utils");
|
17
|
+
const processor_1 = __importDefault(require("@routr/processor"));
|
18
|
+
const logger_1 = __importDefault(require("@fonoster/logger"));
|
19
|
+
function ConnectProcessor(config) {
|
20
|
+
const { bindAddr, locationAddr } = config;
|
21
|
+
const location = new location_1.LocationClient({ addr: locationAddr });
|
22
|
+
new processor_1.default({ bindAddr, name: "connect" })
|
23
|
+
.listen((req, res) => __awaiter(this, void 0, void 0, function* () {
|
24
|
+
logger_1.default.silly(JSON.stringify(req, null, ' '));
|
25
|
+
switch (req.method.toString()) {
|
26
|
+
case 'PUBLISH':
|
27
|
+
case 'NOTIFY':
|
28
|
+
case 'SUBSCRIBE':
|
29
|
+
res.sendMethodNotAllowed();
|
30
|
+
break;
|
31
|
+
case 'REGISTER':
|
32
|
+
yield utils_1.createRegisterHandler(location)(req, res);
|
33
|
+
break;
|
34
|
+
case 'CANCEL':
|
35
|
+
break;
|
36
|
+
default:
|
37
|
+
res.sendNotImplemented();
|
38
|
+
}
|
39
|
+
}));
|
40
|
+
}
|
41
|
+
exports.default = ConnectProcessor;
|
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
package/dist/utils.d.ts
ADDED
package/dist/utils.js
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.createRegisterHandler = void 0;
|
13
|
+
const location_1 = require("@routr/location");
|
14
|
+
const processor_1 = require("@routr/processor");
|
15
|
+
const createRegisterHandler = (location) => {
|
16
|
+
return (request, res) => __awaiter(void 0, void 0, void 0, function* () {
|
17
|
+
yield location.addRoute({
|
18
|
+
aor: processor_1.Target.getTargetAOR(request),
|
19
|
+
route: location_1.Helper.createRoute(request)
|
20
|
+
});
|
21
|
+
res.sendOk();
|
22
|
+
});
|
23
|
+
};
|
24
|
+
exports.createRegisterHandler = createRegisterHandler;
|
package/package.json
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
{
|
2
|
+
"name": "@routr/connect",
|
3
|
+
"version": "2.0.5-alpha.10",
|
4
|
+
"description": "Default processor",
|
5
|
+
"author": "Pedro Sanders <psanders@fonoster.com>",
|
6
|
+
"homepage": "https://github.com/fonoster/routr#readme",
|
7
|
+
"license": "MIT",
|
8
|
+
"main": "dist/connect",
|
9
|
+
"types": "dist/connect",
|
10
|
+
"directories": {
|
11
|
+
"src": "src",
|
12
|
+
"test": "test"
|
13
|
+
},
|
14
|
+
"scripts": {
|
15
|
+
"prebuild": "rimraf ./dist tsconfig.tsbuildinfo",
|
16
|
+
"build": "tsc -b tsconfig.json"
|
17
|
+
},
|
18
|
+
"bin": {
|
19
|
+
"run_connect": "dist/runner.js"
|
20
|
+
},
|
21
|
+
"dependencies": {
|
22
|
+
"@fonoster/logger": "^0.3.3",
|
23
|
+
"@routr/common": "^2.0.5-alpha.10",
|
24
|
+
"@routr/location": "^2.0.5-alpha.10",
|
25
|
+
"@routr/processor": "^2.0.5-alpha.10"
|
26
|
+
},
|
27
|
+
"files": [
|
28
|
+
"dist"
|
29
|
+
],
|
30
|
+
"publishConfig": {
|
31
|
+
"access": "public"
|
32
|
+
},
|
33
|
+
"repository": {
|
34
|
+
"type": "git",
|
35
|
+
"url": "git+https://github.com/fonoster/routr.git"
|
36
|
+
},
|
37
|
+
"bugs": {
|
38
|
+
"url": "https://github.com/fonoster/routr/issues"
|
39
|
+
},
|
40
|
+
"gitHead": "10c6ff135a370a4a4634478fdaf5f42c5c13e28c"
|
41
|
+
}
|