@scefira/dfw 0.1.15 → 0.2.1
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/lib/DFWInstance.d.ts +20 -20
- package/lib/DFWInstance.js +55 -55
- package/lib/DFWUtils.d.ts +27 -27
- package/lib/DFWUtils.js +63 -63
- package/lib/DFWUtils.js.map +1 -1
- package/lib/index.d.ts +10 -10
- package/lib/index.js +25 -25
- package/lib/manager/APIManager.d.ts +47 -47
- package/lib/manager/APIManager.d.ts.map +1 -1
- package/lib/manager/APIManager.js +207 -233
- package/lib/manager/APIManager.js.map +1 -1
- package/lib/manager/DFWModule.d.ts +13 -13
- package/lib/manager/DFWModule.js +19 -19
- package/lib/manager/DatabaseManager.d.ts +8 -8
- package/lib/manager/DatabaseManager.js +24 -24
- package/lib/manager/FileManager.d.ts +130 -130
- package/lib/manager/FileManager.js +254 -254
- package/lib/manager/SecurityManager.d.ts +50 -50
- package/lib/manager/SecurityManager.d.ts.map +1 -1
- package/lib/manager/SecurityManager.js +187 -191
- package/lib/manager/SecurityManager.js.map +1 -1
- package/lib/manager/SessionManager.d.ts +40 -40
- package/lib/manager/SessionManager.d.ts.map +1 -1
- package/lib/manager/SessionManager.js +195 -173
- package/lib/manager/SessionManager.js.map +1 -1
- package/lib/manager/UserManager.d.ts +42 -42
- package/lib/manager/UserManager.js +62 -62
- package/lib/test.d.ts +1 -1
- package/lib/test.js +70 -70
- package/lib/test.js.map +1 -1
- package/lib/types/APIListenerConfig.d.ts +52 -52
- package/lib/types/APIListenerConfig.js +2 -2
- package/lib/types/DFWBoot.d.ts +18 -18
- package/lib/types/DFWBoot.d.ts.map +1 -1
- package/lib/types/DFWBoot.js +2 -2
- package/lib/types/DFWConfig.d.ts +54 -54
- package/lib/types/DFWConfig.js +2 -2
- package/lib/types/DFWRequestScheme.d.ts +33 -37
- package/lib/types/DFWRequestScheme.d.ts.map +1 -1
- package/lib/types/DFWRequestScheme.js +2 -2
- package/package.json +4 -3
- package/prisma/schema.prisma +5 -27
package/lib/DFWInstance.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import APIManager from "./manager/APIManager";
|
|
2
|
-
import DatabaseManager from "./manager/DatabaseManager";
|
|
3
|
-
import FileManager from "./manager/FileManager";
|
|
4
|
-
import SecurityManager from "./manager/SecurityManager";
|
|
5
|
-
import SessionManager from "./manager/SessionManager";
|
|
6
|
-
import UserManager from "./manager/UserManager";
|
|
7
|
-
import { DFWConfig } from "./types/DFWConfig";
|
|
8
|
-
import { PrismaClient } from "@prisma/client";
|
|
9
|
-
declare class DFWInstance {
|
|
10
|
-
readonly config: DFWConfig;
|
|
11
|
-
readonly database: PrismaClient;
|
|
12
|
-
DatabaseManager: DatabaseManager;
|
|
13
|
-
APIManager: APIManager;
|
|
14
|
-
SessionManager: SessionManager;
|
|
15
|
-
SecurityManager: SecurityManager;
|
|
16
|
-
UserManager: UserManager;
|
|
17
|
-
FileManager: FileManager;
|
|
18
|
-
constructor(config: DFWConfig);
|
|
19
|
-
}
|
|
20
|
-
export default DFWInstance;
|
|
1
|
+
import APIManager from "./manager/APIManager";
|
|
2
|
+
import DatabaseManager from "./manager/DatabaseManager";
|
|
3
|
+
import FileManager from "./manager/FileManager";
|
|
4
|
+
import SecurityManager from "./manager/SecurityManager";
|
|
5
|
+
import SessionManager from "./manager/SessionManager";
|
|
6
|
+
import UserManager from "./manager/UserManager";
|
|
7
|
+
import { DFWConfig } from "./types/DFWConfig";
|
|
8
|
+
import { PrismaClient } from "@prisma/client";
|
|
9
|
+
declare class DFWInstance {
|
|
10
|
+
readonly config: DFWConfig;
|
|
11
|
+
readonly database: PrismaClient;
|
|
12
|
+
DatabaseManager: DatabaseManager;
|
|
13
|
+
APIManager: APIManager;
|
|
14
|
+
SessionManager: SessionManager;
|
|
15
|
+
SecurityManager: SecurityManager;
|
|
16
|
+
UserManager: UserManager;
|
|
17
|
+
FileManager: FileManager;
|
|
18
|
+
constructor(config: DFWConfig);
|
|
19
|
+
}
|
|
20
|
+
export default DFWInstance;
|
|
21
21
|
//# sourceMappingURL=DFWInstance.d.ts.map
|
package/lib/DFWInstance.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const APIManager_1 = __importDefault(require("./manager/APIManager"));
|
|
30
|
-
const DatabaseManager_1 = __importDefault(require("./manager/DatabaseManager"));
|
|
31
|
-
const FileManager_1 = __importDefault(require("./manager/FileManager"));
|
|
32
|
-
const SecurityManager_1 = __importDefault(require("./manager/SecurityManager"));
|
|
33
|
-
const SessionManager_1 = __importDefault(require("./manager/SessionManager"));
|
|
34
|
-
const UserManager_1 = __importDefault(require("./manager/UserManager"));
|
|
35
|
-
const fs = __importStar(require("fs"));
|
|
36
|
-
const client_1 = require("@prisma/client");
|
|
37
|
-
class DFWInstance {
|
|
38
|
-
constructor(config) {
|
|
39
|
-
this.config = config;
|
|
40
|
-
this.database = new client_1.PrismaClient({
|
|
41
|
-
log: config.database ? config.database.log ? ['query', 'info', 'warn', 'error'] : undefined : undefined,
|
|
42
|
-
});
|
|
43
|
-
if (fs.existsSync(".dfw") == false) {
|
|
44
|
-
fs.mkdirSync(".dfw");
|
|
45
|
-
}
|
|
46
|
-
this.DatabaseManager = new DatabaseManager_1.default(this);
|
|
47
|
-
this.APIManager = new APIManager_1.default(this);
|
|
48
|
-
this.SessionManager = new SessionManager_1.default(this);
|
|
49
|
-
this.SecurityManager = new SecurityManager_1.default(this);
|
|
50
|
-
this.UserManager = new UserManager_1.default(this);
|
|
51
|
-
this.FileManager = new FileManager_1.default(this);
|
|
52
|
-
Object.freeze(this.config); // Make it readonly
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.default = DFWInstance;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const APIManager_1 = __importDefault(require("./manager/APIManager"));
|
|
30
|
+
const DatabaseManager_1 = __importDefault(require("./manager/DatabaseManager"));
|
|
31
|
+
const FileManager_1 = __importDefault(require("./manager/FileManager"));
|
|
32
|
+
const SecurityManager_1 = __importDefault(require("./manager/SecurityManager"));
|
|
33
|
+
const SessionManager_1 = __importDefault(require("./manager/SessionManager"));
|
|
34
|
+
const UserManager_1 = __importDefault(require("./manager/UserManager"));
|
|
35
|
+
const fs = __importStar(require("fs"));
|
|
36
|
+
const client_1 = require("@prisma/client");
|
|
37
|
+
class DFWInstance {
|
|
38
|
+
constructor(config) {
|
|
39
|
+
this.config = config;
|
|
40
|
+
this.database = new client_1.PrismaClient({
|
|
41
|
+
log: config.database ? config.database.log ? ['query', 'info', 'warn', 'error'] : undefined : undefined,
|
|
42
|
+
});
|
|
43
|
+
if (fs.existsSync(".dfw") == false) {
|
|
44
|
+
fs.mkdirSync(".dfw");
|
|
45
|
+
}
|
|
46
|
+
this.DatabaseManager = new DatabaseManager_1.default(this);
|
|
47
|
+
this.APIManager = new APIManager_1.default(this);
|
|
48
|
+
this.SessionManager = new SessionManager_1.default(this);
|
|
49
|
+
this.SecurityManager = new SecurityManager_1.default(this);
|
|
50
|
+
this.UserManager = new UserManager_1.default(this);
|
|
51
|
+
this.FileManager = new FileManager_1.default(this);
|
|
52
|
+
Object.freeze(this.config); // Make it readonly
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.default = DFWInstance;
|
|
56
56
|
//# sourceMappingURL=DFWInstance.js.map
|
package/lib/DFWUtils.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
export default class DFWUtils {
|
|
2
|
-
static readonly EMAIL_REGEX: RegExp;
|
|
3
|
-
static isEmail(email: string): boolean;
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @param duration ms of sleeping
|
|
7
|
-
*/
|
|
8
|
-
static sleepAsync(duration: number): Promise<void>;
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @param path
|
|
12
|
-
*/
|
|
13
|
-
static getFileMimetype(path: string): string | null;
|
|
14
|
-
/**
|
|
15
|
-
* retrive file extension
|
|
16
|
-
* @param filePath
|
|
17
|
-
*/
|
|
18
|
-
static getFilenameExtension(filePath: string): string;
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
static generateRandomHexString(len: number): string;
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
static uuid(): string;
|
|
27
|
-
}
|
|
1
|
+
export default class DFWUtils {
|
|
2
|
+
static readonly EMAIL_REGEX: RegExp;
|
|
3
|
+
static isEmail(email: string): boolean;
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param duration ms of sleeping
|
|
7
|
+
*/
|
|
8
|
+
static sleepAsync(duration: number): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param path
|
|
12
|
+
*/
|
|
13
|
+
static getFileMimetype(path: string): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* retrive file extension
|
|
16
|
+
* @param filePath
|
|
17
|
+
*/
|
|
18
|
+
static getFilenameExtension(filePath: string): string;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
static generateRandomHexString(len: number): string;
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
static uuid(): string;
|
|
27
|
+
}
|
|
28
28
|
//# sourceMappingURL=DFWUtils.d.ts.map
|
package/lib/DFWUtils.js
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
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
|
-
const mime_types_1 = require("mime-types");
|
|
13
|
-
const uuid = require("uuid");
|
|
14
|
-
class DFWUtils {
|
|
15
|
-
static isEmail(email) {
|
|
16
|
-
return this.EMAIL_REGEX.test(String(email).toLowerCase());
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param duration ms of sleeping
|
|
21
|
-
*/
|
|
22
|
-
static sleepAsync(duration) {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
yield new Promise(function (resolve) {
|
|
25
|
-
setTimeout(() => { resolve(0); }, duration);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
* @param path
|
|
32
|
-
*/
|
|
33
|
-
static getFileMimetype(path) {
|
|
34
|
-
let mimetype = (0, mime_types_1.lookup)(path);
|
|
35
|
-
return mimetype ? mimetype : null;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* retrive file extension
|
|
39
|
-
* @param filePath
|
|
40
|
-
*/
|
|
41
|
-
static getFilenameExtension(filePath) {
|
|
42
|
-
return filePath.slice((filePath.lastIndexOf(".") - 1 >>> 0) + 2);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
*
|
|
46
|
-
*/
|
|
47
|
-
static generateRandomHexString(len) {
|
|
48
|
-
let maxlen = 8, min = Math.pow(16, Math.min(len, maxlen) - 1), max = Math.pow(16, Math.min(len, maxlen)) - 1, n = Math.floor(Math.random() * (max - min + 1)) + min, r = n.toString(16);
|
|
49
|
-
while (r.length < len) {
|
|
50
|
-
r = r + DFWUtils.generateRandomHexString(len - maxlen);
|
|
51
|
-
}
|
|
52
|
-
return r;
|
|
53
|
-
}
|
|
54
|
-
;
|
|
55
|
-
/**
|
|
56
|
-
*
|
|
57
|
-
*/
|
|
58
|
-
static uuid() {
|
|
59
|
-
return uuid.v4();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
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
|
+
const mime_types_1 = require("mime-types");
|
|
13
|
+
const uuid = require("uuid");
|
|
14
|
+
class DFWUtils {
|
|
15
|
+
static isEmail(email) {
|
|
16
|
+
return this.EMAIL_REGEX.test(String(email).toLowerCase());
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param duration ms of sleeping
|
|
21
|
+
*/
|
|
22
|
+
static sleepAsync(duration) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
yield new Promise(function (resolve) {
|
|
25
|
+
setTimeout(() => { resolve(0); }, duration);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param path
|
|
32
|
+
*/
|
|
33
|
+
static getFileMimetype(path) {
|
|
34
|
+
let mimetype = (0, mime_types_1.lookup)(path);
|
|
35
|
+
return mimetype ? mimetype : null;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* retrive file extension
|
|
39
|
+
* @param filePath
|
|
40
|
+
*/
|
|
41
|
+
static getFilenameExtension(filePath) {
|
|
42
|
+
return filePath.slice((filePath.lastIndexOf(".") - 1 >>> 0) + 2);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
static generateRandomHexString(len) {
|
|
48
|
+
let maxlen = 8, min = Math.pow(16, Math.min(len, maxlen) - 1), max = Math.pow(16, Math.min(len, maxlen)) - 1, n = Math.floor(Math.random() * (max - min + 1)) + min, r = n.toString(16);
|
|
49
|
+
while (r.length < len) {
|
|
50
|
+
r = r + DFWUtils.generateRandomHexString(len - maxlen);
|
|
51
|
+
}
|
|
52
|
+
return r;
|
|
53
|
+
}
|
|
54
|
+
;
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
static uuid() {
|
|
59
|
+
return uuid.v4();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
DFWUtils.EMAIL_REGEX = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
63
|
+
exports.default = DFWUtils;
|
|
64
64
|
//# sourceMappingURL=DFWUtils.js.map
|
package/lib/DFWUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DFWUtils.js","sourceRoot":"","sources":["../src/DFWUtils.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2CAAoC;AAGpC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAE7B,MAAqB,QAAQ;IAIlB,MAAM,CAAC,OAAO,CAAC,KAAY;QAC9B,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACI,MAAM,CAAO,UAAU,CAAC,QAAe;;YAC1C,MAAM,IAAI,OAAO,CAAC,UAAS,OAAO;gBAChC,UAAU,CAAC,GAAE,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;YAC5C,CAAC,CAAC,CAAA;QACN,CAAC;KAAA;IAED;;;OAGG;IACI,MAAM,CAAC,eAAe,CAAC,IAAW;QACrC,IAAI,QAAQ,GAAG,IAAA,mBAAM,EAAC,IAAI,CAAC,CAAC;QAC5B,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;IACtC,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,oBAAoB,CAAC,QAAe;QAC9C,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,QAAQ,CA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,CAAC,uBAAuB,CAAE,GAAG,GAAG,MAAM,CAAE,CAAC;SAC3D;QACD,OAAO,CAAC,CAAC;IACb,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,MAAM,CAAC,IAAI;QACd,OAAO,IAAI,CAAC,EAAE,EAAE,CAAC;IACrB,CAAC;;AArDsB,oBAAW,GAAG,yJAAyJ,CAAC;kBAF9K,QAAQ"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import DFWInstance from "./DFWInstance";
|
|
2
|
-
import { DFWConfig } from "./types/DFWConfig";
|
|
3
|
-
export declare class DFWCore {
|
|
4
|
-
static DFW: DFWInstance;
|
|
5
|
-
private static instances;
|
|
6
|
-
private static listeners;
|
|
7
|
-
static createInstance(config?: DFWConfig, name?: string): DFWInstance;
|
|
8
|
-
static get(name?: string): DFWInstance | undefined;
|
|
9
|
-
}
|
|
10
|
-
export default DFWCore;
|
|
1
|
+
import DFWInstance from "./DFWInstance";
|
|
2
|
+
import { DFWConfig } from "./types/DFWConfig";
|
|
3
|
+
export declare class DFWCore {
|
|
4
|
+
static DFW: DFWInstance;
|
|
5
|
+
private static instances;
|
|
6
|
+
private static listeners;
|
|
7
|
+
static createInstance(config?: DFWConfig, name?: string): DFWInstance;
|
|
8
|
+
static get(name?: string): DFWInstance | undefined;
|
|
9
|
+
}
|
|
10
|
+
export default DFWCore;
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
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
|
-
exports.DFWCore = void 0;
|
|
7
|
-
const DFWInstance_1 = __importDefault(require("./DFWInstance"));
|
|
8
|
-
class DFWCore {
|
|
9
|
-
static createInstance(config = {}, name = "main") {
|
|
10
|
-
let DFW = new DFWInstance_1.default(config);
|
|
11
|
-
if (name == "main")
|
|
12
|
-
this.DFW = DFW;
|
|
13
|
-
if (this.instances[name])
|
|
14
|
-
throw new Error(`[DFW_ERROR] DFW Instance '${name}' already exist`);
|
|
15
|
-
this.instances[name] = DFW;
|
|
16
|
-
return DFW;
|
|
17
|
-
}
|
|
18
|
-
static get(name = "main") {
|
|
19
|
-
return this.instances[name];
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.DFWCore = DFWCore;
|
|
23
|
-
DFWCore.instances = {};
|
|
24
|
-
DFWCore.listeners = {}; //TODO Implement some listeners
|
|
25
|
-
exports.default = DFWCore;
|
|
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
|
+
exports.DFWCore = void 0;
|
|
7
|
+
const DFWInstance_1 = __importDefault(require("./DFWInstance"));
|
|
8
|
+
class DFWCore {
|
|
9
|
+
static createInstance(config = {}, name = "main") {
|
|
10
|
+
let DFW = new DFWInstance_1.default(config);
|
|
11
|
+
if (name == "main")
|
|
12
|
+
this.DFW = DFW;
|
|
13
|
+
if (this.instances[name])
|
|
14
|
+
throw new Error(`[DFW_ERROR] DFW Instance '${name}' already exist`);
|
|
15
|
+
this.instances[name] = DFW;
|
|
16
|
+
return DFW;
|
|
17
|
+
}
|
|
18
|
+
static get(name = "main") {
|
|
19
|
+
return this.instances[name];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.DFWCore = DFWCore;
|
|
23
|
+
DFWCore.instances = {};
|
|
24
|
+
DFWCore.listeners = {}; //TODO Implement some listeners
|
|
25
|
+
exports.default = DFWCore;
|
|
26
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { Response, Express, Router } from "express";
|
|
2
|
-
import { DFWRequest, DFWRequestScheme } from "../types/DFWRequestScheme";
|
|
3
|
-
import DFWModule from "./DFWModule";
|
|
4
|
-
import { APIListenerConfig } from "../types/APIListenerConfig";
|
|
5
|
-
import DFWBoot from "../types/DFWBoot";
|
|
6
|
-
import DFWInstance from "../DFWInstance";
|
|
7
|
-
export type APIFunction = (req: DFWRequest, res: Response, dfw: DFWRequestScheme) => (Promise<any> | any);
|
|
8
|
-
export type APIMethods = "get" | "put" | "post" | "delete" | "options" | "link";
|
|
9
|
-
export declare class APIListener {
|
|
10
|
-
readonly config: APIListenerConfig;
|
|
11
|
-
readonly listener: APIFunction;
|
|
12
|
-
constructor(config: APIListenerConfig | APIFunction, listener?: APIFunction);
|
|
13
|
-
}
|
|
14
|
-
export type BootCallback = (req: DFWRequest, boot: DFWBoot) => Promise<any>;
|
|
15
|
-
export default class APIManager extends DFWModule {
|
|
16
|
-
server: Express;
|
|
17
|
-
DFW_BASIC_ROUTER: Router;
|
|
18
|
-
private bootCallbacks;
|
|
19
|
-
constructor(DFW: DFWInstance);
|
|
20
|
-
middleware(req: DFWRequest, res: Response): Promise<void>;
|
|
21
|
-
startServer(port?: number): void;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param path
|
|
25
|
-
* @param apiFunction
|
|
26
|
-
* @param config
|
|
27
|
-
*/
|
|
28
|
-
addListener(path: string, apiFunction: APIFunction, config?: APIListenerConfig): void;
|
|
29
|
-
makeAPIListenerMiddlewares(config?: APIListenerConfig): any[];
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
* @param dfw
|
|
33
|
-
*/
|
|
34
|
-
getBootAsync(req: DFWRequest): Promise<DFWBoot>;
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @param callback
|
|
38
|
-
*/
|
|
39
|
-
addBootCallback(callback: BootCallback): void;
|
|
40
|
-
/**
|
|
41
|
-
* Función recursiva que registra en DFW los listeners basados en una estructura de objeto
|
|
42
|
-
* @param listener
|
|
43
|
-
* @param path
|
|
44
|
-
*/
|
|
45
|
-
addListenerObject(listener: (APIListener | Object) | (APIListener | Object)[], path: string): void;
|
|
46
|
-
}
|
|
47
|
-
export declare const MiddlewareAsyncWrapper: (fn: (...args: any[]) => Promise<void>) => (...args: any[]) => Promise<void>;
|
|
1
|
+
import { Response, Express, Router } from "express";
|
|
2
|
+
import { DFWRequest, DFWRequestScheme } from "../types/DFWRequestScheme";
|
|
3
|
+
import DFWModule from "./DFWModule";
|
|
4
|
+
import { APIListenerConfig } from "../types/APIListenerConfig";
|
|
5
|
+
import DFWBoot from "../types/DFWBoot";
|
|
6
|
+
import DFWInstance from "../DFWInstance";
|
|
7
|
+
export type APIFunction = (req: DFWRequest, res: Response, dfw: DFWRequestScheme) => (Promise<any> | any);
|
|
8
|
+
export type APIMethods = "get" | "put" | "post" | "delete" | "options" | "link";
|
|
9
|
+
export declare class APIListener {
|
|
10
|
+
readonly config: APIListenerConfig;
|
|
11
|
+
readonly listener: APIFunction;
|
|
12
|
+
constructor(config: APIListenerConfig | APIFunction, listener?: APIFunction);
|
|
13
|
+
}
|
|
14
|
+
export type BootCallback = (req: DFWRequest, boot: DFWBoot) => Promise<any>;
|
|
15
|
+
export default class APIManager extends DFWModule {
|
|
16
|
+
server: Express;
|
|
17
|
+
DFW_BASIC_ROUTER: Router;
|
|
18
|
+
private bootCallbacks;
|
|
19
|
+
constructor(DFW: DFWInstance);
|
|
20
|
+
middleware(req: DFWRequest, res: Response): Promise<void>;
|
|
21
|
+
startServer(port?: number): void;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param path
|
|
25
|
+
* @param apiFunction
|
|
26
|
+
* @param config
|
|
27
|
+
*/
|
|
28
|
+
addListener(path: string, apiFunction: APIFunction, config?: APIListenerConfig): void;
|
|
29
|
+
makeAPIListenerMiddlewares(config?: APIListenerConfig): any[];
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param dfw
|
|
33
|
+
*/
|
|
34
|
+
getBootAsync(req: DFWRequest): Promise<DFWBoot>;
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param callback
|
|
38
|
+
*/
|
|
39
|
+
addBootCallback(callback: BootCallback): void;
|
|
40
|
+
/**
|
|
41
|
+
* Función recursiva que registra en DFW los listeners basados en una estructura de objeto
|
|
42
|
+
* @param listener
|
|
43
|
+
* @param path
|
|
44
|
+
*/
|
|
45
|
+
addListenerObject(listener: (APIListener | Object) | (APIListener | Object)[], path: string): void;
|
|
46
|
+
}
|
|
47
|
+
export declare const MiddlewareAsyncWrapper: (fn: (...args: any[]) => Promise<void>) => (...args: any[]) => Promise<void>;
|
|
48
48
|
//# sourceMappingURL=APIManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"APIManager.d.ts","sourceRoot":"","sources":["../../src/manager/APIManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGlE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACvC,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAKzC,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,gBAAgB,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAA;AACzG,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;AAEhF,qBAAa,WAAW;IACpB,SAAgB,MAAM,EAAE,iBAAiB,CAAC;IAC1C,SAAgB,QAAQ,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