yakuza0 2.20.0 → 2.20.4
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/config/paths.js +11 -1
- package/nuxt/build/index.js +94 -49
- package/nuxt/dir.js +4 -0
- package/package.json +3 -2
- package/server/cache/control.js +10 -0
- package/server/proxy/conf.js +2 -1
- package/server/proxy/tire.js +125 -69
- package/template/tfs.plugin.js +1 -1
- package/utils/curl.js +4 -2
- package/utils/inclusive.js +9 -2
package/config/paths.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.chmod = exports.write = exports.read = exports.mkdir = exports.access = undefined;
|
|
6
|
+
exports.chmod = exports.rm = exports.write = exports.read = exports.mkdir = exports.access = undefined;
|
|
7
7
|
|
|
8
8
|
var _extends2 = require('babel-runtime/helpers/extends');
|
|
9
9
|
|
|
@@ -50,6 +50,15 @@ var write = exports.write = function write(path, str) {
|
|
|
50
50
|
} catch (e) {}
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
var rm = exports.rm = function rm(path) {
|
|
54
|
+
try {
|
|
55
|
+
fs.rmSync(path);
|
|
56
|
+
} catch (e) {}
|
|
57
|
+
try {
|
|
58
|
+
fs.rmdirSync(path);
|
|
59
|
+
} catch (e) {}
|
|
60
|
+
};
|
|
61
|
+
|
|
53
62
|
var chmod = exports.chmod = function chmod(path, mode) {
|
|
54
63
|
try {
|
|
55
64
|
fs.chmodSync(path, mode);
|
|
@@ -122,6 +131,7 @@ exports.default = {
|
|
|
122
131
|
mkdir: mkdir,
|
|
123
132
|
read: read,
|
|
124
133
|
write: write,
|
|
134
|
+
rm: rm,
|
|
125
135
|
chmod: chmod,
|
|
126
136
|
path: path,
|
|
127
137
|
root: root,
|
package/nuxt/build/index.js
CHANGED
|
@@ -60,53 +60,14 @@ _yakuza.global.NUXT_BUILD_FILENAME_INDEX = 0;
|
|
|
60
60
|
|
|
61
61
|
exports.default = function (config) {
|
|
62
62
|
var nuxtConf = _config2.default.nuxt;
|
|
63
|
-
var
|
|
63
|
+
var appConf = config.appConf;
|
|
64
|
+
var extendFn = function extendFn(conf, ctx) {};
|
|
65
|
+
|
|
64
66
|
config.build = (0, _extends3.default)({}, config.build, {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
automaticNameDelimiter: '.',
|
|
70
|
-
name: true
|
|
71
|
-
// chunks: 'async',
|
|
72
|
-
// minSize: 30000,
|
|
73
|
-
// maxSize: 20000,
|
|
74
|
-
// minChunks: 1,
|
|
75
|
-
// maxAsyncRequests: 6,
|
|
76
|
-
// maxInitialRequests: 3,
|
|
77
|
-
// automaticNameDelimiter: '~',
|
|
78
|
-
// name: true,
|
|
79
|
-
// chunks: 'async',
|
|
80
|
-
// minSize: 20000,
|
|
81
|
-
// minRemainingSize: 0,
|
|
82
|
-
// minChunks: 1,
|
|
83
|
-
// maxAsyncRequests: 30,
|
|
84
|
-
// maxInitialRequests: 30,
|
|
85
|
-
// enforceSizeThreshold: 50000,
|
|
86
|
-
// cacheGroups: {
|
|
87
|
-
// defaultVendors: {
|
|
88
|
-
// test: /[\\/]node_modules[\\/]/,
|
|
89
|
-
// priority: -10,
|
|
90
|
-
// reuseExistingChunk: true,
|
|
91
|
-
// },
|
|
92
|
-
// default: {
|
|
93
|
-
// minChunks: 2,
|
|
94
|
-
// priority: -20,
|
|
95
|
-
// reuseExistingChunk: true,
|
|
96
|
-
// },
|
|
97
|
-
// },
|
|
98
|
-
}
|
|
99
|
-
// splitChunks: {
|
|
100
|
-
// chunks: 'all',
|
|
101
|
-
// automaticNameDelimiter: '.',
|
|
102
|
-
// name: 'test',
|
|
103
|
-
// maxSize : 100,
|
|
104
|
-
// }
|
|
105
|
-
},
|
|
106
|
-
extractCSS: {
|
|
107
|
-
ignoreOrder: true
|
|
108
|
-
},
|
|
109
|
-
// extractCSS:true,
|
|
67
|
+
// extractCSS: {
|
|
68
|
+
// ignoreOrder: false,
|
|
69
|
+
// },
|
|
70
|
+
// extractCSS: !yConf.dev,
|
|
110
71
|
corejs: _config2.default.resolve.babelConf.corejs,
|
|
111
72
|
transpile: [_yakuza._.regAnd(['@rdc', 'ant-design-vue']), _yakuza._.regAnd(['.cache', 'yakuza0', 'middleware']), 'nuxt', 'delay', 'node-fetch', 'data-uri-to-buffer', 'fetch-blob', 'quill-image-drop-module'].concat((0, _toConsumableArray3.default)(nuxtConf.build && nuxtConf.build.tsl || [])),
|
|
112
73
|
loaders: (0, _extends3.default)({}, config.build && config.build.loaders, {
|
|
@@ -115,6 +76,66 @@ exports.default = function (config) {
|
|
|
115
76
|
}, config.build && config.build.loaders && config.build.loaders.less)
|
|
116
77
|
})
|
|
117
78
|
});
|
|
79
|
+
|
|
80
|
+
// config.build.extractCSS = true;
|
|
81
|
+
if (!_config2.default.dev) {
|
|
82
|
+
config.build.extractCSS = {
|
|
83
|
+
ignoreOrder: false
|
|
84
|
+
};
|
|
85
|
+
// config.build.optimization = {
|
|
86
|
+
// splitChunks: {
|
|
87
|
+
// chunks: 'async',
|
|
88
|
+
// maxSize: 666 * 1024,
|
|
89
|
+
// automaticNameDelimiter: '.',
|
|
90
|
+
// name: true,
|
|
91
|
+
// // cacheGroups: {
|
|
92
|
+
// // styles: {
|
|
93
|
+
// // name: 'styles',
|
|
94
|
+
// // // test: /\.(css|vue)$/,
|
|
95
|
+
// // // test: /\.(css)$/,
|
|
96
|
+
// // test: /\.(vue)$/,
|
|
97
|
+
// // // test: /\.(css|pcss|postcss|styl|stylus|scss|sass|less)$/,
|
|
98
|
+
// // // chunks: 'all',
|
|
99
|
+
// // // enforce: true
|
|
100
|
+
// // }
|
|
101
|
+
// // }
|
|
102
|
+
// // chunks: 'async',
|
|
103
|
+
// // minSize: 30000,
|
|
104
|
+
// // maxSize: 20000,
|
|
105
|
+
// // minChunks: 1,
|
|
106
|
+
// // maxAsyncRequests: 6,
|
|
107
|
+
// // maxInitialRequests: 3,
|
|
108
|
+
// // automaticNameDelimiter: '~',
|
|
109
|
+
// // name: true,
|
|
110
|
+
// // chunks: 'async',
|
|
111
|
+
// // minSize: 20000,
|
|
112
|
+
// // minRemainingSize: 0,
|
|
113
|
+
// // minChunks: 1,
|
|
114
|
+
// // maxAsyncRequests: 30,
|
|
115
|
+
// // maxInitialRequests: 30,
|
|
116
|
+
// // enforceSizeThreshold: 50000,
|
|
117
|
+
// // cacheGroups: {
|
|
118
|
+
// // defaultVendors: {
|
|
119
|
+
// // test: /[\\/]node_modules[\\/]/,
|
|
120
|
+
// // priority: -10,
|
|
121
|
+
// // reuseExistingChunk: true,
|
|
122
|
+
// // },
|
|
123
|
+
// // default: {
|
|
124
|
+
// // minChunks: 2,
|
|
125
|
+
// // priority: -20,
|
|
126
|
+
// // reuseExistingChunk: true,
|
|
127
|
+
// // },
|
|
128
|
+
// // },
|
|
129
|
+
// },
|
|
130
|
+
// // splitChunks: {
|
|
131
|
+
// // chunks: 'all',
|
|
132
|
+
// // automaticNameDelimiter: '.',
|
|
133
|
+
// // name: 'test',
|
|
134
|
+
// // maxSize : 100,
|
|
135
|
+
// // }
|
|
136
|
+
// };
|
|
137
|
+
}
|
|
138
|
+
|
|
118
139
|
if (config.build && config.build.extend) {
|
|
119
140
|
extendFn = config.build.extend;
|
|
120
141
|
}
|
|
@@ -140,9 +161,31 @@ exports.default = function (config) {
|
|
|
140
161
|
// if (ctx && ctx.isClient) {
|
|
141
162
|
// conf.optimization.splitChunks.maxSize = parseInt((0.6 * 1024 * 1024), 10);
|
|
142
163
|
// }
|
|
143
|
-
if (ctx && ctx.isClient) {
|
|
144
|
-
|
|
145
|
-
}
|
|
164
|
+
// if (ctx && ctx.isClient) {
|
|
165
|
+
// conf.devtool = 'source-map'
|
|
166
|
+
// }
|
|
167
|
+
//
|
|
168
|
+
conf.module.rules.forEach(function (r) {
|
|
169
|
+
if (r.test.toString().indexOf("png|jpe?g|gif|svg|webp|avif") !== -1) {
|
|
170
|
+
if (r.use && r.use[0] && r.use[0].options && r.use[0].options.limit) {
|
|
171
|
+
r.use[0].options.limit = 2333;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// if (!appConf.server.openHmr) {
|
|
177
|
+
// const hmrIndex = conf.plugins.findIndex(p => {
|
|
178
|
+
// return p.constructor.name === 'HotModuleReplacementPlugin';
|
|
179
|
+
// });
|
|
180
|
+
//
|
|
181
|
+
// if (hmrIndex !== -1) {
|
|
182
|
+
// conf.plugins.splice(hmrIndex, 1)
|
|
183
|
+
// }
|
|
184
|
+
//
|
|
185
|
+
// conf.plugins.forEach(p => {
|
|
186
|
+
// console.log(p.constructor.name);
|
|
187
|
+
// });
|
|
188
|
+
// }
|
|
146
189
|
};
|
|
147
190
|
|
|
148
191
|
// config.build.vendor = ['babel-polyfill'];
|
|
@@ -172,6 +215,8 @@ exports.default = function (config) {
|
|
|
172
215
|
// cache: yConf.dev,
|
|
173
216
|
// hardSource: yConf.dev,
|
|
174
217
|
// parallel: true,
|
|
218
|
+
// cache: false,
|
|
219
|
+
// hardSource: false,
|
|
175
220
|
cache: _config2.default.dev,
|
|
176
221
|
hardSource: _config2.default.dev,
|
|
177
222
|
"html.minify": {
|
package/nuxt/dir.js
CHANGED
|
@@ -54,6 +54,10 @@ exports.default = function (config, key) {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
_paths2.default.mkdir(appCache);
|
|
57
|
+
// fix jimp-compact
|
|
58
|
+
// const jcp = rootDir + 'node_modules/jimp-compact';
|
|
59
|
+
// paths.rm(jcp);
|
|
60
|
+
// paths.mkdir(jcp);
|
|
57
61
|
|
|
58
62
|
_rimraf2.default.sync(rootDir + '.nuxt');
|
|
59
63
|
_rimraf2.default.sync(rootDir + 'dist');
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yakuza0",
|
|
3
|
-
"version": "2.20.
|
|
3
|
+
"version": "2.20.4",
|
|
4
4
|
"description": "yakuza0 with nuxt",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "babel --no-babelrc src -d . --presets=env --plugins=transform-runtime,transform-object-rest-spread,add-module-exports",
|
|
8
|
-
"pub:beta": "npm run build && npm version prerelease --preid=beta &&
|
|
8
|
+
"pub:beta": "npm run build && npm version prerelease --preid=beta && npm publish --tag beta",
|
|
9
9
|
"pub": "npm run build && npm version patch && npm publish",
|
|
10
10
|
"postinstall": "yk verify commit-init",
|
|
11
11
|
"test": "jest"
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"cli-progress": "^2.1.1",
|
|
46
46
|
"clipboardy": "^1.2.3",
|
|
47
47
|
"commander": "^2.19.0",
|
|
48
|
+
"compression": "^1.7.4",
|
|
48
49
|
"consola": "^2.10.1",
|
|
49
50
|
"core-js": "3.10.1",
|
|
50
51
|
"download": "^7.1.0",
|
package/server/cache/control.js
CHANGED
|
@@ -31,6 +31,8 @@ exports.default = function (defaults) {
|
|
|
31
31
|
cacheControl = [];
|
|
32
32
|
include = options.include || [];
|
|
33
33
|
exclude = options.exclude || [];
|
|
34
|
+
// const excludeType = options.excludeType || [];
|
|
35
|
+
|
|
34
36
|
isInclude = false;
|
|
35
37
|
isExclude = false;
|
|
36
38
|
|
|
@@ -47,6 +49,14 @@ exports.default = function (defaults) {
|
|
|
47
49
|
}
|
|
48
50
|
});
|
|
49
51
|
|
|
52
|
+
// const isExcludeType = excludeType.includes((ctx.get['content-type'] || '').toLowerCase())
|
|
53
|
+
// console.log(ctx.url, isExcludeType, ctx.response.header, 11111);
|
|
54
|
+
// excludeType.forEach(fm => {
|
|
55
|
+
// if (minimatch(ctx.path, fm)) {
|
|
56
|
+
// isExclude = true;
|
|
57
|
+
// }
|
|
58
|
+
// })
|
|
59
|
+
|
|
50
60
|
if (isExclude) {
|
|
51
61
|
noCache(ctx);
|
|
52
62
|
}
|
package/server/proxy/conf.js
CHANGED
|
@@ -160,5 +160,6 @@ var serverHeaders = exports.serverHeaders = function serverHeaders(_ref4) {
|
|
|
160
160
|
// console.log(variable.appNameHeader, req.crossParams.nuxtAppName, 111);
|
|
161
161
|
// console.log(crossParams.nuxtAppName);
|
|
162
162
|
// console.log(nuxtAppConf);
|
|
163
|
-
|
|
163
|
+
// console.log(nuxtAppConf.server.gray, 123);
|
|
164
|
+
return _ref5 = {}, (0, _defineProperty3.default)(_ref5, _def.variable.isDevHeader, { data: conf.dev ? '1' : '0' }), (0, _defineProperty3.default)(_ref5, _def.variable.akHeader, { data: conf.ak, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.ipHeader, { data: (0, _server.getClientIP)(req, { stupid: false }) }), (0, _defineProperty3.default)(_ref5, _def.variable.adjoinIpHeader, { data: (0, _server.getClientIP)(req, { stupid: true }) }), (0, _defineProperty3.default)(_ref5, _def.variable.svcKeyHeader, { data: nuxtAppConf.svcKey, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.domainHeader, { data: nuxtAppConf.domain, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.cookieHeader, { data: crossParams.cookie, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.cookieDomainHeader, { data: crossParams.cookieDomain, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.cookieSameSiteHeader, { data: conf.server.cookieSameSite, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.appKeyHeader, { data: crossParams.nuxtAppKey }), (0, _defineProperty3.default)(_ref5, _def.variable.appNameHeader, { data: crossParams.nuxtAppName }), (0, _defineProperty3.default)(_ref5, _def.variable.encryptSwitchHeader, { data: encryptSwitch, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.encryptTypeHeader, { data: conf.security.encrypt, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.helmetHeader, { data: conf.security.helmet.toString(), noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.projectNameHeader, { data: conf.name, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.shareRuleHeader, { data: (0, _stringify2.default)(conf.shareRule) }), (0, _defineProperty3.default)(_ref5, _def.variable.baseURLHeader, { data: baseURL, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.isHttpsHeader, { data: conf.https ? '1' : '0' }), (0, _defineProperty3.default)(_ref5, _def.variable.appCodeHeader, { data: nuxtAppConf.appCode, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.processKeyHeader, { data: conf.processKey, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.childKeyHeader, { data: conf.childKey, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.orbCsrfHeader, { data: verifyTk.csrf, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.f5OfflineHeader, { data: nuxtAppConf.server && nuxtAppConf.server.f5Offline, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.servicesHeader, { data: req.headers[_def.variable.servicesHeader], noWarn: true }), (0, _defineProperty3.default)(_ref5, 'Cookie', { data: _server.Cookies.setByStr((0, _defineProperty3.default)({}, _def.variable.orbCsrfCookie, verifyTk.csrf), req.headers.cookie), noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.ddosSwitchHeader, { data: crossParams.ddosSwitch || '', noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.yk0VersionHeader, { data: conf.version || '', noWarn: true }), _ref5;
|
|
164
165
|
};
|
package/server/proxy/tire.js
CHANGED
|
@@ -40,6 +40,12 @@ var _curl = require("../../utils/curl");
|
|
|
40
40
|
|
|
41
41
|
var _secCache = require("../../utils/secCache");
|
|
42
42
|
|
|
43
|
+
var _compression = require("compression");
|
|
44
|
+
|
|
45
|
+
var _compression2 = _interopRequireDefault(_compression);
|
|
46
|
+
|
|
47
|
+
var _control = require("../cache/control");
|
|
48
|
+
|
|
43
49
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
44
50
|
|
|
45
51
|
// import paths from '../../config/paths';
|
|
@@ -57,7 +63,7 @@ exports.default = function () {
|
|
|
57
63
|
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(_ref) {
|
|
58
64
|
var config = _ref.config;
|
|
59
65
|
|
|
60
|
-
var appConf, appName, server, pIp, pHost, isFastDfs, apiVer, getUc, build, baseConfig, app, _headers2
|
|
66
|
+
var appConf, appName, server, pIp, pHost, timeout, isFastDfs, apiVer, getUc, build, baseConfig, app, _headers2;
|
|
61
67
|
|
|
62
68
|
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
|
63
69
|
while (1) {
|
|
@@ -68,6 +74,7 @@ exports.default = function () {
|
|
|
68
74
|
server = appConf.server;
|
|
69
75
|
pIp = _server.ip.address();
|
|
70
76
|
pHost = server.protocol + "//" + pIp + ":" + appConf.port;
|
|
77
|
+
timeout = _config2.default.server.infoTimeout + 5000;
|
|
71
78
|
|
|
72
79
|
if (!server.generate.enabled) {
|
|
73
80
|
_context3.next = 24;
|
|
@@ -160,9 +167,11 @@ exports.default = function () {
|
|
|
160
167
|
body: {
|
|
161
168
|
url: '/**',
|
|
162
169
|
project: _config2.default.name,
|
|
163
|
-
app: config.appName
|
|
170
|
+
app: config.appName,
|
|
171
|
+
|
|
172
|
+
remove: true
|
|
164
173
|
},
|
|
165
|
-
timeout:
|
|
174
|
+
timeout: timeout,
|
|
166
175
|
json: true
|
|
167
176
|
});
|
|
168
177
|
|
|
@@ -188,14 +197,14 @@ exports.default = function () {
|
|
|
188
197
|
}();
|
|
189
198
|
|
|
190
199
|
if (_config2.default.security.isTire) {
|
|
191
|
-
_context3.next =
|
|
200
|
+
_context3.next = 14;
|
|
192
201
|
break;
|
|
193
202
|
}
|
|
194
203
|
|
|
195
|
-
_context3.next =
|
|
204
|
+
_context3.next = 14;
|
|
196
205
|
return build();
|
|
197
206
|
|
|
198
|
-
case
|
|
207
|
+
case 14:
|
|
199
208
|
baseConfig = {
|
|
200
209
|
// changeOrigin: true,
|
|
201
210
|
secure: false,
|
|
@@ -206,6 +215,7 @@ exports.default = function () {
|
|
|
206
215
|
|
|
207
216
|
|
|
208
217
|
app.set('x-powered-by', false);
|
|
218
|
+
app.use((0, _compression2.default)());
|
|
209
219
|
|
|
210
220
|
app.use(function (req, res, next) {
|
|
211
221
|
if (req.url !== '/__clearCache') {
|
|
@@ -245,66 +255,97 @@ exports.default = function () {
|
|
|
245
255
|
next();
|
|
246
256
|
}
|
|
247
257
|
} else {
|
|
248
|
-
var
|
|
249
|
-
res.header("Connection", "keep-alive");
|
|
250
|
-
// res.header("Connection", "close");
|
|
258
|
+
var isSet = req.get("x-gen-set");
|
|
251
259
|
|
|
252
|
-
if (
|
|
253
|
-
|
|
254
|
-
|
|
260
|
+
if (isSet !== "true") {
|
|
261
|
+
var _data = (0, _secCache.secCacheGet)(getCacheKey(req.url));
|
|
262
|
+
// res.header("Connection", "close");
|
|
263
|
+
// console.log(req.url, "all");
|
|
264
|
+
|
|
265
|
+
if (_data) {
|
|
266
|
+
// console.log(req.url, "sec have");
|
|
267
|
+
// res.header("Connection", "keep-alive");
|
|
268
|
+
_server._.forEach(_data.resHeaders, function (v, key) {
|
|
255
269
|
res.header(key, v);
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if (
|
|
293
|
-
|
|
270
|
+
// if (key.toLowerCase() !== 'connection') {
|
|
271
|
+
// res.header(key, v);
|
|
272
|
+
// }
|
|
273
|
+
});
|
|
274
|
+
res.status(_data.status).send(_data.body);
|
|
275
|
+
// res.send(data.body);
|
|
276
|
+
} else {
|
|
277
|
+
// console.log(req.url, "sec nooo~");
|
|
278
|
+
var extIndex = req.url.lastIndexOf('.');
|
|
279
|
+
if (!apiVer(req.url) && extIndex === -1) {
|
|
280
|
+
(0, _curl.curlOrb)(server.generate.api.get, {
|
|
281
|
+
method: 'POST',
|
|
282
|
+
body: {
|
|
283
|
+
url: req.url,
|
|
284
|
+
project: _config2.default.name,
|
|
285
|
+
app: config.appName,
|
|
286
|
+
|
|
287
|
+
personality: server.generate.personality,
|
|
288
|
+
domain: appConf.cookieDomain || _server.Cookies.getDefCookieDomain(req && req.headers && req.headers.host || ''),
|
|
289
|
+
svcKey: appConf.svcKey,
|
|
290
|
+
childKey: _config2.default.childKey
|
|
291
|
+
},
|
|
292
|
+
timeout: timeout,
|
|
293
|
+
json: true,
|
|
294
|
+
resolveWithFullResponse: true,
|
|
295
|
+
headers: (0, _defineProperty3.default)({
|
|
296
|
+
// Cookie: Cookies.koaGetCookieStr({req}),
|
|
297
|
+
Cookie: req.get("cookie")
|
|
298
|
+
}, _def.variable.childKeyHeader, _config2.default.childKey)
|
|
299
|
+
}).then(function (response) {
|
|
300
|
+
// console.log(response);
|
|
301
|
+
var data = response.body;
|
|
302
|
+
// console.log(req.url, "req res");
|
|
303
|
+
if (data) {
|
|
304
|
+
// console.log(req.url, "req res have");
|
|
305
|
+
data.body = Buffer.from(data.body);
|
|
306
|
+
if (response.headers['set-cookie']) {
|
|
307
|
+
data.resHeaders = (0, _extends3.default)({}, data.resHeaders, {
|
|
308
|
+
'set-cookie': response.headers['set-cookie']
|
|
309
|
+
});
|
|
294
310
|
}
|
|
295
|
-
});
|
|
296
311
|
|
|
297
|
-
|
|
298
|
-
|
|
312
|
+
// cache ---
|
|
313
|
+
(0, _control.noCache)(res);
|
|
314
|
+
|
|
315
|
+
_server._.forEach(data.resHeaders, function (v, key) {
|
|
316
|
+
res.header(key, v);
|
|
317
|
+
// if (key.toLowerCase() !== 'connection') {
|
|
318
|
+
// res.header(key, v)
|
|
319
|
+
// }
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
// res.header("Cache-Control", "public, max-age=66, s-maxage=120")
|
|
323
|
+
|
|
324
|
+
res.send(data.body);
|
|
325
|
+
|
|
326
|
+
if (server.generate.autoRefresh) {
|
|
327
|
+
(0, _curl.curl)("http://127.0.0.1:" + config.appConf.port + req.url, {
|
|
328
|
+
method: 'GET',
|
|
329
|
+
headers: {
|
|
330
|
+
"Cookie": req.get("cookie"),
|
|
331
|
+
"x-gen-set": "true"
|
|
332
|
+
},
|
|
333
|
+
timeout: timeout
|
|
334
|
+
}).then();
|
|
335
|
+
}
|
|
336
|
+
} else {
|
|
337
|
+
next();
|
|
338
|
+
}
|
|
339
|
+
}).catch(function (e) {
|
|
340
|
+
// console.log(e);
|
|
299
341
|
next();
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
// console.log(e);
|
|
342
|
+
});
|
|
343
|
+
} else {
|
|
303
344
|
next();
|
|
304
|
-
}
|
|
305
|
-
} else {
|
|
306
|
-
next();
|
|
345
|
+
}
|
|
307
346
|
}
|
|
347
|
+
} else {
|
|
348
|
+
next();
|
|
308
349
|
}
|
|
309
350
|
}
|
|
310
351
|
});
|
|
@@ -332,14 +373,21 @@ exports.default = function () {
|
|
|
332
373
|
target: "http://127.0.0.1:" + config.appConf.appPort,
|
|
333
374
|
ws: true,
|
|
334
375
|
onProxyRes: function onProxyRes(proxyRes, req, res) {
|
|
376
|
+
var isDoc = ['text/html; charset=utf-8'].includes((proxyRes.headers['content-type'] || '').toLowerCase());
|
|
377
|
+
|
|
378
|
+
// cache ---
|
|
379
|
+
if (isDoc) {
|
|
380
|
+
proxyRes.headers['Surrogate-Control'] = 'no-store';
|
|
381
|
+
proxyRes.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, proxy-revalidate';
|
|
382
|
+
proxyRes.headers['Pragma'] = 'no-cache';
|
|
383
|
+
proxyRes.headers['Expires'] = '0';
|
|
384
|
+
}
|
|
385
|
+
|
|
335
386
|
var body = [];
|
|
336
387
|
proxyRes.on('data', function (chunk) {
|
|
337
388
|
body.push(chunk);
|
|
338
389
|
});
|
|
339
390
|
proxyRes.on('end', function () {
|
|
340
|
-
// if (req.url === "/object/http") {
|
|
341
|
-
// console.log(body, 111111);
|
|
342
|
-
// }
|
|
343
391
|
if (!apiVer(req.url) && _config2.default.server.cacheControl.enabled) {
|
|
344
392
|
var isCache = true;
|
|
345
393
|
|
|
@@ -373,7 +421,7 @@ exports.default = function () {
|
|
|
373
421
|
|
|
374
422
|
var isLibSave = isCache && [].concat(libContentType).includes((proxyRes.headers['content-type'] || '').toLowerCase());
|
|
375
423
|
|
|
376
|
-
var isDocSave = isCache &&
|
|
424
|
+
var isDocSave = isCache && isDoc;
|
|
377
425
|
|
|
378
426
|
if ((isTireSave || isLibSave || isDocSave) && res.statusCode === 200 || isFastDfs(req.url)) {
|
|
379
427
|
body = Buffer.concat(body);
|
|
@@ -387,12 +435,19 @@ exports.default = function () {
|
|
|
387
435
|
}
|
|
388
436
|
|
|
389
437
|
if (isDocSave) {
|
|
438
|
+
// proxyRes.headers['Surrogate-Control'] = 'no-store';
|
|
439
|
+
// proxyRes.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, proxy-revalidate';
|
|
440
|
+
// proxyRes.headers['Pragma'] = 'no-cache';
|
|
441
|
+
// proxyRes.headers['Expires'] = '0';
|
|
442
|
+
// console.log(req.url, proxyRes.headers['Cache-Control']);
|
|
390
443
|
(0, _curl.curlOrb)(server.generate.api.set, {
|
|
391
444
|
method: 'POST',
|
|
392
445
|
body: {
|
|
393
446
|
project: _config2.default.name,
|
|
394
447
|
app: config.appName,
|
|
395
448
|
url: req.url,
|
|
449
|
+
|
|
450
|
+
personality: server.generate.personality,
|
|
396
451
|
host: pHost,
|
|
397
452
|
svcKey: appConf.svcKey,
|
|
398
453
|
cacheData: (0, _stringify2.default)({
|
|
@@ -400,10 +455,11 @@ exports.default = function () {
|
|
|
400
455
|
resHeaders: proxyRes.headers
|
|
401
456
|
})
|
|
402
457
|
},
|
|
403
|
-
timeout:
|
|
458
|
+
timeout: timeout,
|
|
404
459
|
json: true,
|
|
405
460
|
headers: (0, _defineProperty3.default)({
|
|
406
|
-
Cookie:
|
|
461
|
+
// Cookie: Cookies.koaGetCookieStr({req}),
|
|
462
|
+
Cookie: req.get("cookie")
|
|
407
463
|
}, _def.variable.childKeyHeader, _config2.default.childKey)
|
|
408
464
|
}).then(function () {}).catch(function (e) {});
|
|
409
465
|
}
|
|
@@ -434,10 +490,10 @@ exports.default = function () {
|
|
|
434
490
|
});
|
|
435
491
|
}
|
|
436
492
|
})));
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
sv.keepAliveTimeout = server.generate.keepAliveTimeout;
|
|
440
|
-
sv.headersTimeout = server.generate.headersTimeout;
|
|
493
|
+
app.listen(config.appConf.port);
|
|
494
|
+
// const sv = app.listen(config.appConf.port);
|
|
495
|
+
// sv.keepAliveTimeout = server.generate.keepAliveTimeout;
|
|
496
|
+
// sv.headersTimeout = server.generate.headersTimeout;
|
|
441
497
|
|
|
442
498
|
if (server.generate.clearCache) {
|
|
443
499
|
setInterval(function () {
|
package/template/tfs.plugin.js
CHANGED
package/utils/curl.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.curlOrb = undefined;
|
|
6
|
+
exports.curl = exports.curlOrb = undefined;
|
|
7
7
|
|
|
8
8
|
var _regenerator = require("babel-runtime/regenerator");
|
|
9
9
|
|
|
@@ -51,4 +51,6 @@ var curlOrb = exports.curlOrb = function () {
|
|
|
51
51
|
return function curlOrb(_x2) {
|
|
52
52
|
return _ref.apply(this, arguments);
|
|
53
53
|
};
|
|
54
|
-
}();
|
|
54
|
+
}();
|
|
55
|
+
|
|
56
|
+
exports.curl = _server.curl;
|
package/utils/inclusive.js
CHANGED
|
@@ -269,6 +269,7 @@ var render = function () {
|
|
|
269
269
|
cHost: null,
|
|
270
270
|
basePath: '/',
|
|
271
271
|
openBasePath: false,
|
|
272
|
+
// openHmr: true,
|
|
272
273
|
|
|
273
274
|
// docker: false,
|
|
274
275
|
mockIP: false,
|
|
@@ -355,6 +356,8 @@ var render = function () {
|
|
|
355
356
|
enabled: false,
|
|
356
357
|
forceEnabled: false,
|
|
357
358
|
clearCache: false,
|
|
359
|
+
personality: true,
|
|
360
|
+
autoRefresh: true,
|
|
358
361
|
maxAge: 60 * 60, // 1小时
|
|
359
362
|
keepAliveTimeout: 60 * 1000,
|
|
360
363
|
headersTimeout: 60 * 1000,
|
|
@@ -386,6 +389,9 @@ var render = function () {
|
|
|
386
389
|
// ...(mainConf.server && mainConf.server.cacheControl && mainConf.server.cacheControl.exclude || []),
|
|
387
390
|
// ...(ykConf.server && ykConf.server.cacheControl && ykConf.server.cacheControl.exclude || []),
|
|
388
391
|
]
|
|
392
|
+
// excludeType: [
|
|
393
|
+
// 'text/html; charset=utf-8',
|
|
394
|
+
// ],
|
|
389
395
|
},
|
|
390
396
|
hotLinking: {
|
|
391
397
|
enabled: false,
|
|
@@ -768,7 +774,7 @@ var render = function () {
|
|
|
768
774
|
v.env = v.env || conf.env;
|
|
769
775
|
v.protocol = (v.https ? 'https:' : 'http:') || conf.server.protocol;
|
|
770
776
|
v.host = v.host || conf.server.host;
|
|
771
|
-
v.domain = v.domain || conf.server.domain;
|
|
777
|
+
v.domain = v.domain || v.server && v.server.domain || conf.server.domain;
|
|
772
778
|
v.cHost = v.cHost || conf.server.cHost;
|
|
773
779
|
// v.cPortHide = typeof conf.server.cPortHide === 'boolean' ? conf.server.cPortHide :
|
|
774
780
|
// typeof v.cPortHide === 'boolean' && v.cPortHide === true;
|
|
@@ -804,7 +810,8 @@ var render = function () {
|
|
|
804
810
|
}
|
|
805
811
|
},
|
|
806
812
|
generate: (0, _extends3.default)({}, conf.server.generate, v.server && v.server.generate),
|
|
807
|
-
sslify: (0, _extends3.default)({}, conf.server.sslify, v.server && v.server.sslify)
|
|
813
|
+
sslify: (0, _extends3.default)({}, conf.server.sslify, v.server && v.server.sslify),
|
|
814
|
+
gray: (0, _extends3.default)({}, conf.server.gray, v.server && v.server.gray)
|
|
808
815
|
});
|
|
809
816
|
|
|
810
817
|
if (v.server.openBasePath && v.server.basePath === "/") {
|