@midwayjs/static-file 3.5.3 → 3.7.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/dist/configuration.js
CHANGED
|
@@ -10,9 +10,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.StaticFileConfiguration = void 0;
|
|
13
|
-
const decorator_1 = require("@midwayjs/decorator");
|
|
14
|
-
const static_middleware_1 = require("./middleware/static.middleware");
|
|
15
13
|
const core_1 = require("@midwayjs/core");
|
|
14
|
+
const static_middleware_1 = require("./middleware/static.middleware");
|
|
16
15
|
const DefaultConfig = require("./config/config.default");
|
|
17
16
|
let StaticFileConfiguration = class StaticFileConfiguration {
|
|
18
17
|
async onConfigLoad() {
|
|
@@ -33,11 +32,11 @@ let StaticFileConfiguration = class StaticFileConfiguration {
|
|
|
33
32
|
}
|
|
34
33
|
};
|
|
35
34
|
__decorate([
|
|
36
|
-
(0,
|
|
35
|
+
(0, core_1.Inject)(),
|
|
37
36
|
__metadata("design:type", core_1.MidwayApplicationManager)
|
|
38
37
|
], StaticFileConfiguration.prototype, "applicationManager", void 0);
|
|
39
38
|
StaticFileConfiguration = __decorate([
|
|
40
|
-
(0,
|
|
39
|
+
(0, core_1.Configuration)({
|
|
41
40
|
namespace: 'info',
|
|
42
41
|
importConfigs: [
|
|
43
42
|
{
|
|
@@ -10,7 +10,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.StaticMiddleware = void 0;
|
|
13
|
-
const decorator_1 = require("@midwayjs/decorator");
|
|
14
13
|
const core_1 = require("@midwayjs/core");
|
|
15
14
|
const assert = require("assert");
|
|
16
15
|
const staticCache = require("koa-static-cache");
|
|
@@ -34,7 +33,7 @@ let StaticMiddleware = class StaticMiddleware {
|
|
|
34
33
|
}
|
|
35
34
|
const middlewares = [rangeMiddleware];
|
|
36
35
|
for (const dirObj of dirs) {
|
|
37
|
-
assert(
|
|
36
|
+
assert(core_1.Types.isObject(dirObj) || core_1.Types.isString(dirObj), '`config.static.dir` must be `string | Array<string|object>`.');
|
|
38
37
|
const newOptions = Object.assign({}, this.staticFileConfig, dirObj);
|
|
39
38
|
if (newOptions.dynamic && !newOptions.files) {
|
|
40
39
|
newOptions.files = new LRU(newOptions.maxFiles);
|
|
@@ -43,7 +42,7 @@ let StaticMiddleware = class StaticMiddleware {
|
|
|
43
42
|
prefixs.push(newOptions.prefix);
|
|
44
43
|
}
|
|
45
44
|
// ensure directory exists
|
|
46
|
-
if (!(await
|
|
45
|
+
if (!(await core_1.FileUtils.exists(newOptions.dir))) {
|
|
47
46
|
throw new error_1.DirectoryNotFoundError(newOptions.dir);
|
|
48
47
|
}
|
|
49
48
|
this.logger.info('[midway:static] starting static serve %s -> %s', newOptions.prefix, newOptions.dir);
|
|
@@ -56,19 +55,19 @@ let StaticMiddleware = class StaticMiddleware {
|
|
|
56
55
|
}
|
|
57
56
|
};
|
|
58
57
|
__decorate([
|
|
59
|
-
(0,
|
|
58
|
+
(0, core_1.Config)('staticFile'),
|
|
60
59
|
__metadata("design:type", Object)
|
|
61
60
|
], StaticMiddleware.prototype, "staticFileConfig", void 0);
|
|
62
61
|
__decorate([
|
|
63
|
-
(0,
|
|
62
|
+
(0, core_1.Inject)(),
|
|
64
63
|
__metadata("design:type", core_1.MidwayMiddlewareService)
|
|
65
64
|
], StaticMiddleware.prototype, "middlewareService", void 0);
|
|
66
65
|
__decorate([
|
|
67
|
-
(0,
|
|
66
|
+
(0, core_1.Logger)('coreLogger'),
|
|
68
67
|
__metadata("design:type", Object)
|
|
69
68
|
], StaticMiddleware.prototype, "logger", void 0);
|
|
70
69
|
StaticMiddleware = __decorate([
|
|
71
|
-
(0,
|
|
70
|
+
(0, core_1.Middleware)()
|
|
72
71
|
], StaticMiddleware);
|
|
73
72
|
exports.StaticMiddleware = StaticMiddleware;
|
|
74
73
|
//# sourceMappingURL=static.middleware.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/static-file",
|
|
3
3
|
"description": "midway static file component",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.7.0",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -15,12 +15,11 @@
|
|
|
15
15
|
"ylru": "1.3.2"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@midwayjs/core": "^3.
|
|
19
|
-
"@midwayjs/
|
|
20
|
-
"@midwayjs/
|
|
21
|
-
"@midwayjs/
|
|
22
|
-
"@midwayjs/
|
|
23
|
-
"@midwayjs/serverless-app": "^3.5.3"
|
|
18
|
+
"@midwayjs/core": "^3.7.0",
|
|
19
|
+
"@midwayjs/faas": "^3.7.0",
|
|
20
|
+
"@midwayjs/koa": "^3.7.0",
|
|
21
|
+
"@midwayjs/mock": "^3.7.0",
|
|
22
|
+
"@midwayjs/serverless-app": "^3.7.0"
|
|
24
23
|
},
|
|
25
24
|
"keywords": [
|
|
26
25
|
"midway",
|
|
@@ -44,5 +43,5 @@
|
|
|
44
43
|
"type": "git",
|
|
45
44
|
"url": "https://github.com/midwayjs/midway.git"
|
|
46
45
|
},
|
|
47
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "99386083ee26b386fd508b9c892091c914e77535"
|
|
48
47
|
}
|