@pristine-ts/http 0.0.302 → 0.0.304
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/lib/cjs/commands/commands.js +19 -0
- package/dist/lib/cjs/commands/commands.js.map +1 -0
- package/dist/lib/cjs/commands/file-server.command-options.js +24 -0
- package/dist/lib/cjs/commands/file-server.command-options.js.map +1 -0
- package/dist/lib/cjs/commands/file-server.command.js +51 -0
- package/dist/lib/cjs/commands/file-server.command.js.map +1 -0
- package/dist/lib/cjs/http.module.js +22 -3
- package/dist/lib/cjs/http.module.js.map +1 -1
- package/dist/lib/cjs/servers/file.http-server.js +177 -0
- package/dist/lib/cjs/servers/file.http-server.js.map +1 -0
- package/dist/lib/cjs/servers/servers.js +18 -0
- package/dist/lib/cjs/servers/servers.js.map +1 -0
- package/dist/lib/esm/commands/commands.js +3 -0
- package/dist/lib/esm/commands/commands.js.map +1 -0
- package/dist/lib/esm/commands/file-server.command-options.js +20 -0
- package/dist/lib/esm/commands/file-server.command-options.js.map +1 -0
- package/dist/lib/esm/commands/file-server.command.js +48 -0
- package/dist/lib/esm/commands/file-server.command.js.map +1 -0
- package/dist/lib/esm/http.module.js +23 -4
- package/dist/lib/esm/http.module.js.map +1 -1
- package/dist/lib/esm/servers/file.http-server.js +171 -0
- package/dist/lib/esm/servers/file.http-server.js.map +1 -0
- package/dist/lib/esm/servers/servers.js +2 -0
- package/dist/lib/esm/servers/servers.js.map +1 -0
- package/dist/types/commands/commands.d.ts +2 -0
- package/dist/types/commands/file-server.command-options.d.ts +5 -0
- package/dist/types/commands/file-server.command.d.ts +12 -0
- package/dist/types/http.module.d.ts +2 -0
- package/dist/types/servers/file.http-server.d.ts +7 -0
- package/dist/types/servers/servers.d.ts +1 -0
- package/package.json +8 -5
|
@@ -0,0 +1,19 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./file-server.command"), exports);
|
|
18
|
+
__exportStar(require("./file-server.command-options"), exports);
|
|
19
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../../../src/commands/commands.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,gEAA8C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FileServerCommandOptions = void 0;
|
|
13
|
+
const class_validator_1 = require("@pristine-ts/class-validator");
|
|
14
|
+
class FileServerCommandOptions {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.directory = "./";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.FileServerCommandOptions = FileServerCommandOptions;
|
|
20
|
+
__decorate([
|
|
21
|
+
(0, class_validator_1.IsString)(),
|
|
22
|
+
__metadata("design:type", String)
|
|
23
|
+
], FileServerCommandOptions.prototype, "directory", void 0);
|
|
24
|
+
//# sourceMappingURL=file-server.command-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-server.command-options.js","sourceRoot":"","sources":["../../../../src/commands/file-server.command-options.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kEAAsD;AAEtD,MAAa,wBAAwB;IAArC;QAEI,cAAS,GAAW,IAAI,CAAC;IAK7B,CAAC;CAAA;AAPD,4DAOC;AALG;IADC,IAAA,0BAAQ,GAAE;;2DACc"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.FileServerCommand = void 0;
|
|
22
|
+
require("reflect-metadata");
|
|
23
|
+
const common_1 = require("@pristine-ts/common");
|
|
24
|
+
const http_module_keyname_1 = require("../http.module.keyname");
|
|
25
|
+
const tsyringe_1 = require("tsyringe");
|
|
26
|
+
const cli_1 = require("@pristine-ts/cli");
|
|
27
|
+
const file_http_server_1 = require("../servers/file.http-server");
|
|
28
|
+
const file_server_command_options_1 = require("./file-server.command-options");
|
|
29
|
+
let FileServerCommand = class FileServerCommand {
|
|
30
|
+
constructor(consoleManager, fileHttpServer) {
|
|
31
|
+
this.consoleManager = consoleManager;
|
|
32
|
+
this.fileHttpServer = fileHttpServer;
|
|
33
|
+
this.optionsType = new file_server_command_options_1.FileServerCommandOptions();
|
|
34
|
+
this.name = "file-server:start";
|
|
35
|
+
}
|
|
36
|
+
run(args) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
yield this.fileHttpServer.start(args.directory, args.port, args.address);
|
|
39
|
+
return cli_1.ExitCodeEnum.Success;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.FileServerCommand = FileServerCommand;
|
|
44
|
+
exports.FileServerCommand = FileServerCommand = __decorate([
|
|
45
|
+
(0, common_1.tag)(common_1.ServiceDefinitionTagEnum.Command),
|
|
46
|
+
(0, common_1.moduleScoped)(http_module_keyname_1.HttpModuleKeyname),
|
|
47
|
+
(0, tsyringe_1.injectable)(),
|
|
48
|
+
__metadata("design:paramtypes", [cli_1.ConsoleManager,
|
|
49
|
+
file_http_server_1.FileHttpServer])
|
|
50
|
+
], FileServerCommand);
|
|
51
|
+
//# sourceMappingURL=file-server.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-server.command.js","sourceRoot":"","sources":["../../../../src/commands/file-server.command.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,4BAAyB;AACzB,gDAAgF;AAChF,gEAAyD;AACzD,uCAAoC;AACpC,0CAAgF;AAChF,kEAA2D;AAC3D,+EAAuE;AAKhE,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC1B,YACqB,cAA8B,EAC9B,cAA8B;QAD9B,mBAAc,GAAd,cAAc,CAAgB;QAC9B,mBAAc,GAAd,cAAc,CAAgB;QAGnD,gBAAW,GAA6B,IAAI,sDAAwB,EAAE,CAAA;QACtE,SAAI,GAAG,mBAAmB,CAAC;IAH3B,CAAC;IAKK,GAAG,CAAC,IAA8B;;YACpC,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAEzE,OAAO,kBAAY,CAAC,OAAO,CAAC;QAChC,CAAC;KAAA;CACJ,CAAA;AAdY,8CAAiB;4BAAjB,iBAAiB;IAH7B,IAAA,YAAG,EAAC,iCAAwB,CAAC,OAAO,CAAC;IACrC,IAAA,qBAAY,EAAC,uCAAiB,CAAC;IAC/B,IAAA,qBAAU,GAAE;qCAG4B,oBAAc;QACd,iCAAc;GAH1C,iBAAiB,CAc7B"}
|
|
@@ -18,27 +18,46 @@ exports.HttpModule = void 0;
|
|
|
18
18
|
const http_module_keyname_1 = require("./http.module.keyname");
|
|
19
19
|
const logging_1 = require("@pristine-ts/logging");
|
|
20
20
|
const configuration_1 = require("@pristine-ts/configuration");
|
|
21
|
+
const cli_1 = require("@pristine-ts/cli");
|
|
21
22
|
__exportStar(require("./http.module.keyname"), exports);
|
|
23
|
+
__exportStar(require("./commands/commands"), exports);
|
|
22
24
|
__exportStar(require("./clients/clients"), exports);
|
|
23
25
|
__exportStar(require("./enums/enums"), exports);
|
|
24
26
|
__exportStar(require("./errors/errors"), exports);
|
|
25
27
|
__exportStar(require("./interceptors/interceptors"), exports);
|
|
26
28
|
__exportStar(require("./interfaces/interfaces"), exports);
|
|
27
29
|
__exportStar(require("./options/options"), exports);
|
|
30
|
+
__exportStar(require("./servers/servers"), exports);
|
|
28
31
|
__exportStar(require("./utils/utils"), exports);
|
|
29
32
|
__exportStar(require("./wrappers/wrappers"), exports);
|
|
30
33
|
exports.HttpModule = {
|
|
31
34
|
keyname: http_module_keyname_1.HttpModuleKeyname,
|
|
32
|
-
importModules: [logging_1.LoggingModule],
|
|
35
|
+
importModules: [logging_1.LoggingModule, cli_1.CliModule],
|
|
33
36
|
configurationDefinitions: [
|
|
34
37
|
{
|
|
35
|
-
parameterName:
|
|
38
|
+
parameterName: `${http_module_keyname_1.HttpModuleKeyname}.logging-enabled`,
|
|
36
39
|
defaultValue: true,
|
|
37
40
|
isRequired: false,
|
|
38
41
|
defaultResolvers: [
|
|
39
42
|
new configuration_1.BooleanResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_HTTP_LOGGING")),
|
|
40
43
|
]
|
|
41
|
-
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
parameterName: `${http_module_keyname_1.HttpModuleKeyname}.http-server.file.address`,
|
|
47
|
+
defaultValue: "127.0.0.1",
|
|
48
|
+
isRequired: false,
|
|
49
|
+
defaultResolvers: [
|
|
50
|
+
new configuration_1.EnvironmentVariableResolver("PRISTINE_HTTP_SERVER_FILE_ADDRESS"),
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
parameterName: `${http_module_keyname_1.HttpModuleKeyname}.http-server.file.port`,
|
|
55
|
+
defaultValue: 9000,
|
|
56
|
+
isRequired: false,
|
|
57
|
+
defaultResolvers: [
|
|
58
|
+
new configuration_1.NumberResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_HTTP_SERVER_FILE_PORT")),
|
|
59
|
+
]
|
|
60
|
+
},
|
|
42
61
|
],
|
|
43
62
|
};
|
|
44
63
|
//# sourceMappingURL=http.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.module.js","sourceRoot":"","sources":["../../../src/http.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,+DAAwD;AACxD,kDAAmD;AACnD,
|
|
1
|
+
{"version":3,"file":"http.module.js","sourceRoot":"","sources":["../../../src/http.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,+DAAwD;AACxD,kDAAmD;AACnD,8DAAwG;AACxG,0CAA2C;AAE3C,wDAAsC;AACtC,sDAAoC;AACpC,oDAAkC;AAClC,gDAA8B;AAC9B,kDAAgC;AAChC,8DAA2C;AAC3C,0DAAuC;AACvC,oDAAkC;AAClC,oDAAkC;AAClC,gDAA8B;AAC9B,sDAAoC;AAEvB,QAAA,UAAU,GAAoB;IACvC,OAAO,EAAE,uCAAiB;IAC1B,aAAa,EAAE,CAAC,uBAAa,EAAE,eAAS,CAAC;IACzC,wBAAwB,EAAE;QACtB;YACI,aAAa,EAAE,GAAG,uCAAiB,kBAAkB;YACrD,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,+BAAe,CAAC,IAAI,2CAA2B,CAAC,uBAAuB,CAAC,CAAC;aAChF;SACJ;QACD;YACI,aAAa,EAAE,GAAG,uCAAiB,2BAA2B;YAC9D,YAAY,EAAE,WAAW;YACzB,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,2CAA2B,CAAC,mCAAmC,CAAC;aACvE;SACJ;QACD;YACI,aAAa,EAAE,GAAG,uCAAiB,wBAAwB;YAC3D,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,8BAAc,CAAC,IAAI,2CAA2B,CAAC,gCAAgC,CAAC,CAAC;aACxF;SACJ;KACJ;CACJ,CAAA"}
|
|
@@ -0,0 +1,177 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.FileHttpServer = void 0;
|
|
28
|
+
const tsyringe_1 = require("tsyringe");
|
|
29
|
+
const http_module_keyname_1 = require("../http.module.keyname");
|
|
30
|
+
const http_1 = __importDefault(require("http"));
|
|
31
|
+
const fs_1 = __importDefault(require("fs"));
|
|
32
|
+
const path_1 = __importDefault(require("path"));
|
|
33
|
+
const url_1 = __importDefault(require("url"));
|
|
34
|
+
let FileHttpServer = class FileHttpServer {
|
|
35
|
+
constructor(address, port) {
|
|
36
|
+
this.address = address;
|
|
37
|
+
this.port = port;
|
|
38
|
+
}
|
|
39
|
+
getPort() {
|
|
40
|
+
if (this.port) {
|
|
41
|
+
return this.port;
|
|
42
|
+
}
|
|
43
|
+
// Will bind to an open port if you specify 0.
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
start(directory, port, address) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
port = port !== null && port !== void 0 ? port : this.getPort();
|
|
49
|
+
address = address !== null && address !== void 0 ? address : this.address;
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
http_1.default.createServer((req, res) => {
|
|
52
|
+
if (req.url === undefined) {
|
|
53
|
+
console.error("URL undefined, skipping.");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
// parse URL
|
|
57
|
+
const parsedUrl = url_1.default.parse(req.url);
|
|
58
|
+
// extract URL path
|
|
59
|
+
let pathname = path_1.default.join(directory, `${parsedUrl.pathname}`);
|
|
60
|
+
// based on the URL path, extract the file extension. e.g. .js, .doc, ...
|
|
61
|
+
const ext = path_1.default.parse(pathname).ext;
|
|
62
|
+
// maps file extension to MIME typere
|
|
63
|
+
const map = {
|
|
64
|
+
".aac": "audio/aac",
|
|
65
|
+
".abw": "application/x-abiword",
|
|
66
|
+
".arc": "application/x-freearc",
|
|
67
|
+
".avi": "video/x-msvideo",
|
|
68
|
+
".azw": "application/vnd.amazon.ebook",
|
|
69
|
+
".bin": "application/octet-stream",
|
|
70
|
+
".bmp": "image/bmp",
|
|
71
|
+
".bz": "application/x-bzip",
|
|
72
|
+
".bz2": "application/x-bzip2",
|
|
73
|
+
".csh": "application/x-csh",
|
|
74
|
+
".css": "text/css",
|
|
75
|
+
".csv": "text/csv",
|
|
76
|
+
".doc": "application/msword",
|
|
77
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
78
|
+
".eot": "application/vnd.ms-fontobject",
|
|
79
|
+
".epub": "application/epub+zip",
|
|
80
|
+
".gif": "image/gif",
|
|
81
|
+
".htm": "text/html",
|
|
82
|
+
".html": "text/html",
|
|
83
|
+
".ico": "image/vnd.microsoft.icon",
|
|
84
|
+
".ics": "text/calendar",
|
|
85
|
+
".jar": "application/java-archive",
|
|
86
|
+
".jpeg": "image/jpeg",
|
|
87
|
+
".jpg": "image/jpeg",
|
|
88
|
+
".js": "text/javascript",
|
|
89
|
+
".json": "application/json",
|
|
90
|
+
".jsonld": "application/ld+json",
|
|
91
|
+
".mid": "audio/midi",
|
|
92
|
+
".midi": "audio/midi",
|
|
93
|
+
".mjs": "text/javascript",
|
|
94
|
+
".mp3": "audio/mpeg",
|
|
95
|
+
".mp4": "video/mp4",
|
|
96
|
+
".mpeg": "video/mpeg",
|
|
97
|
+
".mpkg": "application/vnd.apple.installer+xml",
|
|
98
|
+
".odp": "application/vnd.oasis.opendocument.presentation",
|
|
99
|
+
".ods": "application/vnd.oasis.opendocument.spreadsheet",
|
|
100
|
+
".odt": "application/vnd.oasis.opendocument.text",
|
|
101
|
+
".oga": "audio/ogg",
|
|
102
|
+
".ogv": "video/ogg",
|
|
103
|
+
".ogx": "application/ogg",
|
|
104
|
+
".otf": "font/otf",
|
|
105
|
+
".png": "image/png",
|
|
106
|
+
".pdf": "application/pdf",
|
|
107
|
+
".php": "application/php",
|
|
108
|
+
".ppt": "application/vnd.ms-powerpoint",
|
|
109
|
+
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
110
|
+
".rar": "application/vnd.rar",
|
|
111
|
+
".rtf": "application/rtf",
|
|
112
|
+
".sh": "application/x-sh",
|
|
113
|
+
".svg": "image/svg+xml",
|
|
114
|
+
".swf": "application/x-shockwave-flash",
|
|
115
|
+
".tar": "application/x-tar",
|
|
116
|
+
".tif": "image/tiff",
|
|
117
|
+
".tiff": "image/tiff",
|
|
118
|
+
".ts": "video/mp2t",
|
|
119
|
+
".ttf": "font/ttf",
|
|
120
|
+
".txt": "text/plain",
|
|
121
|
+
".vsd": "application/vnd.visio",
|
|
122
|
+
".wav": "audio/wav",
|
|
123
|
+
".weba": "audio/webm",
|
|
124
|
+
".webm": "video/webm",
|
|
125
|
+
".webp": "image/webp",
|
|
126
|
+
".woff": "font/woff",
|
|
127
|
+
".woff2": "font/woff2",
|
|
128
|
+
".xhtml": "application/xhtml+xml",
|
|
129
|
+
".xls": "application/vnd.ms-excel",
|
|
130
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
131
|
+
".xml": "application/xml",
|
|
132
|
+
".xul": "application/vnd.mozilla.xul+xml",
|
|
133
|
+
".zip": "application/zip",
|
|
134
|
+
".3gp": "video/3gpp",
|
|
135
|
+
".3g2": "video/3gpp2",
|
|
136
|
+
".7z": "application/x-7z-compressed"
|
|
137
|
+
};
|
|
138
|
+
fs_1.default.exists(pathname, function (exist) {
|
|
139
|
+
if (!exist) {
|
|
140
|
+
// if the file is not found, return 404
|
|
141
|
+
res.statusCode = 404;
|
|
142
|
+
res.end(`File ${pathname} not found!`);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
// if is a directory search for index file matching the extension
|
|
146
|
+
if (fs_1.default.statSync(pathname).isDirectory())
|
|
147
|
+
pathname += '/index' + ext;
|
|
148
|
+
// read file from file system
|
|
149
|
+
fs_1.default.readFile(pathname, function (err, data) {
|
|
150
|
+
var _a;
|
|
151
|
+
if (err) {
|
|
152
|
+
res.statusCode = 500;
|
|
153
|
+
res.end(`Error getting the file: ${err}.`);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
// if the file is found, set Content-type and send data
|
|
157
|
+
res.setHeader('Content-type', (_a = map[ext]) !== null && _a !== void 0 ? _a : 'text/plain');
|
|
158
|
+
res.end(data);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
}).listen(port, address, () => {
|
|
163
|
+
console.log("Server started on port: " + port);
|
|
164
|
+
return resolve();
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
exports.FileHttpServer = FileHttpServer;
|
|
171
|
+
exports.FileHttpServer = FileHttpServer = __decorate([
|
|
172
|
+
(0, tsyringe_1.injectable)(),
|
|
173
|
+
__param(0, (0, tsyringe_1.inject)(`%${http_module_keyname_1.HttpModuleKeyname}.http-server.file.address%`)),
|
|
174
|
+
__param(1, (0, tsyringe_1.inject)(`%${http_module_keyname_1.HttpModuleKeyname}.http-server.file.port%`)),
|
|
175
|
+
__metadata("design:paramtypes", [String, Number])
|
|
176
|
+
], FileHttpServer);
|
|
177
|
+
//# sourceMappingURL=file.http-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.http-server.js","sourceRoot":"","sources":["../../../../src/servers/file.http-server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAC5C,gEAAyD;AACzD,gDAA2C;AAC3C,4CAAoB;AACpB,gDAAwB;AACxB,8CA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AAC,CAAC;4BAC/C,CAAC;iCAAM,CAAC;gCACJ,uDAAuD;gCACvD,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,MAAA,GAAG,CAAC,GAAG,CAAC,mCAAI,YAAY,CAAE,CAAC;gCACzD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;4BAClB,CAAC;wBACL,CAAC,CAAC,CAAC;oBACP,CAAC,CAAC,CAAC;gBAEP,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE;oBAC1B,OAAO,CAAC,GAAG,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAAC;oBAE/C,OAAO,OAAO,EAAE,CAAC;gBACrB,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;CACJ,CAAA;AA3IY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,qBAAU,GAAE;IAEI,WAAA,IAAA,iBAAM,EAAC,IAAI,uCAAiB,4BAA4B,CAAC,CAAA;IACzD,WAAA,IAAA,iBAAM,EAAC,IAAI,uCAAiB,yBAAyB,CAAC,CAAA;;GAF1D,cAAc,CA2I1B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./file.http-server"), exports);
|
|
18
|
+
//# sourceMappingURL=servers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"servers.js","sourceRoot":"","sources":["../../../../src/servers/servers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../../../src/commands/commands.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { IsString } from "@pristine-ts/class-validator";
|
|
11
|
+
export class FileServerCommandOptions {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.directory = "./";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
__decorate([
|
|
17
|
+
IsString(),
|
|
18
|
+
__metadata("design:type", String)
|
|
19
|
+
], FileServerCommandOptions.prototype, "directory", void 0);
|
|
20
|
+
//# sourceMappingURL=file-server.command-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-server.command-options.js","sourceRoot":"","sources":["../../../../src/commands/file-server.command-options.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,8BAA8B,CAAC;AAEtD,MAAM,OAAO,wBAAwB;IAArC;QAEI,cAAS,GAAW,IAAI,CAAC;IAK7B,CAAC;CAAA;AALG;IADC,QAAQ,EAAE;;2DACc"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
12
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
13
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
14
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
15
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
16
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
import "reflect-metadata";
|
|
20
|
+
import { moduleScoped, ServiceDefinitionTagEnum, tag } from "@pristine-ts/common";
|
|
21
|
+
import { HttpModuleKeyname } from "../http.module.keyname";
|
|
22
|
+
import { injectable } from "tsyringe";
|
|
23
|
+
import { ConsoleManager, ExitCodeEnum } from "@pristine-ts/cli";
|
|
24
|
+
import { FileHttpServer } from "../servers/file.http-server";
|
|
25
|
+
import { FileServerCommandOptions } from "./file-server.command-options";
|
|
26
|
+
let FileServerCommand = class FileServerCommand {
|
|
27
|
+
constructor(consoleManager, fileHttpServer) {
|
|
28
|
+
this.consoleManager = consoleManager;
|
|
29
|
+
this.fileHttpServer = fileHttpServer;
|
|
30
|
+
this.optionsType = new FileServerCommandOptions();
|
|
31
|
+
this.name = "file-server:start";
|
|
32
|
+
}
|
|
33
|
+
run(args) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
yield this.fileHttpServer.start(args.directory, args.port, args.address);
|
|
36
|
+
return ExitCodeEnum.Success;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
FileServerCommand = __decorate([
|
|
41
|
+
tag(ServiceDefinitionTagEnum.Command),
|
|
42
|
+
moduleScoped(HttpModuleKeyname),
|
|
43
|
+
injectable(),
|
|
44
|
+
__metadata("design:paramtypes", [ConsoleManager,
|
|
45
|
+
FileHttpServer])
|
|
46
|
+
], FileServerCommand);
|
|
47
|
+
export { FileServerCommand };
|
|
48
|
+
//# sourceMappingURL=file-server.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-server.command.js","sourceRoot":"","sources":["../../../../src/commands/file-server.command.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,kBAAkB,CAAA;AACzB,OAAO,EAAC,YAAY,EAAE,wBAAwB,EAAE,GAAG,EAAC,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAmB,cAAc,EAAE,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAC,wBAAwB,EAAC,MAAM,+BAA+B,CAAC;AAKhE,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC1B,YACqB,cAA8B,EAC9B,cAA8B;QAD9B,mBAAc,GAAd,cAAc,CAAgB;QAC9B,mBAAc,GAAd,cAAc,CAAgB;QAGnD,gBAAW,GAA6B,IAAI,wBAAwB,EAAE,CAAA;QACtE,SAAI,GAAG,mBAAmB,CAAC;IAH3B,CAAC;IAKK,GAAG,CAAC,IAA8B;;YACpC,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAEzE,OAAO,YAAY,CAAC,OAAO,CAAC;QAChC,CAAC;KAAA;CACJ,CAAA;AAdY,iBAAiB;IAH7B,GAAG,CAAC,wBAAwB,CAAC,OAAO,CAAC;IACrC,YAAY,CAAC,iBAAiB,CAAC;IAC/B,UAAU,EAAE;qCAG4B,cAAc;QACd,cAAc;GAH1C,iBAAiB,CAc7B"}
|
|
@@ -1,27 +1,46 @@
|
|
|
1
1
|
import { HttpModuleKeyname } from "./http.module.keyname";
|
|
2
2
|
import { LoggingModule } from "@pristine-ts/logging";
|
|
3
|
-
import { BooleanResolver, EnvironmentVariableResolver } from "@pristine-ts/configuration";
|
|
3
|
+
import { BooleanResolver, EnvironmentVariableResolver, NumberResolver } from "@pristine-ts/configuration";
|
|
4
|
+
import { CliModule } from "@pristine-ts/cli";
|
|
4
5
|
export * from "./http.module.keyname";
|
|
6
|
+
export * from "./commands/commands";
|
|
5
7
|
export * from "./clients/clients";
|
|
6
8
|
export * from "./enums/enums";
|
|
7
9
|
export * from "./errors/errors";
|
|
8
10
|
export * from "./interceptors/interceptors";
|
|
9
11
|
export * from "./interfaces/interfaces";
|
|
10
12
|
export * from "./options/options";
|
|
13
|
+
export * from "./servers/servers";
|
|
11
14
|
export * from "./utils/utils";
|
|
12
15
|
export * from "./wrappers/wrappers";
|
|
13
16
|
export const HttpModule = {
|
|
14
17
|
keyname: HttpModuleKeyname,
|
|
15
|
-
importModules: [LoggingModule],
|
|
18
|
+
importModules: [LoggingModule, CliModule],
|
|
16
19
|
configurationDefinitions: [
|
|
17
20
|
{
|
|
18
|
-
parameterName:
|
|
21
|
+
parameterName: `${HttpModuleKeyname}.logging-enabled`,
|
|
19
22
|
defaultValue: true,
|
|
20
23
|
isRequired: false,
|
|
21
24
|
defaultResolvers: [
|
|
22
25
|
new BooleanResolver(new EnvironmentVariableResolver("PRISTINE_HTTP_LOGGING")),
|
|
23
26
|
]
|
|
24
|
-
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
parameterName: `${HttpModuleKeyname}.http-server.file.address`,
|
|
30
|
+
defaultValue: "127.0.0.1",
|
|
31
|
+
isRequired: false,
|
|
32
|
+
defaultResolvers: [
|
|
33
|
+
new EnvironmentVariableResolver("PRISTINE_HTTP_SERVER_FILE_ADDRESS"),
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
parameterName: `${HttpModuleKeyname}.http-server.file.port`,
|
|
38
|
+
defaultValue: 9000,
|
|
39
|
+
isRequired: false,
|
|
40
|
+
defaultResolvers: [
|
|
41
|
+
new NumberResolver(new EnvironmentVariableResolver("PRISTINE_HTTP_SERVER_FILE_PORT")),
|
|
42
|
+
]
|
|
43
|
+
},
|
|
25
44
|
],
|
|
26
45
|
};
|
|
27
46
|
//# sourceMappingURL=http.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.module.js","sourceRoot":"","sources":["../../../src/http.module.ts"],"names":[],"m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AAC,mCAAmC,CAAC;aACvE;SACJ;QACD;YACI,aAAa,EAAE,GAAG,iBAAiB,wBAAwB;YAC3D,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBACd,IAAI,cAAc,CAAC,IAAI,2BAA2B,CAAC,gCAAgC,CAAC,CAAC;aACxF;SACJ;KACJ;CACJ,CAAA"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
import { injectable, inject } from "tsyringe";
|
|
23
|
+
import { HttpModuleKeyname } from "../http.module.keyname";
|
|
24
|
+
import http from "http";
|
|
25
|
+
import fs from "fs";
|
|
26
|
+
import path from "path";
|
|
27
|
+
import url from "url";
|
|
28
|
+
let FileHttpServer = class FileHttpServer {
|
|
29
|
+
constructor(address, port) {
|
|
30
|
+
this.address = address;
|
|
31
|
+
this.port = port;
|
|
32
|
+
}
|
|
33
|
+
getPort() {
|
|
34
|
+
if (this.port) {
|
|
35
|
+
return this.port;
|
|
36
|
+
}
|
|
37
|
+
// Will bind to an open port if you specify 0.
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
start(directory, port, address) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
port = port !== null && port !== void 0 ? port : this.getPort();
|
|
43
|
+
address = address !== null && address !== void 0 ? address : this.address;
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
http.createServer((req, res) => {
|
|
46
|
+
if (req.url === undefined) {
|
|
47
|
+
console.error("URL undefined, skipping.");
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
// parse URL
|
|
51
|
+
const parsedUrl = url.parse(req.url);
|
|
52
|
+
// extract URL path
|
|
53
|
+
let pathname = path.join(directory, `${parsedUrl.pathname}`);
|
|
54
|
+
// based on the URL path, extract the file extension. e.g. .js, .doc, ...
|
|
55
|
+
const ext = path.parse(pathname).ext;
|
|
56
|
+
// maps file extension to MIME typere
|
|
57
|
+
const map = {
|
|
58
|
+
".aac": "audio/aac",
|
|
59
|
+
".abw": "application/x-abiword",
|
|
60
|
+
".arc": "application/x-freearc",
|
|
61
|
+
".avi": "video/x-msvideo",
|
|
62
|
+
".azw": "application/vnd.amazon.ebook",
|
|
63
|
+
".bin": "application/octet-stream",
|
|
64
|
+
".bmp": "image/bmp",
|
|
65
|
+
".bz": "application/x-bzip",
|
|
66
|
+
".bz2": "application/x-bzip2",
|
|
67
|
+
".csh": "application/x-csh",
|
|
68
|
+
".css": "text/css",
|
|
69
|
+
".csv": "text/csv",
|
|
70
|
+
".doc": "application/msword",
|
|
71
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
72
|
+
".eot": "application/vnd.ms-fontobject",
|
|
73
|
+
".epub": "application/epub+zip",
|
|
74
|
+
".gif": "image/gif",
|
|
75
|
+
".htm": "text/html",
|
|
76
|
+
".html": "text/html",
|
|
77
|
+
".ico": "image/vnd.microsoft.icon",
|
|
78
|
+
".ics": "text/calendar",
|
|
79
|
+
".jar": "application/java-archive",
|
|
80
|
+
".jpeg": "image/jpeg",
|
|
81
|
+
".jpg": "image/jpeg",
|
|
82
|
+
".js": "text/javascript",
|
|
83
|
+
".json": "application/json",
|
|
84
|
+
".jsonld": "application/ld+json",
|
|
85
|
+
".mid": "audio/midi",
|
|
86
|
+
".midi": "audio/midi",
|
|
87
|
+
".mjs": "text/javascript",
|
|
88
|
+
".mp3": "audio/mpeg",
|
|
89
|
+
".mp4": "video/mp4",
|
|
90
|
+
".mpeg": "video/mpeg",
|
|
91
|
+
".mpkg": "application/vnd.apple.installer+xml",
|
|
92
|
+
".odp": "application/vnd.oasis.opendocument.presentation",
|
|
93
|
+
".ods": "application/vnd.oasis.opendocument.spreadsheet",
|
|
94
|
+
".odt": "application/vnd.oasis.opendocument.text",
|
|
95
|
+
".oga": "audio/ogg",
|
|
96
|
+
".ogv": "video/ogg",
|
|
97
|
+
".ogx": "application/ogg",
|
|
98
|
+
".otf": "font/otf",
|
|
99
|
+
".png": "image/png",
|
|
100
|
+
".pdf": "application/pdf",
|
|
101
|
+
".php": "application/php",
|
|
102
|
+
".ppt": "application/vnd.ms-powerpoint",
|
|
103
|
+
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
104
|
+
".rar": "application/vnd.rar",
|
|
105
|
+
".rtf": "application/rtf",
|
|
106
|
+
".sh": "application/x-sh",
|
|
107
|
+
".svg": "image/svg+xml",
|
|
108
|
+
".swf": "application/x-shockwave-flash",
|
|
109
|
+
".tar": "application/x-tar",
|
|
110
|
+
".tif": "image/tiff",
|
|
111
|
+
".tiff": "image/tiff",
|
|
112
|
+
".ts": "video/mp2t",
|
|
113
|
+
".ttf": "font/ttf",
|
|
114
|
+
".txt": "text/plain",
|
|
115
|
+
".vsd": "application/vnd.visio",
|
|
116
|
+
".wav": "audio/wav",
|
|
117
|
+
".weba": "audio/webm",
|
|
118
|
+
".webm": "video/webm",
|
|
119
|
+
".webp": "image/webp",
|
|
120
|
+
".woff": "font/woff",
|
|
121
|
+
".woff2": "font/woff2",
|
|
122
|
+
".xhtml": "application/xhtml+xml",
|
|
123
|
+
".xls": "application/vnd.ms-excel",
|
|
124
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
125
|
+
".xml": "application/xml",
|
|
126
|
+
".xul": "application/vnd.mozilla.xul+xml",
|
|
127
|
+
".zip": "application/zip",
|
|
128
|
+
".3gp": "video/3gpp",
|
|
129
|
+
".3g2": "video/3gpp2",
|
|
130
|
+
".7z": "application/x-7z-compressed"
|
|
131
|
+
};
|
|
132
|
+
fs.exists(pathname, function (exist) {
|
|
133
|
+
if (!exist) {
|
|
134
|
+
// if the file is not found, return 404
|
|
135
|
+
res.statusCode = 404;
|
|
136
|
+
res.end(`File ${pathname} not found!`);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
// if is a directory search for index file matching the extension
|
|
140
|
+
if (fs.statSync(pathname).isDirectory())
|
|
141
|
+
pathname += '/index' + ext;
|
|
142
|
+
// read file from file system
|
|
143
|
+
fs.readFile(pathname, function (err, data) {
|
|
144
|
+
var _a;
|
|
145
|
+
if (err) {
|
|
146
|
+
res.statusCode = 500;
|
|
147
|
+
res.end(`Error getting the file: ${err}.`);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// if the file is found, set Content-type and send data
|
|
151
|
+
res.setHeader('Content-type', (_a = map[ext]) !== null && _a !== void 0 ? _a : 'text/plain');
|
|
152
|
+
res.end(data);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}).listen(port, address, () => {
|
|
157
|
+
console.log("Server started on port: " + port);
|
|
158
|
+
return resolve();
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
FileHttpServer = __decorate([
|
|
165
|
+
injectable(),
|
|
166
|
+
__param(0, inject(`%${HttpModuleKeyname}.http-server.file.address%`)),
|
|
167
|
+
__param(1, inject(`%${HttpModuleKeyname}.http-server.file.port%`)),
|
|
168
|
+
__metadata("design:paramtypes", [String, Number])
|
|
169
|
+
], FileHttpServer);
|
|
170
|
+
export { FileHttpServer };
|
|
171
|
+
//# sourceMappingURL=file.http-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.http-server.js","sourceRoot":"","sources":["../../../../src/servers/file.http-server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,UAAU,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,IAAuB,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,GAAG,MAAM,KAAK,CAAC;AAGf,IAAM,cAAc,GAApB,MAAM,cAAc;IACvB,YAAwF,OAAe,EAClB,IAAY;QADT,YAAO,GAAP,OAAO,CAAQ;QAClB,SAAI,GAAJ,IAAI,CAAQ;IACjG,CAAC;IAEO,OAAO;QACX,IAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YACX,OAAO,IAAI,CAAC,IAAI,CAAC;QACrB,CAAC;QAED,8CAA8C;QAC9C,OAAO,CAAC,CAAC;IACb,CAAC;IA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C,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE;oBAC1B,OAAO,CAAC,GAAG,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAAC;oBAE/C,OAAO,OAAO,EAAE,CAAC;gBACrB,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;CACJ,CAAA;AA3IY,cAAc;IAD1B,UAAU,EAAE;IAEI,WAAA,MAAM,CAAC,IAAI,iBAAiB,4BAA4B,CAAC,CAAA;IACzD,WAAA,MAAM,CAAC,IAAI,iBAAiB,yBAAyB,CAAC,CAAA;;GAF1D,cAAc,CA2I1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"servers.js","sourceRoot":"","sources":["../../../../src/servers/servers.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { CommandInterface, ConsoleManager, ExitCodeEnum } from "@pristine-ts/cli";
|
|
3
|
+
import { FileHttpServer } from "../servers/file.http-server";
|
|
4
|
+
import { FileServerCommandOptions } from "./file-server.command-options";
|
|
5
|
+
export declare class FileServerCommand implements CommandInterface<FileServerCommandOptions> {
|
|
6
|
+
private readonly consoleManager;
|
|
7
|
+
private readonly fileHttpServer;
|
|
8
|
+
constructor(consoleManager: ConsoleManager, fileHttpServer: FileHttpServer);
|
|
9
|
+
optionsType: FileServerCommandOptions;
|
|
10
|
+
name: string;
|
|
11
|
+
run(args: FileServerCommandOptions): Promise<ExitCodeEnum | number>;
|
|
12
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ModuleInterface } from "@pristine-ts/common";
|
|
2
2
|
export * from "./http.module.keyname";
|
|
3
|
+
export * from "./commands/commands";
|
|
3
4
|
export * from "./clients/clients";
|
|
4
5
|
export * from "./enums/enums";
|
|
5
6
|
export * from "./errors/errors";
|
|
6
7
|
export * from "./interceptors/interceptors";
|
|
7
8
|
export * from "./interfaces/interfaces";
|
|
8
9
|
export * from "./options/options";
|
|
10
|
+
export * from "./servers/servers";
|
|
9
11
|
export * from "./utils/utils";
|
|
10
12
|
export * from "./wrappers/wrappers";
|
|
11
13
|
export declare const HttpModule: ModuleInterface;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./file.http-server";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pristine-ts/http",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.304",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "dist/lib/esm/http.module.js",
|
|
6
6
|
"main": "dist/lib/cjs/http.module.js",
|
|
@@ -15,9 +15,12 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@pristine-ts/
|
|
19
|
-
"@pristine-ts/
|
|
20
|
-
"
|
|
18
|
+
"@pristine-ts/class-validator": "^1.0.25",
|
|
19
|
+
"@pristine-ts/cli": "^0.0.304",
|
|
20
|
+
"@pristine-ts/common": "^0.0.304",
|
|
21
|
+
"@pristine-ts/logging": "^0.0.304",
|
|
22
|
+
"lodash": "^4.17.21",
|
|
23
|
+
"tsyringe": "^4.8.0"
|
|
21
24
|
},
|
|
22
25
|
"author": "",
|
|
23
26
|
"license": "ISC",
|
|
@@ -58,5 +61,5 @@
|
|
|
58
61
|
"src/*.{js,ts}"
|
|
59
62
|
]
|
|
60
63
|
},
|
|
61
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "3f3c999223b89a8bcf7dcacf963dbe8b73b09d37"
|
|
62
65
|
}
|