web_api_base 1.0.0 → 1.0.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/dist/App.js +32 -0
- package/dist/App.js.map +1 -0
- package/dist/Application.d.ts +10 -0
- package/dist/Application.js +33 -0
- package/dist/Application.js.map +1 -0
- package/dist/ApplicationConfiguration.d.ts +10 -0
- package/dist/ApplicationConfiguration.js +69 -0
- package/dist/ApplicationConfiguration.js.map +1 -0
- package/dist/Configuration.js +69 -0
- package/dist/Configuration.js.map +1 -0
- package/dist/Index.js +2 -0
- package/dist/Index.js.map +1 -0
- package/dist/__tests__/classes/Controller.d.ts +8 -0
- package/dist/__tests__/classes/Controller.js +54 -0
- package/dist/__tests__/classes/Controller.js.map +1 -0
- package/dist/__tests__/decorators/controllers/ControllerDecorators.spec.d.ts +1 -0
- package/dist/__tests__/decorators/controllers/ControllerDecorators.spec.js +40 -0
- package/dist/__tests__/decorators/controllers/ControllerDecorators.spec.js.map +1 -0
- package/dist/config.json +1 -0
- package/dist/controllers/FileController.js +162 -0
- package/dist/controllers/FileController.js.map +1 -0
- package/dist/controllers/StatusController.js +44 -0
- package/dist/controllers/StatusController.js.map +1 -0
- package/dist/controllers/base/ControllerBase.d.ts +16 -0
- package/dist/controllers/base/ControllerBase.js +79 -0
- package/dist/controllers/base/ControllerBase.js.map +1 -0
- package/dist/decorators/controllers/ControllerDecorators.d.ts +36 -0
- package/dist/decorators/controllers/ControllerDecorators.js +104 -0
- package/dist/decorators/controllers/ControllerDecorators.js.map +1 -0
- package/dist/dependencyInjection/DependecyService.d.ts +9 -0
- package/dist/dependencyInjection/DependecyService.js +23 -0
- package/dist/dependencyInjection/DependecyService.js.map +1 -0
- package/dist/enums/httpVerbs/HttpVerbs.d.ts +6 -0
- package/dist/enums/httpVerbs/HttpVerbs.js +11 -0
- package/dist/enums/httpVerbs/HttpVerbs.js.map +1 -0
- package/dist/index.d.ts +0 -0
- package/dist/interfaces/IApplication.d.ts +7 -0
- package/dist/interfaces/IApplication.js +3 -0
- package/dist/interfaces/IApplication.js.map +1 -0
- package/dist/interfaces/IApplicationConfiguration.d.ts +5 -0
- package/dist/interfaces/IApplicationConfiguration.js +3 -0
- package/dist/interfaces/IApplicationConfiguration.js.map +1 -0
- package/dist/interfaces/IController.d.ts +5 -0
- package/dist/interfaces/IController.js +3 -0
- package/dist/interfaces/IController.js.map +1 -0
- package/dist/interfaces/entities/IDirectory.d.ts +5 -0
- package/dist/interfaces/entities/IDirectory.js +3 -0
- package/dist/interfaces/entities/IDirectory.js.map +1 -0
- package/dist/jest.config.d.ts +0 -0
- package/dist/jest.config.js +8 -0
- package/dist/jest.config.js.map +1 -0
- package/dist/midlewares/IMidleware.d.ts +4 -0
- package/dist/midlewares/IMidleware.js +3 -0
- package/dist/midlewares/IMidleware.js.map +1 -0
- package/dist/services/FileService.js +45 -0
- package/dist/services/FileService.js.map +1 -0
- package/dist/services/IFileService.js +8 -0
- package/dist/services/IFileService.js.map +1 -0
- package/dist/services/fileService/FileService.d.ts +10 -0
- package/dist/services/fileService/FileService.js +96 -0
- package/dist/services/fileService/FileService.js.map +1 -0
- package/dist/services/fileService/FileServiceBase.d.ts +10 -0
- package/dist/services/fileService/FileServiceBase.js +7 -0
- package/dist/services/fileService/FileServiceBase.js.map +1 -0
- package/package.json +7 -3
- package/.vscode/launch.json +0 -21
- package/Application.ts +0 -39
- package/ApplicationConfiguration.ts +0 -82
- package/__tests__/classes/Controller.ts +0 -38
- package/__tests__/decorators/controllers/ControllerDecorators.spec.ts +0 -67
- package/controllers/base/ControllerBase.ts +0 -116
- package/decorators/controllers/ControllerDecorators.ts +0 -187
- package/dependencyInjection/DependecyService.ts +0 -36
- package/enums/httpVerbs/HttpVerbs.ts +0 -7
- package/interfaces/IApplication.ts +0 -13
- package/interfaces/IApplicationConfiguration.ts +0 -6
- package/interfaces/IController.ts +0 -8
- package/interfaces/entities/IDirectory.ts +0 -6
- package/jest.config.ts +0 -6
- package/midlewares/IMidleware.ts +0 -6
- package/services/fileService/FileService.ts +0 -125
- package/services/fileService/FileServiceBase.ts +0 -16
- package/tsconfig.json +0 -103
package/dist/App.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
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 Configuration_1 = __importDefault(require("./Configuration"));
|
|
16
|
+
const express_1 = __importDefault(require("express"));
|
|
17
|
+
class App {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.Configuration = new Configuration_1.default();
|
|
20
|
+
this.Express = (0, express_1.default)();
|
|
21
|
+
}
|
|
22
|
+
StartAsync() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
yield this.Configuration.StartAsync();
|
|
25
|
+
this.Express.listen(this.Configuration.Port, this.Configuration.Host, () => {
|
|
26
|
+
console.log(`App running on ${this.Configuration.Host}:${this.Configuration.Port}`);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.default = App;
|
|
32
|
+
//# sourceMappingURL=App.js.map
|
package/dist/App.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.js","sourceRoot":"","sources":["../App.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oEAA2C;AAE3C,sDAAsC;AAGtC,MAAqB,GAAG;IAQpB;QAEI,IAAI,CAAC,aAAa,GAAG,IAAI,uBAAa,EAAE,CAAC;QAEzC,IAAI,CAAC,OAAO,GAAG,IAAA,iBAAe,GAAE,CAAC;IACrC,CAAC;IAEY,UAAU;;YAEnB,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;YAEtC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,GAAE,EAAE;gBAEtE,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;YACxF,CAAC,CAAC,CAAA;QACN,CAAC;KAAA;CAEJ;AAzBD,sBAyBC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Express } from "express";
|
|
2
|
+
import IApplication from "./interfaces/IApplication";
|
|
3
|
+
import IApplicationConfiguration from "./interfaces/IApplicationConfiguration";
|
|
4
|
+
export default abstract class Application implements IApplication {
|
|
5
|
+
private ApplicationConfiguration;
|
|
6
|
+
Express: Express;
|
|
7
|
+
constructor();
|
|
8
|
+
StartAsync(): Promise<void>;
|
|
9
|
+
abstract Configure(appConfig: IApplicationConfiguration): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 express_1 = __importDefault(require("express"));
|
|
16
|
+
const ApplicationConfiguration_1 = __importDefault(require("./ApplicationConfiguration"));
|
|
17
|
+
class Application {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.ApplicationConfiguration = new ApplicationConfiguration_1.default();
|
|
20
|
+
this.Express = (0, express_1.default)();
|
|
21
|
+
}
|
|
22
|
+
StartAsync() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
yield this.ApplicationConfiguration.StartAsync();
|
|
25
|
+
this.Configure(this.ApplicationConfiguration);
|
|
26
|
+
this.Express.listen(this.ApplicationConfiguration.Port, this.ApplicationConfiguration.Host, () => {
|
|
27
|
+
console.log(`App running on ${this.ApplicationConfiguration.Host}:${this.ApplicationConfiguration.Port}`);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.default = Application;
|
|
33
|
+
//# sourceMappingURL=Application.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Application.js","sourceRoot":"","sources":["../Application.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,sDAAoC;AACpC,0FAAiE;AAIjE,MAA8B,WAAW;IAQrC;QAEI,IAAI,CAAC,wBAAwB,GAAG,IAAI,kCAAwB,EAAE,CAAC;QAE/D,IAAI,CAAC,OAAO,GAAG,IAAA,iBAAa,GAAE,CAAC;IAEnC,CAAC;IAGY,UAAU;;YAEnB,MAAM,IAAI,CAAC,wBAAwB,CAAC,UAAU,EAAE,CAAC;YAEjD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;YAE9C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,IAAI,EAAE,IAAI,CAAC,wBAAwB,CAAC,IAAI,EAAE,GAAE,EAAE;gBAE5F,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,CAAC,wBAAwB,CAAC,IAAI,IAAI,IAAI,CAAC,wBAAwB,CAAC,IAAI,EAAE,CAAC,CAAC;YAC9G,CAAC,CAAC,CAAA;QACN,CAAC;KAAA;CAKJ;AAhCD,8BAgCC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import IApplicationConfiguration from './interfaces/IApplicationConfiguration';
|
|
2
|
+
export default class Configuration implements IApplicationConfiguration {
|
|
3
|
+
Host: string;
|
|
4
|
+
Port: number;
|
|
5
|
+
constructor();
|
|
6
|
+
StartAsync(): Promise<void>;
|
|
7
|
+
private CheckFileAsync;
|
|
8
|
+
private ReadFileAsync;
|
|
9
|
+
private CreateFileAsync;
|
|
10
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
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 fs_1 = __importDefault(require("fs"));
|
|
16
|
+
class Configuration {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.Host = "0.0.0.0";
|
|
19
|
+
this.Port = 5555;
|
|
20
|
+
process.env["root_dir"] = __dirname;
|
|
21
|
+
}
|
|
22
|
+
StartAsync() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
if (!(yield this.CheckFileAsync())) {
|
|
25
|
+
yield this.CreateFileAsync();
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
yield this.ReadFileAsync();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
CheckFileAsync() {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
return new Promise((resolve, _) => resolve(fs_1.default.existsSync(`${__dirname}\\config.json`)));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
ReadFileAsync() {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
return new Promise((resolve, _) => {
|
|
40
|
+
fs_1.default.readFile(`${__dirname}\\config.json`, 'utf-8', (error, data) => {
|
|
41
|
+
if (error) {
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
let json = JSON.parse(data);
|
|
45
|
+
for (let key in this) {
|
|
46
|
+
if (json[key] != undefined) {
|
|
47
|
+
this[key] = json[key];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
resolve(true);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
CreateFileAsync() {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
return new Promise((resolve, _) => {
|
|
58
|
+
fs_1.default.writeFile(`${__dirname}\\config.json`, JSON.stringify(this), 'utf-8', error => {
|
|
59
|
+
if (error) {
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
resolve(true);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.default = Configuration;
|
|
69
|
+
//# sourceMappingURL=ApplicationConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApplicationConfiguration.js","sourceRoot":"","sources":["../ApplicationConfiguration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,4CAAsB;AAKtB,MAAqB,aAAa;IAM9B;QAHO,SAAI,GAAY,SAAS,CAAC;QAC1B,SAAI,GAAY,IAAI,CAAC;QAIxB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;IACxC,CAAC;IAEY,UAAU;;YAEnB,IAAG,CAAC,CAAA,MAAM,IAAI,CAAC,cAAc,EAAE,CAAA,EAC/B;gBACI,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;aAEhC;iBAAI;gBAED,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;aAC9B;QACL,CAAC;KAAA;IAEa,cAAc;;YAExB,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,YAAI,CAAC,UAAU,CAAC,GAAG,SAAS,eAAe,CAAC,CAAC,CAAC,CAAC;QACvG,CAAC;KAAA;IAEa,aAAa;;YAEvB,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;gBAEvC,YAAI,CAAC,QAAQ,CAAC,GAAG,SAAS,eAAe,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;oBAEhE,IAAG,KAAK,EACR;wBACI,MAAM,KAAK,CAAC;qBACf;oBAED,IAAI,IAAI,GAAS,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBAElC,KAAI,IAAI,GAAG,IAAI,IAAI,EACnB;wBACI,IAAG,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,EACzB;4BACI,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;yBACzB;qBACJ;oBAED,OAAO,CAAC,IAAI,CAAC,CAAC;gBAElB,CAAC,CAAC,CAAA;YACN,CAAC,CAAC,CAAA;QACN,CAAC;KAAA;IAEa,eAAe;;YAGzB,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,CAAC,EAAC,EAAE;gBAEtC,YAAI,CAAC,SAAS,CAAC,GAAG,SAAS,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE;oBAG/E,IAAG,KAAK,EACR;wBACI,MAAM,KAAK,CAAC;qBACf;oBAED,OAAO,CAAC,IAAI,CAAC,CAAC;gBAElB,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAA;QAEN,CAAC;KAAA;CAEJ;AA3ED,gCA2EC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
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 fs_1 = __importDefault(require("fs"));
|
|
16
|
+
class Configuration {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.Host = "0.0.0.0";
|
|
19
|
+
this.Port = 5432;
|
|
20
|
+
process.env["root_dir"] = __dirname;
|
|
21
|
+
}
|
|
22
|
+
StartAsync() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
if (!(yield this.CheckFileAsync())) {
|
|
25
|
+
yield this.CreateFileAsync();
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
yield this.ReadFileAsync();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
CheckFileAsync() {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
return new Promise((resolve, _) => resolve(fs_1.default.existsSync(`${__dirname}\\config.json`)));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
ReadFileAsync() {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
return new Promise((resolve, _) => {
|
|
40
|
+
fs_1.default.readFile(`${__dirname}\\config.json`, 'utf-8', (error, data) => {
|
|
41
|
+
if (error) {
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
let json = JSON.parse(data);
|
|
45
|
+
for (let key in this) {
|
|
46
|
+
if (json[key] != undefined) {
|
|
47
|
+
this[key] = json[key];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
resolve(true);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
CreateFileAsync() {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
return new Promise((resolve, _) => {
|
|
58
|
+
fs_1.default.writeFile(`${__dirname}\\config.json`, JSON.stringify(this), 'utf-8', error => {
|
|
59
|
+
if (error) {
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
resolve(true);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.default = Configuration;
|
|
69
|
+
//# sourceMappingURL=Configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../Configuration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,4CAAsB;AAItB,MAAqB,aAAa;IAM9B;QAHO,SAAI,GAAY,SAAS,CAAC;QAC1B,SAAI,GAAY,IAAI,CAAC;QAIxB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;IACxC,CAAC;IAEY,UAAU;;YAEnB,IAAG,CAAC,CAAA,MAAM,IAAI,CAAC,cAAc,EAAE,CAAA,EAC/B;gBACI,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;aAEhC;iBAAI;gBAED,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;aAC9B;QACL,CAAC;KAAA;IAEa,cAAc;;YAExB,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,YAAI,CAAC,UAAU,CAAC,GAAG,SAAS,eAAe,CAAC,CAAC,CAAC,CAAC;QACvG,CAAC;KAAA;IAEa,aAAa;;YAEvB,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;gBAEvC,YAAI,CAAC,QAAQ,CAAC,GAAG,SAAS,eAAe,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;oBAEhE,IAAG,KAAK,EACR;wBACI,MAAM,KAAK,CAAC;qBACf;oBAED,IAAI,IAAI,GAAS,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBAElC,KAAI,IAAI,GAAG,IAAI,IAAI,EACnB;wBACI,IAAG,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,EACzB;4BACI,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;yBACzB;qBACJ;oBAED,OAAO,CAAC,IAAI,CAAC,CAAC;gBAElB,CAAC,CAAC,CAAA;YACN,CAAC,CAAC,CAAA;QACN,CAAC;KAAA;IAEa,eAAe;;YAGzB,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,CAAC,EAAC,EAAE;gBAEtC,YAAI,CAAC,SAAS,CAAC,GAAG,SAAS,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE;oBAG/E,IAAG,KAAK,EACR;wBACI,MAAM,KAAK,CAAC;qBACf;oBAED,OAAO,CAAC,IAAI,CAAC,CAAC;gBAElB,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAA;QAEN,CAAC;KAAA;CAEJ;AA3ED,gCA2EC"}
|
package/dist/Index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ControllerBase } from "../../controllers/base/ControllerBase";
|
|
2
|
+
import IApplication from "../../interfaces/IApplication";
|
|
3
|
+
export declare class ControllerTest extends ControllerBase {
|
|
4
|
+
constructor();
|
|
5
|
+
TestAction(name: string): void;
|
|
6
|
+
TestActionTwo(name: string, age: number): void;
|
|
7
|
+
AppendSync(application: IApplication): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* istanbul ignore next */
|
|
3
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
+
};
|
|
9
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
11
|
+
};
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.ControllerTest = void 0;
|
|
17
|
+
const ControllerBase_1 = require("../../controllers/base/ControllerBase");
|
|
18
|
+
const ControllerDecorators_1 = __importDefault(require("../../decorators/controllers/ControllerDecorators"));
|
|
19
|
+
const HttpVerbs_1 = require("../../enums/httpVerbs/HttpVerbs");
|
|
20
|
+
let ControllerTest = class ControllerTest extends ControllerBase_1.ControllerBase {
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
}
|
|
24
|
+
TestAction(name) {
|
|
25
|
+
console.log(name);
|
|
26
|
+
}
|
|
27
|
+
TestActionTwo(name, age) {
|
|
28
|
+
console.log(name, age);
|
|
29
|
+
}
|
|
30
|
+
AppendSync(application) {
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
__decorate([
|
|
34
|
+
ControllerDecorators_1.default.Action("Test"),
|
|
35
|
+
ControllerDecorators_1.default.Verb(HttpVerbs_1.HTTPVerbs.GET),
|
|
36
|
+
ControllerDecorators_1.default.Argument('name'),
|
|
37
|
+
__metadata("design:type", Function),
|
|
38
|
+
__metadata("design:paramtypes", [String]),
|
|
39
|
+
__metadata("design:returntype", void 0)
|
|
40
|
+
], ControllerTest.prototype, "TestAction", null);
|
|
41
|
+
__decorate([
|
|
42
|
+
ControllerDecorators_1.default.Action("Test"),
|
|
43
|
+
ControllerDecorators_1.default.Verb(HttpVerbs_1.HTTPVerbs.GET),
|
|
44
|
+
ControllerDecorators_1.default.Argument('name', 'age'),
|
|
45
|
+
__metadata("design:type", Function),
|
|
46
|
+
__metadata("design:paramtypes", [String, Number]),
|
|
47
|
+
__metadata("design:returntype", void 0)
|
|
48
|
+
], ControllerTest.prototype, "TestActionTwo", null);
|
|
49
|
+
ControllerTest = __decorate([
|
|
50
|
+
ControllerDecorators_1.default.Route("/test"),
|
|
51
|
+
__metadata("design:paramtypes", [])
|
|
52
|
+
], ControllerTest);
|
|
53
|
+
exports.ControllerTest = ControllerTest;
|
|
54
|
+
//# sourceMappingURL=Controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Controller.js","sourceRoot":"","sources":["../../../__tests__/classes/Controller.ts"],"names":[],"mappings":";AAAA,0BAA0B;;;;;;;;;;;;;;;AAE1B,0EAAuE;AACvE,6GAAsF;AACtF,+DAA4D;AAK5D,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,+BAAc;IAE9C;QAEI,KAAK,EAAE,CAAC;IACZ,CAAC;IAKM,UAAU,CAAC,IAAa;QAE3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAKM,aAAa,CAAC,IAAa,EAAE,GAAY;QAE5C,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC3B,CAAC;IAGM,UAAU,CAAC,WAAyB;IAG3C,CAAC;CACJ,CAAA;AAlBG;IAHC,8BAAqB,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,8BAAqB,CAAC,IAAI,CAAC,qBAAS,CAAC,GAAG,CAAC;IACzC,8BAAqB,CAAC,QAAQ,CAAS,MAAM,CAAC;;;;gDAI9C;AAKD;IAHC,8BAAqB,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,8BAAqB,CAAC,IAAI,CAAC,qBAAS,CAAC,GAAG,CAAC;IACzC,8BAAqB,CAAC,QAAQ,CAAiB,MAAM,EAAE,KAAK,CAAC;;;;mDAI7D;AArBQ,cAAc;IAD1B,8BAAqB,CAAC,KAAK,CAAC,OAAO,CAAC;;GACxB,cAAc,CA4B1B;AA5BY,wCAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
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 Controller_1 = require("../../classes/Controller");
|
|
7
|
+
const ControllerDecorators_1 = __importDefault(require("../../../decorators/controllers/ControllerDecorators"));
|
|
8
|
+
const HttpVerbs_1 = require("../../../enums/httpVerbs/HttpVerbs");
|
|
9
|
+
describe('testing controllers decorators', () => {
|
|
10
|
+
test("action name", () => {
|
|
11
|
+
var controller = new Controller_1.ControllerTest();
|
|
12
|
+
let action = ControllerDecorators_1.default.GetAction(controller, "TestAction");
|
|
13
|
+
expect(action).toBe("Test");
|
|
14
|
+
}, 10 ^ 5);
|
|
15
|
+
test("http verb", () => {
|
|
16
|
+
var controller = new Controller_1.ControllerTest();
|
|
17
|
+
let verb = ControllerDecorators_1.default.GetVerb(controller, "TestAction");
|
|
18
|
+
expect(verb).toBe(HttpVerbs_1.HTTPVerbs.GET);
|
|
19
|
+
}, 10 ^ 5);
|
|
20
|
+
test("action with one arg", () => {
|
|
21
|
+
var controller = new Controller_1.ControllerTest();
|
|
22
|
+
var handler = ControllerDecorators_1.default.GetArgumentsHandler(controller, 'TestAction');
|
|
23
|
+
var arr = handler === null || handler === void 0 ? void 0 : handler.CreateArgumentsList({ name: "adriano" });
|
|
24
|
+
Reflect.apply(controller.TestAction, controller, arr !== null && arr !== void 0 ? arr : []);
|
|
25
|
+
expect(arr).not.toBeNull();
|
|
26
|
+
}, 10 ^ 5);
|
|
27
|
+
test("action with two args", () => {
|
|
28
|
+
var controller = new Controller_1.ControllerTest();
|
|
29
|
+
var handler = ControllerDecorators_1.default.GetArgumentsHandler(controller, 'TestActionTwo');
|
|
30
|
+
var arr = handler === null || handler === void 0 ? void 0 : handler.CreateArgumentsList({ name: "adriano", age: 30 });
|
|
31
|
+
Reflect.apply(controller.TestActionTwo, controller, arr !== null && arr !== void 0 ? arr : []);
|
|
32
|
+
expect(arr).not.toBeNull();
|
|
33
|
+
}, 10 ^ 5);
|
|
34
|
+
test("controller route", () => {
|
|
35
|
+
var controller = new Controller_1.ControllerTest();
|
|
36
|
+
var route = ControllerDecorators_1.default.GetRoute(controller);
|
|
37
|
+
expect(route).toBe("/test");
|
|
38
|
+
}, 10 ^ 5);
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=ControllerDecorators.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ControllerDecorators.spec.js","sourceRoot":"","sources":["../../../../__tests__/decorators/controllers/ControllerDecorators.spec.ts"],"names":[],"mappings":";;;;;AAAA,yDAA0D;AAC1D,gHAAyF;AACzF,kEAA+D;AAE/D,QAAQ,CAAC,gCAAgC,EAAE,GAAE,EAAE;IAG3C,IAAI,CAAC,aAAa,EAAE,GAAE,EAAE;QAEpB,IAAI,UAAU,GAAG,IAAI,2BAAc,EAAE,CAAC;QACtC,IAAI,MAAM,GAAG,8BAAqB,CAAC,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QACvE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhC,CAAC,EAAC,EAAE,GAAC,CAAC,CAAC,CAAA;IAEP,IAAI,CAAC,WAAW,EAAE,GAAE,EAAE;QAElB,IAAI,UAAU,GAAG,IAAI,2BAAc,EAAE,CAAC;QACtC,IAAI,IAAI,GAAG,8BAAqB,CAAC,OAAO,CAAC,UAAU,EAAE,Y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C,CAAA;IAGP,IAAI,CAAC,kBAAkB,EAAE,GAAE,EAAE;QAEzB,IAAI,UAAU,GAAG,IAAI,2BAAc,EAAE,CAAC;QAEtC,IAAI,KAAK,GAAG,8BAAqB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAEvD,MAAM,CAAC,KAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAGjC,CAAC,EAAC,EAAE,GAAC,CAAC,CAAC,CAAA;AAEX,CAAC,CAAC,CAAA"}
|
package/dist/config.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"Host":"0.0.0.0","Port":5555}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.FileController = void 0;
|
|
25
|
+
const ControllerDecorators_1 = __importDefault(require("../decorators/controllers/ControllerDecorators"));
|
|
26
|
+
const ControllerBase_1 = require("./base/ControllerBase");
|
|
27
|
+
const HttpVerbs_1 = require("../enums/httpVerbs/HttpVerbs");
|
|
28
|
+
const FileServiceBase_1 = __importDefault(require("../services/fileService/FileServiceBase"));
|
|
29
|
+
const path_1 = __importDefault(require("path"));
|
|
30
|
+
const formidable_1 = __importDefault(require("formidable"));
|
|
31
|
+
let FileController = class FileController extends ControllerBase_1.ControllerBase {
|
|
32
|
+
constructor(_fileService) {
|
|
33
|
+
super();
|
|
34
|
+
this._fileService = _fileService;
|
|
35
|
+
}
|
|
36
|
+
GetDefaultDir() {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
try {
|
|
39
|
+
this.OK(yield this._fileService.GetDefaultDir());
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
this.Error({ error: err.message });
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
GetAllFiles(folder) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
try {
|
|
49
|
+
this.OK(yield this._fileService.GetAllFiles(folder));
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
this.Error({ error: err.message });
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
GetAllFolders(folder) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
try {
|
|
59
|
+
this.OK(yield this._fileService.GetAllForders(folder));
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
this.Error({ error: err.message });
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
DownloadFile(file) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
try {
|
|
69
|
+
if (!(yield this._fileService.FileExists(file)))
|
|
70
|
+
return this.BadRequest({ error: `The file ${file} not exists` });
|
|
71
|
+
this.Response.download(file);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
this.Error({ error: err.message });
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
UploadFile(folder, filename) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
if (!filename)
|
|
81
|
+
return this.Error({ error: `The file´s name is required` });
|
|
82
|
+
if (!(yield this._fileService.DirectoryExists(folder)))
|
|
83
|
+
return this.Error({ error: `The folder ${folder} not exists` });
|
|
84
|
+
try {
|
|
85
|
+
(0, formidable_1.default)({ multiples: false }).parse(this.Request, (err, _, incomming) => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
if (err)
|
|
87
|
+
return this.Error(err);
|
|
88
|
+
try {
|
|
89
|
+
let temp = incomming.file.filepath;
|
|
90
|
+
let newfile = path_1.default.join(folder, filename);
|
|
91
|
+
yield this._fileService.CopyAsync(temp, newfile);
|
|
92
|
+
this.OK({ created: true, message: `The file ${newfile} was uploaded` });
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
this.Error({ error: err.message });
|
|
96
|
+
}
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
this.Error({ error: err.message });
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
CreateFolder(folder) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
try {
|
|
107
|
+
yield this._fileService.CreateDirectory(folder);
|
|
108
|
+
this.OK({ created: true, message: `The folder ${folder} was created` });
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
this.Error({ error: err.message });
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
__decorate([
|
|
117
|
+
ControllerDecorators_1.default.Action("/default-dir"),
|
|
118
|
+
__metadata("design:type", Function),
|
|
119
|
+
__metadata("design:paramtypes", []),
|
|
120
|
+
__metadata("design:returntype", Promise)
|
|
121
|
+
], FileController.prototype, "GetDefaultDir", null);
|
|
122
|
+
__decorate([
|
|
123
|
+
ControllerDecorators_1.default.Action("/files"),
|
|
124
|
+
ControllerDecorators_1.default.Argument("folder"),
|
|
125
|
+
__metadata("design:type", Function),
|
|
126
|
+
__metadata("design:paramtypes", [String]),
|
|
127
|
+
__metadata("design:returntype", Promise)
|
|
128
|
+
], FileController.prototype, "GetAllFiles", null);
|
|
129
|
+
__decorate([
|
|
130
|
+
ControllerDecorators_1.default.Action("/folders"),
|
|
131
|
+
ControllerDecorators_1.default.Argument("folder"),
|
|
132
|
+
__metadata("design:type", Function),
|
|
133
|
+
__metadata("design:paramtypes", [String]),
|
|
134
|
+
__metadata("design:returntype", Promise)
|
|
135
|
+
], FileController.prototype, "GetAllFolders", null);
|
|
136
|
+
__decorate([
|
|
137
|
+
ControllerDecorators_1.default.Action("/download"),
|
|
138
|
+
ControllerDecorators_1.default.Argument("file"),
|
|
139
|
+
__metadata("design:type", Function),
|
|
140
|
+
__metadata("design:paramtypes", [String]),
|
|
141
|
+
__metadata("design:returntype", Promise)
|
|
142
|
+
], FileController.prototype, "DownloadFile", null);
|
|
143
|
+
__decorate([
|
|
144
|
+
ControllerDecorators_1.default.Verb(HttpVerbs_1.HTTPVerbs.POST),
|
|
145
|
+
ControllerDecorators_1.default.Action("/upload"),
|
|
146
|
+
ControllerDecorators_1.default.Argument("folder", "filename"),
|
|
147
|
+
__metadata("design:type", Function),
|
|
148
|
+
__metadata("design:paramtypes", [String, String]),
|
|
149
|
+
__metadata("design:returntype", Promise)
|
|
150
|
+
], FileController.prototype, "UploadFile", null);
|
|
151
|
+
__decorate([
|
|
152
|
+
ControllerDecorators_1.default.Argument("folder"),
|
|
153
|
+
__metadata("design:type", Function),
|
|
154
|
+
__metadata("design:paramtypes", [String]),
|
|
155
|
+
__metadata("design:returntype", Promise)
|
|
156
|
+
], FileController.prototype, "CreateFolder", null);
|
|
157
|
+
FileController = __decorate([
|
|
158
|
+
ControllerDecorators_1.default.Route("/fs"),
|
|
159
|
+
__metadata("design:paramtypes", [FileServiceBase_1.default])
|
|
160
|
+
], FileController);
|
|
161
|
+
exports.FileController = FileController;
|
|
162
|
+
//# sourceMappingURL=FileController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileController.js","sourceRoot":"","sources":["../../controllers/FileController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,0GAAgE;AAChE,0DAAuD;AACvD,4DAAkE;AAClE,8FAAsE;AACtE,gDAAwB;AAExB,4DAAoC;AAIpC,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,+BAAc;IAG9C,YAAoB,YAA8B;QAE9C,KAAK,EAAE,CAAC;QAFQ,iBAAY,GAAZ,YAAY,CAAkB;IAGlD,CAAC;IAGY,aAAa;;YAEtB,IAAG;gBAEC,IAAI,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,CAAC,CAAA;aAEnD;YACD,OAAM,GAAG,EACT;gBACI,IAAI,CAAC,KAAK,CAAC,EAAC,KAAK,EAAI,GAAa,CAAC,OAAO,EAAC,CAAC,CAAC;aAEhD;QACL,CAAC;KAAA;IAIY,WAAW,CAAC,MAAe;;YAEpC,IAAG;gBAEC,IAAI,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAA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;IAFC,8BAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;IACnB,8BAAE,CAAC,QAAQ,CAAS,QAAQ,CAAC;;;;iDAa7B;AAID;IAFC,8BAAE,CAAC,MAAM,CAAC,UAAU,CAAC;IACrB,8BAAE,CAAC,QAAQ,CAAS,QAAQ,CAAC;;;;mDAa7B;AAKD;IAFC,8BAAE,CAAC,MAAM,CAAC,WAAW,CAAC;IACtB,8BAAE,CAAC,QAAQ,CAAS,MAAM,CAAC;;;;kDAgB3B;AAKD;IAHC,8BAAE,CAAC,IAAI,CAAC,qBAAK,CAAC,IAAI,CAAC;IACnB,8BAAE,CAAC,MAAM,CAAC,SAAS,CAAC;IACpB,8BAAE,CAAC,QAAQ,CAAiB,QAAQ,EAAE,UAAU,CAAC;;;;gDA0CjD;AAGD;IADC,8BAAE,CAAC,QAAQ,CAAS,QAAQ,CAAC;;;;kDAe7B;AAxIQ,cAAc;IAD1B,8BAAE,CAAC,KAAK,CAAC,KAAK,CAAC;qCAIuB,yBAAe;GAHzC,cAAc,CA2I1B;AA3IY,wCAAc"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
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
|
+
exports.StatusController = void 0;
|
|
16
|
+
const ControllerDecorators_1 = __importDefault(require("../decorators/controllers/ControllerDecorators"));
|
|
17
|
+
const ControllerBase_1 = require("./base/ControllerBase");
|
|
18
|
+
const HttpVerbs_1 = require("../enums/httpVerbs/HttpVerbs");
|
|
19
|
+
const FileServiceBase_1 = __importDefault(require("../services/fileService/FileServiceBase"));
|
|
20
|
+
let StatusController = class StatusController extends ControllerBase_1.ControllerBase {
|
|
21
|
+
constructor(FileService) {
|
|
22
|
+
super();
|
|
23
|
+
this.FileService = FileService;
|
|
24
|
+
}
|
|
25
|
+
CheckStatus() {
|
|
26
|
+
this.OK({ status: "OK" });
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
__decorate([
|
|
30
|
+
ControllerDecorators_1.default.Before(s => console.log("midleware executado apenas para essa action")),
|
|
31
|
+
ControllerDecorators_1.default.Verb(HttpVerbs_1.HTTPVerbs.GET),
|
|
32
|
+
ControllerDecorators_1.default.Action("/check"),
|
|
33
|
+
__metadata("design:type", Function),
|
|
34
|
+
__metadata("design:paramtypes", []),
|
|
35
|
+
__metadata("design:returntype", void 0)
|
|
36
|
+
], StatusController.prototype, "CheckStatus", null);
|
|
37
|
+
StatusController = __decorate([
|
|
38
|
+
ControllerDecorators_1.default.Use(s => { console.log("primeiro midleware a ser executado"); }),
|
|
39
|
+
ControllerDecorators_1.default.Use(s => { console.log("segundo midleware a ser executado"); }),
|
|
40
|
+
ControllerDecorators_1.default.Route("/status"),
|
|
41
|
+
__metadata("design:paramtypes", [FileServiceBase_1.default])
|
|
42
|
+
], StatusController);
|
|
43
|
+
exports.StatusController = StatusController;
|
|
44
|
+
//# sourceMappingURL=StatusController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusController.js","sourceRoot":"","sources":["../../controllers/StatusController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0GAAgE;AAChE,0DAAuD;AACvD,4DAAkE;AAClE,8FAAsE;AAMtE,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,+BAAc;IAGhD,YAAmB,WAA6B;QAE5C,KAAK,EAAE,CAAC;QAFO,gBAAW,GAAX,WAAW,CAAkB;IAGhD,CAAC;IAKM,WAAW;QAEd,IAAI,CAAC,EAAE,CAAC,EAAC,MAAM,EAAG,IAAI,EAAC,CAAC,CAAA;IAC5B,CAAC;CAEJ,CAAA;AALG;IAHC,8BAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;IAC1E,8BAAE,CAAC,IAAI,CAAC,qBAAK,CAAC,GAAG,CAAC;IAClB,8BAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;;;;mDAInB;AAdQ,gBAAgB;IAH5B,8BAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAA,CAAA,CAAC,CAAC;IACjE,8BAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAA,CAAA,CAAC,CAAC;IAChE,8BAAE,CAAC,KAAK,CAAC,SAAS,CAAC;qCAIiB,yBAAe;GAHvC,gBAAgB,CAgB5B;AAhBY,4CAAgB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import IController from "../../interfaces/IController";
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import IApplication from "../../interfaces/IApplication";
|
|
4
|
+
export declare class ControllerBase implements IController {
|
|
5
|
+
Request: Request;
|
|
6
|
+
Response: Response;
|
|
7
|
+
constructor();
|
|
8
|
+
OK<T>(result: T): void;
|
|
9
|
+
Created(): void;
|
|
10
|
+
BadRequest<T>(result: T): void;
|
|
11
|
+
Error<T>(result: T): void;
|
|
12
|
+
SendResponse<T>(status: number, result: T): void;
|
|
13
|
+
static AppendController<T extends IController>(ctor: {
|
|
14
|
+
new (...args: any[]): T;
|
|
15
|
+
}, application: IApplication): void;
|
|
16
|
+
}
|