1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | const debug_1 = __importDefault(require("debug"));
|
7 | const error_1 = __importDefault(require("./error"));
|
8 | const server_1 = __importDefault(require("./server"));
|
9 | const debug = debug_1.default("NCEnvironment");
|
10 | class Environment {
|
11 | constructor() {
|
12 | this.url = process.env.NEXTCLOUD_URL;
|
13 | this.userName = process.env.NEXTCLOUD_USERNAME;
|
14 | this.password = process.env.NEXTCLOUD_PASSWORD;
|
15 | if ((process.env.TEST_RECORDING_ACTIVE &&
|
16 | (process.env.TEST_RECORDING_ACTIVE === "0" || process.env.TEST_RECORDING_ACTIVE === "false" || process.env.TEST_RECORDING_ACTIVE === "inactive")) ||
|
17 | !process.env.TEST_RECORDING_ACTIVE) {
|
18 | this.recordingActive = false;
|
19 | }
|
20 | else {
|
21 | this.recordingActive = true;
|
22 | }
|
23 | }
|
24 | |
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | getServer() {
|
31 | if (!this.url) {
|
32 | throw new error_1.default("NCEnvironment: NEXTCLOUD_URL not defined in environment", "ERR_NEXTCLOUD_URL_NOT_DEFINED");
|
33 | }
|
34 | if (!this.userName) {
|
35 | throw new error_1.default("NCEnvironment: NEXTCLOUD_USERNAME not defined in environment", "ERR_NEXTCLOUD_USERNAME_NOT_DEFINED");
|
36 | }
|
37 | if (!this.password) {
|
38 | throw new error_1.default("NCEnvironment: NEXTCLOUD_PASSWORD not defined in environment", "ERR_NEXTCLOUD_PASSWORD_NOT_DEFINED");
|
39 | }
|
40 | return new server_1.default({
|
41 | basicAuth: {
|
42 | password: this.password,
|
43 | username: this.userName,
|
44 | },
|
45 | logRequestResponse: this.recordingActive,
|
46 | url: this.url,
|
47 | });
|
48 | }
|
49 | }
|
50 | exports.default = Environment;
|