jimpex 10.0.2 → 11.0.0
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/CHANGELOG.md +29 -0
- package/README.md +7 -9
- package/dist/app/index.d.ts +1 -1
- package/dist/app/index.js +1 -22
- package/dist/app/index.js.map +1 -1
- package/dist/app/jimpex.d.ts +1 -1
- package/dist/app/jimpex.js +100 -131
- package/dist/app/jimpex.js.map +1 -1
- package/dist/controllers/common/config.d.ts +2 -2
- package/dist/controllers/common/config.js +12 -39
- package/dist/controllers/common/config.js.map +1 -1
- package/dist/controllers/common/health.d.ts +4 -4
- package/dist/controllers/common/health.js +20 -47
- package/dist/controllers/common/health.js.map +1 -1
- package/dist/controllers/common/index.d.ts +1 -1
- package/dist/controllers/common/index.js +3 -26
- package/dist/controllers/common/index.js.map +1 -1
- package/dist/controllers/common/statics.d.ts +3 -3
- package/dist/controllers/common/statics.js +32 -65
- package/dist/controllers/common/statics.js.map +1 -1
- package/dist/controllers/index.d.ts +1 -1
- package/dist/controllers/index.js +2 -24
- package/dist/controllers/index.js.map +1 -1
- package/dist/controllers/utils/gateway.d.ts +5 -5
- package/dist/controllers/utils/gateway.js +70 -91
- package/dist/controllers/utils/gateway.js.map +1 -1
- package/dist/controllers/utils/index.d.ts +1 -1
- package/dist/controllers/utils/index.js +1 -22
- package/dist/controllers/utils/index.js.map +1 -1
- package/dist/{index-C6I3NCC-.d.ts → index-BlSpNHox.d.ts} +13 -13
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -32
- package/dist/index.js.map +1 -1
- package/dist/middlewares/common/errorHandler.d.ts +5 -5
- package/dist/middlewares/common/errorHandler.js +31 -56
- package/dist/middlewares/common/errorHandler.js.map +1 -1
- package/dist/middlewares/common/forceHTTPS.d.ts +1 -1
- package/dist/middlewares/common/forceHTTPS.js +8 -35
- package/dist/middlewares/common/forceHTTPS.js.map +1 -1
- package/dist/middlewares/common/hsts.d.ts +1 -1
- package/dist/middlewares/common/hsts.js +12 -39
- package/dist/middlewares/common/hsts.js.map +1 -1
- package/dist/middlewares/common/index.d.ts +3 -3
- package/dist/middlewares/common/index.js +3 -26
- package/dist/middlewares/common/index.js.map +1 -1
- package/dist/middlewares/html/fastHTML.d.ts +4 -4
- package/dist/middlewares/html/fastHTML.js +43 -66
- package/dist/middlewares/html/fastHTML.js.map +1 -1
- package/dist/middlewares/html/index.d.ts +2 -2
- package/dist/middlewares/html/index.js +2 -24
- package/dist/middlewares/html/index.js.map +1 -1
- package/dist/middlewares/html/showHTML.d.ts +3 -3
- package/dist/middlewares/html/showHTML.js +25 -52
- package/dist/middlewares/html/showHTML.js.map +1 -1
- package/dist/middlewares/index.d.ts +4 -4
- package/dist/middlewares/index.js +3 -26
- package/dist/middlewares/index.js.map +1 -1
- package/dist/middlewares/utils/index.d.ts +3 -3
- package/dist/middlewares/utils/index.js +1 -22
- package/dist/middlewares/utils/index.js.map +1 -1
- package/dist/middlewares/utils/versionValidator.d.ts +5 -5
- package/dist/middlewares/utils/versionValidator.js +24 -51
- package/dist/middlewares/utils/versionValidator.js.map +1 -1
- package/dist/services/common/appError.d.ts +2 -2
- package/dist/services/common/appError.js +18 -46
- package/dist/services/common/appError.js.map +1 -1
- package/dist/services/common/httpError.d.ts +2 -2
- package/dist/services/common/httpError.js +7 -33
- package/dist/services/common/httpError.js.map +1 -1
- package/dist/services/common/index.d.ts +1 -1
- package/dist/services/common/index.js +14 -42
- package/dist/services/common/index.js.map +1 -1
- package/dist/services/common/sendFile.d.ts +1 -1
- package/dist/services/common/sendFile.js +4 -29
- package/dist/services/common/sendFile.js.map +1 -1
- package/dist/services/frontend/frontendFs.d.ts +2 -2
- package/dist/services/frontend/frontendFs.js +12 -49
- package/dist/services/frontend/frontendFs.js.map +1 -1
- package/dist/services/frontend/index.d.ts +2 -2
- package/dist/services/frontend/index.js +8 -34
- package/dist/services/frontend/index.js.map +1 -1
- package/dist/services/html/htmlGenerator.d.ts +5 -5
- package/dist/services/html/htmlGenerator.js +46 -75
- package/dist/services/html/htmlGenerator.js.map +1 -1
- package/dist/services/html/index.d.ts +2 -2
- package/dist/services/html/index.js +8 -34
- package/dist/services/html/index.js.map +1 -1
- package/dist/services/http/apiClient.d.ts +1 -1
- package/dist/services/http/apiClient.js +23 -48
- package/dist/services/http/apiClient.js.map +1 -1
- package/dist/services/http/http.d.ts +5 -5
- package/dist/services/http/http.js +23 -60
- package/dist/services/http/http.js.map +1 -1
- package/dist/services/http/index.d.ts +2 -2
- package/dist/services/http/index.js +14 -42
- package/dist/services/http/index.js.map +1 -1
- package/dist/services/http/responsesBuilder.d.ts +4 -4
- package/dist/services/http/responsesBuilder.js +13 -40
- package/dist/services/http/responsesBuilder.js.map +1 -1
- package/dist/services/index.d.ts +3 -3
- package/dist/services/index.js +5 -30
- package/dist/services/index.js.map +1 -1
- package/dist/services/utils/ensureBearerToken.d.ts +2 -2
- package/dist/services/utils/ensureBearerToken.js +15 -42
- package/dist/services/utils/ensureBearerToken.js.map +1 -1
- package/dist/services/utils/index.d.ts +1 -1
- package/dist/services/utils/index.js +8 -34
- package/dist/services/utils/index.js.map +1 -1
- package/dist/types/events.d.ts +1 -1
- package/dist/types/events.js +0 -16
- package/dist/types/events.js.map +1 -1
- package/dist/types/express.js +0 -16
- package/dist/types/express.js.map +1 -1
- package/dist/types/http.js +0 -16
- package/dist/types/http.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +6 -32
- package/dist/types/index.js.map +1 -1
- package/dist/types/options.d.ts +1 -1
- package/dist/types/options.js +0 -16
- package/dist/types/options.js.map +1 -1
- package/dist/types/utils.js +0 -16
- package/dist/types/utils.js.map +1 -1
- package/dist/types/wootils.js +0 -16
- package/dist/types/wootils.js.map +1 -1
- package/dist/utils/fns/index.js +4 -28
- package/dist/utils/fns/index.js.map +1 -1
- package/dist/utils/fns/others.js +2 -26
- package/dist/utils/fns/others.js.map +1 -1
- package/dist/utils/fns/routes.js +4 -31
- package/dist/utils/fns/routes.js.map +1 -1
- package/dist/utils/fns/statuses.js +3 -37
- package/dist/utils/fns/statuses.js.map +1 -1
- package/dist/utils/fns/text.js +2 -26
- package/dist/utils/fns/text.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +2 -24
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/wrappers.d.ts +1 -1
- package/dist/utils/wrappers.js +20 -48
- package/dist/utils/wrappers.js.map +1 -1
- package/eslint.config.js +19 -0
- package/examples/basic/app.ts +4 -4
- package/examples/basic/controller.ts +2 -2
- package/examples/basic/index.ts +4 -4
- package/examples/basic/middleware.ts +2 -2
- package/examples/basic/service.ts +1 -1
- package/package.json +61 -49
- package/pnpm-workspace.yaml +4 -0
- package/src/app/index.ts +1 -1
- package/src/app/jimpex.ts +23 -20
- package/src/controllers/common/config.ts +4 -4
- package/src/controllers/common/health.ts +9 -5
- package/src/controllers/common/index.ts +3 -3
- package/src/controllers/common/statics.ts +12 -7
- package/src/controllers/index.ts +2 -2
- package/src/controllers/utils/gateway.ts +8 -8
- package/src/controllers/utils/index.ts +1 -1
- package/src/index.ts +6 -6
- package/src/middlewares/common/errorHandler.ts +9 -5
- package/src/middlewares/common/forceHTTPS.ts +2 -2
- package/src/middlewares/common/hsts.ts +2 -2
- package/src/middlewares/common/index.ts +3 -3
- package/src/middlewares/html/fastHTML.ts +14 -5
- package/src/middlewares/html/index.ts +2 -2
- package/src/middlewares/html/showHTML.ts +8 -4
- package/src/middlewares/index.ts +3 -3
- package/src/middlewares/utils/index.ts +1 -1
- package/src/middlewares/utils/versionValidator.ts +6 -6
- package/src/services/common/appError.ts +1 -1
- package/src/services/common/httpError.ts +2 -2
- package/src/services/common/index.ts +7 -7
- package/src/services/common/sendFile.ts +2 -2
- package/src/services/frontend/frontendFs.ts +3 -3
- package/src/services/frontend/index.ts +3 -3
- package/src/services/html/htmlGenerator.ts +11 -13
- package/src/services/html/index.ts +3 -3
- package/src/services/http/apiClient.ts +3 -3
- package/src/services/http/http.ts +5 -5
- package/src/services/http/index.ts +7 -7
- package/src/services/http/responsesBuilder.ts +5 -5
- package/src/services/index.ts +5 -5
- package/src/services/utils/ensureBearerToken.ts +4 -4
- package/src/services/utils/index.ts +3 -3
- package/src/types/events.ts +8 -8
- package/src/types/http.ts +1 -1
- package/src/types/index.ts +6 -6
- package/src/types/options.ts +2 -2
- package/src/types/utils.ts +4 -4
- package/src/utils/fns/index.ts +4 -4
- package/src/utils/fns/routes.ts +1 -1
- package/src/utils/index.ts +2 -2
- package/src/utils/wrappers.ts +6 -6
- package/tsconfig.json +9 -4
- package/tsup.config.ts +1 -2
- package/vitest.config.ts +24 -0
- package/dist/app/index.d.mts +0 -14
- package/dist/app/jimpex.d.mts +0 -14
- package/dist/controllers/common/config.d.mts +0 -79
- package/dist/controllers/common/health.d.mts +0 -83
- package/dist/controllers/common/index.d.mts +0 -22
- package/dist/controllers/common/statics.d.mts +0 -223
- package/dist/controllers/index.d.mts +0 -25
- package/dist/controllers/utils/gateway.d.mts +0 -725
- package/dist/controllers/utils/index.d.mts +0 -17
- package/dist/esm/app/index.js +0 -2
- package/dist/esm/app/index.js.map +0 -1
- package/dist/esm/app/jimpex.js +0 -640
- package/dist/esm/app/jimpex.js.map +0 -1
- package/dist/esm/chunk-V6TY7KAL.js +0 -8
- package/dist/esm/chunk-V6TY7KAL.js.map +0 -1
- package/dist/esm/controllers/common/config.js +0 -80
- package/dist/esm/controllers/common/config.js.map +0 -1
- package/dist/esm/controllers/common/health.js +0 -88
- package/dist/esm/controllers/common/health.js.map +0 -1
- package/dist/esm/controllers/common/index.js +0 -4
- package/dist/esm/controllers/common/index.js.map +0 -1
- package/dist/esm/controllers/common/statics.js +0 -226
- package/dist/esm/controllers/common/statics.js.map +0 -1
- package/dist/esm/controllers/index.js +0 -3
- package/dist/esm/controllers/index.js.map +0 -1
- package/dist/esm/controllers/utils/gateway.js +0 -559
- package/dist/esm/controllers/utils/gateway.js.map +0 -1
- package/dist/esm/controllers/utils/index.js +0 -2
- package/dist/esm/controllers/utils/index.js.map +0 -1
- package/dist/esm/index.js +0 -7
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/middlewares/common/errorHandler.js +0 -116
- package/dist/esm/middlewares/common/errorHandler.js.map +0 -1
- package/dist/esm/middlewares/common/forceHTTPS.js +0 -52
- package/dist/esm/middlewares/common/forceHTTPS.js.map +0 -1
- package/dist/esm/middlewares/common/hsts.js +0 -74
- package/dist/esm/middlewares/common/hsts.js.map +0 -1
- package/dist/esm/middlewares/common/index.js +0 -4
- package/dist/esm/middlewares/common/index.js.map +0 -1
- package/dist/esm/middlewares/html/fastHTML.js +0 -157
- package/dist/esm/middlewares/html/fastHTML.js.map +0 -1
- package/dist/esm/middlewares/html/index.js +0 -3
- package/dist/esm/middlewares/html/index.js.map +0 -1
- package/dist/esm/middlewares/html/showHTML.js +0 -100
- package/dist/esm/middlewares/html/showHTML.js.map +0 -1
- package/dist/esm/middlewares/index.js +0 -4
- package/dist/esm/middlewares/index.js.map +0 -1
- package/dist/esm/middlewares/utils/index.js +0 -2
- package/dist/esm/middlewares/utils/index.js.map +0 -1
- package/dist/esm/middlewares/utils/versionValidator.js +0 -135
- package/dist/esm/middlewares/utils/versionValidator.js.map +0 -1
- package/dist/esm/services/common/appError.js +0 -98
- package/dist/esm/services/common/appError.js.map +0 -1
- package/dist/esm/services/common/httpError.js +0 -28
- package/dist/esm/services/common/httpError.js.map +0 -1
- package/dist/esm/services/common/index.js +0 -17
- package/dist/esm/services/common/index.js.map +0 -1
- package/dist/esm/services/common/sendFile.js +0 -27
- package/dist/esm/services/common/sendFile.js.map +0 -1
- package/dist/esm/services/frontend/frontendFs.js +0 -66
- package/dist/esm/services/frontend/frontendFs.js.map +0 -1
- package/dist/esm/services/frontend/index.js +0 -11
- package/dist/esm/services/frontend/index.js.map +0 -1
- package/dist/esm/services/html/htmlGenerator.js +0 -192
- package/dist/esm/services/html/htmlGenerator.js.map +0 -1
- package/dist/esm/services/html/index.js +0 -11
- package/dist/esm/services/html/index.js.map +0 -1
- package/dist/esm/services/http/apiClient.js +0 -94
- package/dist/esm/services/http/apiClient.js.map +0 -1
- package/dist/esm/services/http/http.js +0 -180
- package/dist/esm/services/http/http.js.map +0 -1
- package/dist/esm/services/http/index.js +0 -17
- package/dist/esm/services/http/index.js.map +0 -1
- package/dist/esm/services/http/responsesBuilder.js +0 -152
- package/dist/esm/services/http/responsesBuilder.js.map +0 -1
- package/dist/esm/services/index.js +0 -6
- package/dist/esm/services/index.js.map +0 -1
- package/dist/esm/services/utils/ensureBearerToken.js +0 -94
- package/dist/esm/services/utils/ensureBearerToken.js.map +0 -1
- package/dist/esm/services/utils/index.js +0 -11
- package/dist/esm/services/utils/index.js.map +0 -1
- package/dist/esm/types/events.js +0 -1
- package/dist/esm/types/events.js.map +0 -1
- package/dist/esm/types/express.js +0 -1
- package/dist/esm/types/express.js.map +0 -1
- package/dist/esm/types/http.js +0 -1
- package/dist/esm/types/http.js.map +0 -1
- package/dist/esm/types/index.js +0 -7
- package/dist/esm/types/index.js.map +0 -1
- package/dist/esm/types/options.js +0 -1
- package/dist/esm/types/options.js.map +0 -1
- package/dist/esm/types/utils.js +0 -1
- package/dist/esm/types/utils.js.map +0 -1
- package/dist/esm/types/wootils.js +0 -1
- package/dist/esm/types/wootils.js.map +0 -1
- package/dist/esm/utils/fns/index.js +0 -5
- package/dist/esm/utils/fns/index.js.map +0 -1
- package/dist/esm/utils/fns/others.js +0 -6
- package/dist/esm/utils/fns/others.js.map +0 -1
- package/dist/esm/utils/fns/routes.js +0 -25
- package/dist/esm/utils/fns/routes.js.map +0 -1
- package/dist/esm/utils/fns/statuses.js +0 -6
- package/dist/esm/utils/fns/statuses.js.map +0 -1
- package/dist/esm/utils/fns/text.js +0 -6
- package/dist/esm/utils/fns/text.js.map +0 -1
- package/dist/esm/utils/index.js +0 -3
- package/dist/esm/utils/index.js.map +0 -1
- package/dist/esm/utils/wrappers.js +0 -41
- package/dist/esm/utils/wrappers.js.map +0 -1
- package/dist/index-Bwf7JHu9.d.mts +0 -1287
- package/dist/index.d.mts +0 -47
- package/dist/middlewares/common/errorHandler.d.mts +0 -132
- package/dist/middlewares/common/forceHTTPS.d.mts +0 -69
- package/dist/middlewares/common/hsts.d.mts +0 -110
- package/dist/middlewares/common/index.d.mts +0 -22
- package/dist/middlewares/html/fastHTML.d.mts +0 -180
- package/dist/middlewares/html/index.d.mts +0 -21
- package/dist/middlewares/html/showHTML.d.mts +0 -127
- package/dist/middlewares/index.d.mts +0 -30
- package/dist/middlewares/utils/index.d.mts +0 -20
- package/dist/middlewares/utils/versionValidator.d.mts +0 -215
- package/dist/services/common/appError.d.mts +0 -139
- package/dist/services/common/httpError.d.mts +0 -80
- package/dist/services/common/index.d.mts +0 -47
- package/dist/services/common/sendFile.d.mts +0 -102
- package/dist/services/frontend/frontendFs.d.mts +0 -96
- package/dist/services/frontend/index.d.mts +0 -40
- package/dist/services/html/htmlGenerator.d.mts +0 -237
- package/dist/services/html/index.d.mts +0 -43
- package/dist/services/http/apiClient.d.mts +0 -170
- package/dist/services/http/http.d.mts +0 -182
- package/dist/services/http/index.d.mts +0 -51
- package/dist/services/http/responsesBuilder.d.mts +0 -179
- package/dist/services/index.d.mts +0 -33
- package/dist/services/utils/ensureBearerToken.d.mts +0 -158
- package/dist/services/utils/index.d.mts +0 -44
- package/dist/types/events.d.mts +0 -14
- package/dist/types/express.d.mts +0 -10
- package/dist/types/http.d.mts +0 -82
- package/dist/types/index.d.mts +0 -14
- package/dist/types/options.d.mts +0 -14
- package/dist/types/utils.d.mts +0 -48
- package/dist/types/wootils.d.mts +0 -4
- package/dist/utils/fns/index.d.mts +0 -5
- package/dist/utils/fns/others.d.mts +0 -17
- package/dist/utils/fns/routes.d.mts +0 -39
- package/dist/utils/fns/statuses.d.mts +0 -45
- package/dist/utils/fns/text.d.mts +0 -9
- package/dist/utils/index.d.mts +0 -19
- package/dist/utils/wrappers.d.mts +0 -14
|
@@ -1,31 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var httpError_exports = {};
|
|
20
|
-
__export(httpError_exports, {
|
|
21
|
-
HTTPError: () => HTTPError,
|
|
22
|
-
createHTTPError: () => createHTTPError,
|
|
23
|
-
httpErrorProvider: () => httpErrorProvider
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(httpError_exports);
|
|
26
|
-
var import_utils = require("../../utils");
|
|
27
|
-
var import_appError = require("./appError");
|
|
28
|
-
class HTTPError extends import_appError.AppError {
|
|
1
|
+
import { provider, statuses as statusesFn } from "../../utils/index.js";
|
|
2
|
+
import { AppError } from "./appError.js";
|
|
3
|
+
class HTTPError extends AppError {
|
|
29
4
|
/**
|
|
30
5
|
* @param message The error message.
|
|
31
6
|
* @param status The HTTP status code.
|
|
@@ -35,19 +10,18 @@ class HTTPError extends import_appError.AppError {
|
|
|
35
10
|
* the container; otherwise, it will use the `statuses` library
|
|
36
11
|
* directly.
|
|
37
12
|
*/
|
|
38
|
-
constructor(message, status = (
|
|
13
|
+
constructor(message, status = statusesFn("ok"), context = {}, statuses = statusesFn) {
|
|
39
14
|
super(message, { ...context, status }, statuses);
|
|
40
15
|
}
|
|
41
16
|
}
|
|
42
17
|
const createHTTPError = (...args) => new HTTPError(...args);
|
|
43
|
-
const httpErrorProvider =
|
|
18
|
+
const httpErrorProvider = provider((app) => {
|
|
44
19
|
app.set("HTTPError", () => HTTPError);
|
|
45
20
|
app.set("httpError", () => createHTTPError);
|
|
46
21
|
});
|
|
47
|
-
|
|
48
|
-
0 && (module.exports = {
|
|
22
|
+
export {
|
|
49
23
|
HTTPError,
|
|
50
24
|
createHTTPError,
|
|
51
25
|
httpErrorProvider
|
|
52
|
-
}
|
|
26
|
+
};
|
|
53
27
|
//# sourceMappingURL=httpError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/common/httpError.ts"],"sourcesContent":["import { provider, statuses as statusesFn, type Statuses } from '../../utils';\nimport { AppError, type AppErrorContext } from './appError';\n/**\n * A type of error to be used on HTTP requests. This is the most common type of error used\n * by Jimpex.\n *\n * @group Services\n * @group Services/HTTPError\n */\nexport class HTTPError extends AppError {\n /**\n * @param message The error message.\n * @param status The HTTP status code.\n * @param context Context information related to the error.\n * @param statuses A reference to the service that generates HTTP status codes. This\n * is in case the implementation wants to use a special version from\n * the container; otherwise, it will use the `statuses` library\n * directly.\n */\n constructor(\n message: string,\n status: number | string = statusesFn('ok'),\n context: AppErrorContext = {},\n statuses: Statuses = statusesFn,\n ) {\n super(message, { ...context, status }, statuses);\n }\n}\n/**\n * Shorthand for `new HTTPError()`.\n *\n * @param args The same parameters as the {@link HTTPError} constructor.\n * @returns A new instance of {@link HTTPError}.\n * @group Services\n * @group Services/HTTPError\n */\nexport const createHTTPError = (\n ...args: ConstructorParameters<typeof HTTPError>\n): HTTPError => new HTTPError(...args);\n/**\n * The type of the function that generates a new instance of {@link HTTPError}.\n * This is exported to make it easy to type the dependency injection.\n *\n * @group Services/HTTPError\n */\nexport type CreateHTTPErrorFn = typeof createHTTPError;\n/**\n * THe type of the {@link HTTPError} class.\n * This is exported to make it easy to type the dependency injection.\n *\n * @group Services/HTTPError\n */\nexport type HTTPErrorClass = typeof HTTPError;\n/**\n * A service provider that will register both the {@link HTTPError} and a generator\n * function on the container. `HTTPError` will be the key for class, and `httpError` will\n * be for the generator function.\n *\n * @example\n *\n * // Register it on the container\n * container.register(httpErrorProvider);\n * // Getting access to the class.\n * const HTTPError = container.get<HTTPErrorClass>('HTTPError');\n * // Getting access to the function.\n * const httpError = container.get<CreateHTTPErrorFn>('httpError');\n *\n * @group Providers\n * @group Services/HTTPError\n */\nexport const httpErrorProvider = provider((app) => {\n app.set('HTTPError', () => HTTPError);\n app.set('httpError', () => createHTTPError);\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/services/common/httpError.ts"],"sourcesContent":["import { provider, statuses as statusesFn, type Statuses } from '../../utils/index.js';\nimport { AppError, type AppErrorContext } from './appError.js';\n/**\n * A type of error to be used on HTTP requests. This is the most common type of error used\n * by Jimpex.\n *\n * @group Services\n * @group Services/HTTPError\n */\nexport class HTTPError extends AppError {\n /**\n * @param message The error message.\n * @param status The HTTP status code.\n * @param context Context information related to the error.\n * @param statuses A reference to the service that generates HTTP status codes. This\n * is in case the implementation wants to use a special version from\n * the container; otherwise, it will use the `statuses` library\n * directly.\n */\n constructor(\n message: string,\n status: number | string = statusesFn('ok'),\n context: AppErrorContext = {},\n statuses: Statuses = statusesFn,\n ) {\n super(message, { ...context, status }, statuses);\n }\n}\n/**\n * Shorthand for `new HTTPError()`.\n *\n * @param args The same parameters as the {@link HTTPError} constructor.\n * @returns A new instance of {@link HTTPError}.\n * @group Services\n * @group Services/HTTPError\n */\nexport const createHTTPError = (\n ...args: ConstructorParameters<typeof HTTPError>\n): HTTPError => new HTTPError(...args);\n/**\n * The type of the function that generates a new instance of {@link HTTPError}.\n * This is exported to make it easy to type the dependency injection.\n *\n * @group Services/HTTPError\n */\nexport type CreateHTTPErrorFn = typeof createHTTPError;\n/**\n * THe type of the {@link HTTPError} class.\n * This is exported to make it easy to type the dependency injection.\n *\n * @group Services/HTTPError\n */\nexport type HTTPErrorClass = typeof HTTPError;\n/**\n * A service provider that will register both the {@link HTTPError} and a generator\n * function on the container. `HTTPError` will be the key for class, and `httpError` will\n * be for the generator function.\n *\n * @example\n *\n * // Register it on the container\n * container.register(httpErrorProvider);\n * // Getting access to the class.\n * const HTTPError = container.get<HTTPErrorClass>('HTTPError');\n * // Getting access to the function.\n * const httpError = container.get<CreateHTTPErrorFn>('httpError');\n *\n * @group Providers\n * @group Services/HTTPError\n */\nexport const httpErrorProvider = provider((app) => {\n app.set('HTTPError', () => HTTPError);\n app.set('httpError', () => createHTTPError);\n});\n"],"mappings":"AAAA,SAAS,UAAU,YAAY,kBAAiC;AAChE,SAAS,gBAAsC;AAQxC,MAAM,kBAAkB,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUtC,YACE,SACA,SAA0B,WAAW,IAAI,GACzC,UAA2B,CAAC,GAC5B,WAAqB,YACrB;AACA,UAAM,SAAS,EAAE,GAAG,SAAS,OAAO,GAAG,QAAQ;AAAA,EACjD;AACF;AASO,MAAM,kBAAkB,IAC1B,SACW,IAAI,UAAU,GAAG,IAAI;AAgC9B,MAAM,oBAAoB,SAAS,CAAC,QAAQ;AACjD,MAAI,IAAI,aAAa,MAAM,SAAS;AACpC,MAAI,IAAI,aAAa,MAAM,eAAe;AAC5C,CAAC;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-BlSpNHox.js';
|
|
3
3
|
export { AppError, AppErrorClass, AppErrorContext, CreateAppErrorFn, appErrorProvider, createAppError } from './appError.js';
|
|
4
4
|
export { CreateHTTPErrorFn, HTTPError, HTTPErrorClass, createHTTPError, httpErrorProvider } from './httpError.js';
|
|
5
5
|
export { SendFile, SendFileGeneratorOptions, SendFileOptions, sendFile, sendFileProvider } from './sendFile.js';
|
|
@@ -1,44 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var common_exports = {};
|
|
21
|
-
__export(common_exports, {
|
|
22
|
-
commonServicesProvider: () => commonServicesProvider
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(common_exports);
|
|
25
|
-
var import_utils = require("../../utils");
|
|
26
|
-
var import_appError = require("./appError");
|
|
27
|
-
var import_httpError = require("./httpError");
|
|
28
|
-
var import_sendFile = require("./sendFile");
|
|
29
|
-
__reExport(common_exports, require("./appError"), module.exports);
|
|
30
|
-
__reExport(common_exports, require("./httpError"), module.exports);
|
|
31
|
-
__reExport(common_exports, require("./sendFile"), module.exports);
|
|
32
|
-
const commonServicesProvider = (0, import_utils.providers)({
|
|
33
|
-
appErrorProvider: import_appError.appErrorProvider,
|
|
34
|
-
httpErrorProvider: import_httpError.httpErrorProvider,
|
|
35
|
-
sendFileProvider: import_sendFile.sendFileProvider
|
|
36
|
-
});
|
|
37
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
-
0 && (module.exports = {
|
|
39
|
-
commonServicesProvider,
|
|
40
|
-
...require("./appError"),
|
|
41
|
-
...require("./httpError"),
|
|
42
|
-
...require("./sendFile")
|
|
1
|
+
import { providers } from "../../utils/index.js";
|
|
2
|
+
import { appErrorProvider } from "./appError.js";
|
|
3
|
+
import { httpErrorProvider } from "./httpError.js";
|
|
4
|
+
import { sendFileProvider } from "./sendFile.js";
|
|
5
|
+
const commonServicesProvider = providers({
|
|
6
|
+
appErrorProvider,
|
|
7
|
+
httpErrorProvider,
|
|
8
|
+
sendFileProvider
|
|
43
9
|
});
|
|
10
|
+
export * from "./appError.js";
|
|
11
|
+
export * from "./httpError.js";
|
|
12
|
+
export * from "./sendFile.js";
|
|
13
|
+
export {
|
|
14
|
+
commonServicesProvider
|
|
15
|
+
};
|
|
44
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/common/index.ts"],"sourcesContent":["import { providers } from '../../utils';\nimport { appErrorProvider } from './appError';\nimport { httpErrorProvider } from './httpError';\nimport { sendFileProvider } from './sendFile';\n/**\n * Registers all the common services on the container.\n *\n * - {@link AppError | appError}\n * - {@link HTTPError | httpError}\n * - {@link SendFile | sendFile}\n *\n * @example\n *\n * // Register the collection on the container\n * container.register(commonServicesProvider);\n * // Getting access to one the services instance\n * const sendFile = container.get<SendFile>('sendFile');\n *\n * @group Providers\n */\nexport const commonServicesProvider = providers({\n appErrorProvider,\n httpErrorProvider,\n sendFileProvider,\n});\n\nexport * from './appError';\nexport * from './httpError';\nexport * from './sendFile';\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/services/common/index.ts"],"sourcesContent":["import { providers } from '../../utils/index.js';\nimport { appErrorProvider } from './appError.js';\nimport { httpErrorProvider } from './httpError.js';\nimport { sendFileProvider } from './sendFile.js';\n/**\n * Registers all the common services on the container.\n *\n * - {@link AppError | appError}\n * - {@link HTTPError | httpError}\n * - {@link SendFile | sendFile}\n *\n * @example\n *\n * // Register the collection on the container\n * container.register(commonServicesProvider);\n * // Getting access to one the services instance\n * const sendFile = container.get<SendFile>('sendFile');\n *\n * @group Providers\n */\nexport const commonServicesProvider = providers({\n appErrorProvider,\n httpErrorProvider,\n sendFileProvider,\n});\n\nexport * from './appError.js';\nexport * from './httpError.js';\nexport * from './sendFile.js';\n"],"mappings":"AAAA,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AAiB1B,MAAM,yBAAyB,UAAU;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-BlSpNHox.js';
|
|
3
3
|
import { Response, NextFunction } from 'express';
|
|
4
4
|
import { PathUtils } from '@homer0/path-utils';
|
|
5
5
|
import '../../types/express.js';
|
|
@@ -1,28 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var sendFile_exports = {};
|
|
20
|
-
__export(sendFile_exports, {
|
|
21
|
-
sendFile: () => sendFile,
|
|
22
|
-
sendFileProvider: () => sendFileProvider
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(sendFile_exports);
|
|
25
|
-
var import_utils = require("../../utils");
|
|
1
|
+
import { provider } from "../../utils/index.js";
|
|
26
2
|
const sendFile = ({ inject: { pathUtils } }) => ({ res, filepath, from = "app", next = () => {
|
|
27
3
|
} }) => {
|
|
28
4
|
res.sendFile(pathUtils.joinFrom(from, filepath), (error) => {
|
|
@@ -33,7 +9,7 @@ const sendFile = ({ inject: { pathUtils } }) => ({ res, filepath, from = "app",
|
|
|
33
9
|
}
|
|
34
10
|
});
|
|
35
11
|
};
|
|
36
|
-
const sendFileProvider =
|
|
12
|
+
const sendFileProvider = provider((app) => {
|
|
37
13
|
app.set(
|
|
38
14
|
"sendFile",
|
|
39
15
|
() => sendFile({
|
|
@@ -43,9 +19,8 @@ const sendFileProvider = (0, import_utils.provider)((app) => {
|
|
|
43
19
|
})
|
|
44
20
|
);
|
|
45
21
|
});
|
|
46
|
-
|
|
47
|
-
0 && (module.exports = {
|
|
22
|
+
export {
|
|
48
23
|
sendFile,
|
|
49
24
|
sendFileProvider
|
|
50
|
-
}
|
|
25
|
+
};
|
|
51
26
|
//# sourceMappingURL=sendFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/common/sendFile.ts"],"sourcesContent":["import { provider } from '../../utils';\nimport type { Response, NextFunction, PathUtils } from '../../types';\n/**\n * The options to create a {@link SendFile} function.\n *\n * @group Services/SendFile\n */\nexport type SendFileGeneratorOptions = {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n pathUtils: PathUtils;\n };\n};\n/**\n * The options for the function that actually serves a file.\n *\n * @group Services/SendFile\n */\nexport type SendFileOptions = {\n /**\n * The response object sent by the application. Necessary to write the file.\n */\n res: Response;\n /**\n * The path of the file to serve. Depending on the `from` option, it will be either\n * relative to the project root, or the application executable.\n */\n filepath: string;\n /**\n * The name of a location on the `pathUtils` service from where the `filepath` is\n * relative to. It can be `app` for the directory containing the application executable,\n * or `project` for the project root. It could also be any other location that the\n * implementation may have registered.\n *\n * @default 'app'\n */\n from?: string;\n /**\n * The function to move to the next middleware. It can be used to report an error in\n * case the file can't be served.\n *\n * @default {() => {}}\n */\n next?: NextFunction;\n};\n/**\n * The type of the function that serves a file.\n * This is exported to make it easy to type the dependency injection.\n *\n * @group Services/SendFile\n */\nexport type SendFile = (options: SendFileOptions) => void;\n/**\n * Generates a function to send files on the application response.\n *\n * @param options To inject the required dependencies.\n * @example\n *\n * <caption>Basic usage</caption>\n *\n * // Let's say this is inside an Express middleware.\n * // Get the function\n * const send = sendFile(pathUtils);\n * send({ res, filepath: 'some-file.html', next });\n * // If your app is on \"/app/index.js\", this will send \"/app/some-file.html\".\n *\n * @group Services\n * @group Services/SendFile\n */\nexport const sendFile =\n ({ inject: { pathUtils } }: SendFileGeneratorOptions): SendFile =>\n ({ res, filepath, from = 'app', next = () => {} }) => {\n res.sendFile(pathUtils.joinFrom(from, filepath), (error) => {\n if (error) {\n next(error);\n } else {\n res.end();\n }\n });\n };\n\n/**\n * The service provider that once registered on the container will set the result of\n * {@link sendFile} as the `sendFile` service.\n *\n * @example\n *\n * // Register it on the container\n * container.register(sendFileProvider);\n * // Getting access to the service instance\n * const sendFile = container.get<SendFile>('sendFile');\n *\n * @group Providers\n * @group Services/SendFile\n */\nexport const sendFileProvider = provider((app) => {\n app.set('sendFile', () =>\n sendFile({\n inject: {\n pathUtils: app.get('pathUtils'),\n },\n }),\n );\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/services/common/sendFile.ts"],"sourcesContent":["import { provider } from '../../utils/index.js';\nimport type { Response, NextFunction, PathUtils } from '../../types/index.js';\n/**\n * The options to create a {@link SendFile} function.\n *\n * @group Services/SendFile\n */\nexport type SendFileGeneratorOptions = {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n pathUtils: PathUtils;\n };\n};\n/**\n * The options for the function that actually serves a file.\n *\n * @group Services/SendFile\n */\nexport type SendFileOptions = {\n /**\n * The response object sent by the application. Necessary to write the file.\n */\n res: Response;\n /**\n * The path of the file to serve. Depending on the `from` option, it will be either\n * relative to the project root, or the application executable.\n */\n filepath: string;\n /**\n * The name of a location on the `pathUtils` service from where the `filepath` is\n * relative to. It can be `app` for the directory containing the application executable,\n * or `project` for the project root. It could also be any other location that the\n * implementation may have registered.\n *\n * @default 'app'\n */\n from?: string;\n /**\n * The function to move to the next middleware. It can be used to report an error in\n * case the file can't be served.\n *\n * @default {() => {}}\n */\n next?: NextFunction;\n};\n/**\n * The type of the function that serves a file.\n * This is exported to make it easy to type the dependency injection.\n *\n * @group Services/SendFile\n */\nexport type SendFile = (options: SendFileOptions) => void;\n/**\n * Generates a function to send files on the application response.\n *\n * @param options To inject the required dependencies.\n * @example\n *\n * <caption>Basic usage</caption>\n *\n * // Let's say this is inside an Express middleware.\n * // Get the function\n * const send = sendFile(pathUtils);\n * send({ res, filepath: 'some-file.html', next });\n * // If your app is on \"/app/index.js\", this will send \"/app/some-file.html\".\n *\n * @group Services\n * @group Services/SendFile\n */\nexport const sendFile =\n ({ inject: { pathUtils } }: SendFileGeneratorOptions): SendFile =>\n ({ res, filepath, from = 'app', next = () => {} }) => {\n res.sendFile(pathUtils.joinFrom(from, filepath), (error) => {\n if (error) {\n next(error);\n } else {\n res.end();\n }\n });\n };\n\n/**\n * The service provider that once registered on the container will set the result of\n * {@link sendFile} as the `sendFile` service.\n *\n * @example\n *\n * // Register it on the container\n * container.register(sendFileProvider);\n * // Getting access to the service instance\n * const sendFile = container.get<SendFile>('sendFile');\n *\n * @group Providers\n * @group Services/SendFile\n */\nexport const sendFileProvider = provider((app) => {\n app.set('sendFile', () =>\n sendFile({\n inject: {\n pathUtils: app.get('pathUtils'),\n },\n }),\n );\n});\n"],"mappings":"AAAA,SAAS,gBAAgB;AAuElB,MAAM,WACX,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,MACzB,CAAC,EAAE,KAAK,UAAU,OAAO,OAAO,OAAO,MAAM;AAAC,EAAE,MAAM;AACpD,MAAI,SAAS,UAAU,SAAS,MAAM,QAAQ,GAAG,CAAC,UAAU;AAC1D,QAAI,OAAO;AACT,WAAK,KAAK;AAAA,IACZ,OAAO;AACL,UAAI,IAAI;AAAA,IACV;AAAA,EACF,CAAC;AACH;AAgBK,MAAM,mBAAmB,SAAS,CAAC,QAAQ;AAChD,MAAI;AAAA,IAAI;AAAA,IAAY,MAClB,SAAS;AAAA,MACP,QAAQ;AAAA,QACN,WAAW,IAAI,IAAI,WAAW;AAAA,MAChC;AAAA,IACF,CAAC;AAAA,EACH;AACF,CAAC;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-BlSpNHox.js';
|
|
3
3
|
import { PathUtils } from '@homer0/path-utils';
|
|
4
|
-
import fs from 'fs/promises';
|
|
4
|
+
import fs from 'node:fs/promises';
|
|
5
5
|
import '../../types/express.js';
|
|
6
6
|
import 'express';
|
|
7
7
|
import '../../types/http.js';
|
|
@@ -1,50 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
31
|
-
var frontendFs_exports = {};
|
|
32
|
-
__export(frontendFs_exports, {
|
|
33
|
-
FrontendFs: () => FrontendFs,
|
|
34
|
-
frontendFsProvider: () => frontendFsProvider
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(frontendFs_exports);
|
|
37
|
-
var import_promises = __toESM(require("fs/promises"));
|
|
38
|
-
var import_utils = require("../../utils");
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import { provider } from "../../utils/index.js";
|
|
39
3
|
class FrontendFs {
|
|
4
|
+
/**
|
|
5
|
+
* The service that generates the relative paths.
|
|
6
|
+
*/
|
|
7
|
+
_pathUtils;
|
|
40
8
|
/**
|
|
41
9
|
* @param options The options to construct the service.
|
|
42
10
|
*/
|
|
43
11
|
constructor({ inject: { pathUtils } }) {
|
|
44
|
-
/**
|
|
45
|
-
* The service that generates the relative paths.
|
|
46
|
-
*/
|
|
47
|
-
__publicField(this, "_pathUtils");
|
|
48
12
|
this._pathUtils = pathUtils;
|
|
49
13
|
}
|
|
50
14
|
/**
|
|
@@ -53,7 +17,7 @@ class FrontendFs {
|
|
|
53
17
|
* @param filepath The path to the file.
|
|
54
18
|
*/
|
|
55
19
|
delete(filepath) {
|
|
56
|
-
return
|
|
20
|
+
return fs.unlink(this.getAppPath(filepath));
|
|
57
21
|
}
|
|
58
22
|
/**
|
|
59
23
|
* Reads a file from the file system.
|
|
@@ -62,7 +26,7 @@ class FrontendFs {
|
|
|
62
26
|
* @param encoding The text encoding in which the file should be read.
|
|
63
27
|
*/
|
|
64
28
|
read(filepath, encoding = "utf-8") {
|
|
65
|
-
return
|
|
29
|
+
return fs.readFile(this.getAppPath(filepath), encoding);
|
|
66
30
|
}
|
|
67
31
|
/**
|
|
68
32
|
* Writes a file on the file system.
|
|
@@ -71,7 +35,7 @@ class FrontendFs {
|
|
|
71
35
|
* @param content The contents of the file.
|
|
72
36
|
*/
|
|
73
37
|
write(filepath, content) {
|
|
74
|
-
return
|
|
38
|
+
return fs.writeFile(this.getAppPath(filepath), content);
|
|
75
39
|
}
|
|
76
40
|
/**
|
|
77
41
|
* Utility method to get the path of a file relative to the application executable.
|
|
@@ -82,7 +46,7 @@ class FrontendFs {
|
|
|
82
46
|
return this._pathUtils.joinFrom("app", filepath);
|
|
83
47
|
}
|
|
84
48
|
}
|
|
85
|
-
const frontendFsProvider =
|
|
49
|
+
const frontendFsProvider = provider((app) => {
|
|
86
50
|
app.set(
|
|
87
51
|
"frontendFs",
|
|
88
52
|
() => new FrontendFs({
|
|
@@ -92,9 +56,8 @@ const frontendFsProvider = (0, import_utils.provider)((app) => {
|
|
|
92
56
|
})
|
|
93
57
|
);
|
|
94
58
|
});
|
|
95
|
-
|
|
96
|
-
0 && (module.exports = {
|
|
59
|
+
export {
|
|
97
60
|
FrontendFs,
|
|
98
61
|
frontendFsProvider
|
|
99
|
-
}
|
|
62
|
+
};
|
|
100
63
|
//# sourceMappingURL=frontendFs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/frontend/frontendFs.ts"],"sourcesContent":["import fs from 'fs/promises';\nimport { provider } from '../../utils';\nimport type { PathUtils } from '../../types';\n/**\n * The options to construct a {@link FrontendFs}.\n *\n * @group Services/FrontendFs\n */\nexport type FrontendFsOptions = {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n pathUtils: PathUtils;\n };\n};\n/**\n * This service allows the application to easily work with the filesystem. The idea behind\n * centralizing this functionalities into a service is that is pretty common to have\n * bundling tools to generate the frontend, and on that process files can have different\n * paths or not even be generated all. The service can be extended/overwritten to\n * accommodate any requirements and avoid having to update or add `if`s to every `fs` call\n * the application does.\n * Another _'feature'_ of this service is that all the paths are relative to the directory\n * where the app executable is located, so you don't have to remember the relative path\n * from the place you are accessing a file to the place where it's located.\n *\n * @group Services\n * @group Services/FrontendFs\n */\nexport class FrontendFs {\n /**\n * The service that generates the relative paths.\n */\n protected readonly _pathUtils: PathUtils;\n /**\n * @param options The options to construct the service.\n */\n constructor({ inject: { pathUtils } }: FrontendFsOptions) {\n this._pathUtils = pathUtils;\n }\n /**\n * Deletes a file from the file system.\n *\n * @param filepath The path to the file.\n */\n delete(filepath: string): Promise<void> {\n return fs.unlink(this.getAppPath(filepath));\n }\n /**\n * Reads a file from the file system.\n *\n * @param filepath The path to the file.\n * @param encoding The text encoding in which the file should be read.\n */\n read(filepath: string, encoding: BufferEncoding = 'utf-8'): Promise<string> {\n return fs.readFile(this.getAppPath(filepath), encoding);\n }\n /**\n * Writes a file on the file system.\n *\n * @param filepath The path to the file.\n * @param content The contents of the file.\n */\n write(filepath: string, content: Parameters<typeof fs.writeFile>[1]): Promise<void> {\n return fs.writeFile(this.getAppPath(filepath), content);\n }\n /**\n * Utility method to get the path of a file relative to the application executable.\n *\n * @param filepath The path to the file.\n */\n protected getAppPath(filepath: string): string {\n return this._pathUtils.joinFrom('app', filepath);\n }\n}\n/**\n * The service provider that once registered on the container will set an instance of\n * {@link FrontendFs} as the `frontendFs` service.\n *\n * @example\n *\n * // Register it on the container\n * container.register(frontendFsProvider);\n * // Getting access to the service instance\n * const frontendFs = container.get<FrontendFs>('frontendFs');\n *\n * @group Providers\n * @group Services/FrontendFs\n */\nexport const frontendFsProvider = provider((app) => {\n app.set(\n 'frontendFs',\n () =>\n new FrontendFs({\n inject: {\n pathUtils: app.get<PathUtils>('pathUtils'),\n },\n }),\n );\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/services/frontend/frontendFs.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport { provider } from '../../utils/index.js';\nimport type { PathUtils } from '../../types/index.js';\n/**\n * The options to construct a {@link FrontendFs}.\n *\n * @group Services/FrontendFs\n */\nexport type FrontendFsOptions = {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n pathUtils: PathUtils;\n };\n};\n/**\n * This service allows the application to easily work with the filesystem. The idea behind\n * centralizing this functionalities into a service is that is pretty common to have\n * bundling tools to generate the frontend, and on that process files can have different\n * paths or not even be generated all. The service can be extended/overwritten to\n * accommodate any requirements and avoid having to update or add `if`s to every `fs` call\n * the application does.\n * Another _'feature'_ of this service is that all the paths are relative to the directory\n * where the app executable is located, so you don't have to remember the relative path\n * from the place you are accessing a file to the place where it's located.\n *\n * @group Services\n * @group Services/FrontendFs\n */\nexport class FrontendFs {\n /**\n * The service that generates the relative paths.\n */\n protected readonly _pathUtils: PathUtils;\n /**\n * @param options The options to construct the service.\n */\n constructor({ inject: { pathUtils } }: FrontendFsOptions) {\n this._pathUtils = pathUtils;\n }\n /**\n * Deletes a file from the file system.\n *\n * @param filepath The path to the file.\n */\n delete(filepath: string): Promise<void> {\n return fs.unlink(this.getAppPath(filepath));\n }\n /**\n * Reads a file from the file system.\n *\n * @param filepath The path to the file.\n * @param encoding The text encoding in which the file should be read.\n */\n read(filepath: string, encoding: BufferEncoding = 'utf-8'): Promise<string> {\n return fs.readFile(this.getAppPath(filepath), encoding);\n }\n /**\n * Writes a file on the file system.\n *\n * @param filepath The path to the file.\n * @param content The contents of the file.\n */\n write(filepath: string, content: Parameters<typeof fs.writeFile>[1]): Promise<void> {\n return fs.writeFile(this.getAppPath(filepath), content);\n }\n /**\n * Utility method to get the path of a file relative to the application executable.\n *\n * @param filepath The path to the file.\n */\n protected getAppPath(filepath: string): string {\n return this._pathUtils.joinFrom('app', filepath);\n }\n}\n/**\n * The service provider that once registered on the container will set an instance of\n * {@link FrontendFs} as the `frontendFs` service.\n *\n * @example\n *\n * // Register it on the container\n * container.register(frontendFsProvider);\n * // Getting access to the service instance\n * const frontendFs = container.get<FrontendFs>('frontendFs');\n *\n * @group Providers\n * @group Services/FrontendFs\n */\nexport const frontendFsProvider = provider((app) => {\n app.set(\n 'frontendFs',\n () =>\n new FrontendFs({\n inject: {\n pathUtils: app.get<PathUtils>('pathUtils'),\n },\n }),\n );\n});\n"],"mappings":"AAAA,OAAO,QAAQ;AACf,SAAS,gBAAgB;AA6BlB,MAAM,WAAW;AAAA;AAAA;AAAA;AAAA,EAIH;AAAA;AAAA;AAAA;AAAA,EAInB,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAsB;AACxD,SAAK,aAAa;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,UAAiC;AACtC,WAAO,GAAG,OAAO,KAAK,WAAW,QAAQ,CAAC;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,KAAK,UAAkB,WAA2B,SAA0B;AAC1E,WAAO,GAAG,SAAS,KAAK,WAAW,QAAQ,GAAG,QAAQ;AAAA,EACxD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,UAAkB,SAA4D;AAClF,WAAO,GAAG,UAAU,KAAK,WAAW,QAAQ,GAAG,OAAO;AAAA,EACxD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMU,WAAW,UAA0B;AAC7C,WAAO,KAAK,WAAW,SAAS,OAAO,QAAQ;AAAA,EACjD;AACF;AAeO,MAAM,qBAAqB,SAAS,CAAC,QAAQ;AAClD,MAAI;AAAA,IACF;AAAA,IACA,MACE,IAAI,WAAW;AAAA,MACb,QAAQ;AAAA,QACN,WAAW,IAAI,IAAe,WAAW;AAAA,MAC3C;AAAA,IACF,CAAC;AAAA,EACL;AACF,CAAC;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-BlSpNHox.js';
|
|
3
3
|
export { FrontendFs, FrontendFsOptions, frontendFsProvider } from './frontendFs.js';
|
|
4
4
|
import '../../types/express.js';
|
|
5
5
|
import 'express';
|
|
@@ -13,7 +13,7 @@ import '@homer0/path-utils';
|
|
|
13
13
|
import '@homer0/simple-logger';
|
|
14
14
|
import '@homer0/simple-config';
|
|
15
15
|
import '@homer0/events-hub';
|
|
16
|
-
import 'fs/promises';
|
|
16
|
+
import 'node:fs/promises';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Registers all the frontend services on the container.
|
|
@@ -1,36 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var frontend_exports = {};
|
|
21
|
-
__export(frontend_exports, {
|
|
22
|
-
frontendServicesProvider: () => frontendServicesProvider
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(frontend_exports);
|
|
25
|
-
var import_utils = require("../../utils");
|
|
26
|
-
var import_frontendFs = require("./frontendFs");
|
|
27
|
-
__reExport(frontend_exports, require("./frontendFs"), module.exports);
|
|
28
|
-
const frontendServicesProvider = (0, import_utils.providers)({
|
|
29
|
-
frontendFsProvider: import_frontendFs.frontendFsProvider
|
|
30
|
-
});
|
|
31
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
-
0 && (module.exports = {
|
|
33
|
-
frontendServicesProvider,
|
|
34
|
-
...require("./frontendFs")
|
|
1
|
+
import { providers } from "../../utils/index.js";
|
|
2
|
+
import { frontendFsProvider } from "./frontendFs.js";
|
|
3
|
+
const frontendServicesProvider = providers({
|
|
4
|
+
frontendFsProvider
|
|
35
5
|
});
|
|
6
|
+
export * from "./frontendFs.js";
|
|
7
|
+
export {
|
|
8
|
+
frontendServicesProvider
|
|
9
|
+
};
|
|
36
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/frontend/index.ts"],"sourcesContent":["import { providers } from '../../utils';\nimport { frontendFsProvider } from './frontendFs';\n/**\n * Registers all the frontend services on the container.\n *\n * - {@link FrontendFs | frontendFs}\n *\n * @example\n *\n * // Register the collection on the container\n * container.register(frontendServicesProvider);\n * // Getting access to one the services instance\n * const frontendFs = container.get<FrontendFs>('frontendFs');\n *\n * @group Providers\n */\nexport const frontendServicesProvider = providers({\n frontendFsProvider,\n});\n\nexport * from './frontendFs';\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/services/frontend/index.ts"],"sourcesContent":["import { providers } from '../../utils/index.js';\nimport { frontendFsProvider } from './frontendFs.js';\n/**\n * Registers all the frontend services on the container.\n *\n * - {@link FrontendFs | frontendFs}\n *\n * @example\n *\n * // Register the collection on the container\n * container.register(frontendServicesProvider);\n * // Getting access to one the services instance\n * const frontendFs = container.get<FrontendFs>('frontendFs');\n *\n * @group Providers\n */\nexport const frontendServicesProvider = providers({\n frontendFsProvider,\n});\n\nexport * from './frontendFs.js';\n"],"mappings":"AAAA,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AAe5B,MAAM,2BAA2B,UAAU;AAAA,EAChD;AACF,CAAC;AAED,cAAc;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-BlSpNHox.js';
|
|
3
3
|
import { SimpleLogger } from '@homer0/simple-logger';
|
|
4
4
|
import { SimpleConfig } from '@homer0/simple-config';
|
|
5
5
|
import { FrontendFs } from '../frontend/frontendFs.js';
|
|
@@ -14,7 +14,7 @@ import 'node-fetch';
|
|
|
14
14
|
import '../../types/utils.js';
|
|
15
15
|
import '@homer0/path-utils';
|
|
16
16
|
import '@homer0/events-hub';
|
|
17
|
-
import 'fs/promises';
|
|
17
|
+
import 'node:fs/promises';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* The options to customize a {@link HTMLGenerator} instance.
|
|
@@ -41,7 +41,7 @@ type HTMLGeneratorOptions = {
|
|
|
41
41
|
*/
|
|
42
42
|
silent: boolean;
|
|
43
43
|
/**
|
|
44
|
-
* Whether or not to delete the
|
|
44
|
+
* Whether or not to delete the template after generating the file.
|
|
45
45
|
*
|
|
46
46
|
* @default true
|
|
47
47
|
*/
|
|
@@ -49,7 +49,7 @@ type HTMLGeneratorOptions = {
|
|
|
49
49
|
/**
|
|
50
50
|
* The placeholder string where the information will be written.
|
|
51
51
|
*
|
|
52
|
-
* @default /\{\{
|
|
52
|
+
* @default /\{\{appConfig(?:uration)?\}\}/
|
|
53
53
|
*/
|
|
54
54
|
replacePlaceholder: string | RegExp;
|
|
55
55
|
/**
|
|
@@ -165,7 +165,7 @@ declare class HTMLGenerator {
|
|
|
165
165
|
protected _fileReady: boolean;
|
|
166
166
|
/**
|
|
167
167
|
* A deferred promise to return when another service asks if the file has been
|
|
168
|
-
* generated. Once this
|
|
168
|
+
* generated. Once this service finishes generating the file, the promise will be
|
|
169
169
|
* resolved for all implementations that hold a reference to this deferred.
|
|
170
170
|
*/
|
|
171
171
|
protected _fileDeferred?: DeferredPromise<void>;
|