cloudcmd 19.18.0 → 19.19.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 +10 -0
- package/HELP.md +3 -1
- package/README.md +1 -1
- package/bin/cloudcmd.js +2 -1
- package/dist/cloudcmd.common.js +5 -2
- package/dist/cloudcmd.common.js.map +1 -1
- package/dist/sw.js +1 -1
- package/dist-dev/cloudcmd.common.js +2 -2
- package/dist-dev/sw.js +1 -1
- package/package.json +2 -1
- package/server/server.js +11 -6
package/dist/sw.js
CHANGED
|
@@ -311,7 +311,7 @@ const respondWith = currify((f, e) => {
|
|
|
311
311
|
e.respondWith(f(e));
|
|
312
312
|
});
|
|
313
313
|
const getPathName = url => new URL(url).pathname;
|
|
314
|
-
const date = "Tue May 26 2026
|
|
314
|
+
const date = "Tue May 26 2026 23:16:55 GMT+0300 (Eastern European Summer Time)";
|
|
315
315
|
const NAME = `cloudcmd: ${date}`;
|
|
316
316
|
const createRequest = a => new Request(a, {
|
|
317
317
|
credentials: 'same-origin'
|
|
@@ -1690,7 +1690,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
1690
1690
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
1691
1691
|
|
|
1692
1692
|
"use strict";
|
|
1693
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ENABLED: () => (/* binding */ ENABLED),\n/* harmony export */ hide: () => (/* binding */ hide),\n/* harmony export */ init: () => (/* binding */ init),\n/* harmony export */ show: () => (/* binding */ show)\n/* harmony export */ });\n/* harmony import */ var execon__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\n/* harmony import */ var wraptile__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\n/* harmony import */ var _cloudcmd_create_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n/* harmony import */ var _dom_load__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! #dom/load */ \"./client/dom/load.js\");\n/* harmony import */ var _dom_rest__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! #dom/rest */ \"./client/dom/rest.js\");\n/* harmony import */ var _common_cloudfunc__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! #common/cloudfunc */ \"./common/cloudfunc.js\");\n
|
|
1693
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ENABLED: () => (/* binding */ ENABLED),\n/* harmony export */ hide: () => (/* binding */ hide),\n/* harmony export */ init: () => (/* binding */ init),\n/* harmony export */ show: () => (/* binding */ show)\n/* harmony export */ });\n/* harmony import */ var execon__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\n/* harmony import */ var wraptile__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\n/* harmony import */ var _cloudcmd_create_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n/* harmony import */ var _dom_load__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! #dom/load */ \"./client/dom/load.js\");\n/* harmony import */ var _dom_rest__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! #dom/rest */ \"./client/dom/rest.js\");\n/* harmony import */ var _common_cloudfunc__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! #common/cloudfunc */ \"./common/cloudfunc.js\");\n\n\n\n\n\n\nconst {\n CloudCmd,\n DOM\n} = globalThis;\nconst {\n config,\n Key\n} = CloudCmd;\nconst {\n Buffer,\n Events,\n Dialog,\n Images\n} = DOM;\nconst Info = DOM.CurrentInfo;\nconst alertNoFiles = Dialog.alert.noFiles;\nconst uploadTo = wraptile__WEBPACK_IMPORTED_MODULE_1__(_uploadTo);\nlet MenuShowedName;\nlet MenuContext;\nlet MenuContextFile;\nconst ENABLED = false;\nCloudCmd.Menu = {\n init,\n show,\n hide\n};\nasync function init() {\n const {\n isAuth,\n menuDataFile\n } = getFileMenuData();\n const fm = DOM.getFM();\n const menuData = getMenuData(isAuth);\n const options = getOptions({\n type: 'context'\n });\n const optionsFile = getOptions({\n type: 'file'\n });\n const {\n createCloudMenu\n } = await __webpack_require__.e(/*! import() */ \"cloudcmd.common\").then(__webpack_require__.bind(__webpack_require__, /*! ./cloudmenu.js */ \"./client/modules/menu/cloudmenu.js\"));\n const {\n name\n } = fm.dataset;\n MenuContext = await createCloudMenu(name, options, menuData);\n MenuContextFile = await createCloudMenu(name, optionsFile, menuDataFile);\n MenuContext.addContextMenuListener();\n MenuContextFile.addContextMenuListener();\n Events.addKey(listener);\n}\nfunction hide() {\n MenuContext.hide();\n MenuContextFile.hide();\n}\nfunction show(position) {\n const {\n x,\n y\n } = getPosition(position);\n MenuContext.show(x, y);\n MenuContextFile.show(x, y);\n Images.hide();\n}\nfunction getPosition(position) {\n if (position) return {\n x: position.x,\n y: position.y\n };\n return getCurrentPosition();\n}\nfunction getMenuNameByEl(el) {\n if (!el) return 'context';\n const name = DOM.getCurrentName(el);\n if (name === '..') return 'context';\n return 'contextFile';\n}\nfunction getOptions({\n type\n}) {\n let name;\n let func;\n if (type === 'context') {\n name = 'context';\n func = Key.unsetBind;\n } else if (type === 'file') {\n name = 'contextFile';\n }\n const options = {\n icon: true,\n infiniteScroll: false,\n beforeClose: Key.setBind,\n beforeHide: Key.setBind,\n beforeShow: execon__WEBPACK_IMPORTED_MODULE_0__[\"with\"](beforeShow, func),\n beforeClick,\n name\n };\n return options;\n}\nfunction getMenuData(isAuth) {\n const menu = {\n 'Paste': Buffer.paste,\n 'New': {\n File: DOM.promptNewFile,\n Directory: DOM.promptNewDir\n },\n 'Upload': () => {\n CloudCmd.Upload.show();\n },\n 'Upload From Cloud': uploadFromCloud,\n 'Toggle File Selection': DOM.toggleSelectedFile,\n '(Un)Select All': DOM.toggleAllSelectedFiles\n };\n if (isAuth) menu['Log Out'] = CloudCmd.logOut;\n return menu;\n}\nfunction getFileMenuData() {\n const isAuth = CloudCmd.config('auth');\n const menuBottom = getMenuData(isAuth);\n const menuTop = {\n 'View': () => {\n CloudCmd.View.show();\n },\n 'Edit': () => {\n const name = config('vim') ? 'EditFileVim' : 'EditFile';\n CloudCmd[name].show();\n },\n 'Rename': () => {\n setTimeout(DOM.renameCurrent, 100);\n },\n 'Delete': () => {\n CloudCmd.Operation.show('delete');\n },\n 'Pack': () => {\n CloudCmd.Operation.show('pack');\n },\n 'Extract': () => {\n CloudCmd.Operation.show('extract');\n },\n 'Download': preDownload,\n 'Upload To Cloud': uploadTo('Cloud'),\n 'Cut': () => {\n isCurrent(Buffer.cut, alertNoFiles);\n },\n 'Copy': () => {\n isCurrent(Buffer.copy, alertNoFiles);\n }\n };\n const menuDataFile = {\n ...menuTop,\n ...menuBottom\n };\n return {\n isAuth,\n menuDataFile\n };\n}\nfunction isCurrent(yesFn, noFn) {\n if (Info.name !== '..') return yesFn();\n noFn();\n}\nfunction isPath(x, y) {\n const {\n panel\n } = Info;\n const isEmptyRoot = !panel;\n if (isEmptyRoot) return false;\n const el = document.elementFromPoint(x, y);\n const elements = panel.querySelectorAll('[data-name=\"js-path\"] *');\n return !~[].indexOf.call(elements, el);\n}\nfunction beforeShow(callback, params) {\n Key.unsetBind();\n const {\n name,\n position = {\n x: params.x,\n y: params.y\n }\n } = params;\n const {\n x,\n y\n } = position;\n const el = DOM.getCurrentByPosition({\n x,\n y\n });\n const menuName = getMenuNameByEl(el);\n let isShow = menuName !== 'contextFile';\n if (params.name === 'contextFile') isShow = !isShow;\n if (isShow) MenuShowedName = name;\n execon__WEBPACK_IMPORTED_MODULE_0__(callback);\n if (isShow) isShow = isPath(x, y);\n return isShow;\n}\nconst beforeClick = name => MenuShowedName !== name;\nasync function _uploadTo(nameModule) {\n const [error, data] = await Info.getData();\n if (error) return;\n const {\n name\n } = Info;\n CloudCmd.execFromModule(nameModule, 'uploadFile', name, data);\n CloudCmd.log(`Uploading to ${name}...`);\n}\nfunction uploadFromCloud() {\n Images.show.load('top');\n CloudCmd.execFromModule('Cloud', 'saveFile', async (currentName, data) => {\n const path = DOM.getCurrentDirPath() + currentName;\n const [e] = await _dom_rest__WEBPACK_IMPORTED_MODULE_4__.write(path, data);\n if (e) return;\n await CloudCmd.refresh({\n currentName\n });\n });\n}\nfunction preDownload() {\n download(config('packer'));\n}\nfunction download(type) {\n const TIME = 30 * 1000;\n const {\n prefixURL\n } = CloudCmd;\n const PACK = '/pack';\n const date = Date.now();\n const files = DOM.getActiveFiles();\n if (!files.length) return alertNoFiles();\n for (const file of files) {\n const selected = DOM.isSelected(file);\n const isDir = DOM.isCurrentIsDir(file);\n const path = DOM.getCurrentPath(file);\n CloudCmd.log(`downloading file ${path}...`);\n\n /*\n * if we send ajax request -\n * no need in hash so we escape #\n * and all other characters, like \"%\"\n */\n const encodedPath = encodeURI(path).replace(/#/g, '#');\n const id = (0,_dom_load__WEBPACK_IMPORTED_MODULE_3__.getIdBySrc)(path);\n let src;\n if (isDir) src = prefixURL + PACK + encodedPath + DOM.getPackerExt(type);else src = prefixURL + _common_cloudfunc__WEBPACK_IMPORTED_MODULE_5__.FS + encodedPath + '?download';\n const element = _cloudcmd_create_element__WEBPACK_IMPORTED_MODULE_2__('iframe', {\n id: id + '-' + date,\n async: false,\n className: 'hidden',\n src\n });\n const {\n body\n } = document;\n const removeChild = body.removeChild.bind(body, element);\n setTimeout(removeChild, TIME);\n if (selected) DOM.toggleSelectedFile(file);\n }\n}\nfunction getCurrentPosition() {\n const current = Info.element;\n const rect = current.getBoundingClientRect();\n const position = {\n x: Math.round(rect.left + rect.width / 3),\n y: Math.round(rect.top)\n };\n return position;\n}\nfunction listener(event) {\n const {\n F9,\n ESC\n } = Key;\n const key = event.keyCode;\n const isBind = Key.isBind();\n if (key === ESC) {\n Key.setBind();\n return hide();\n }\n if (isBind && key === F9) {\n const position = getCurrentPosition();\n MenuContext.show(position.x, position.y);\n event.preventDefault();\n }\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/modules/menu/index.js\n}");
|
|
1694
1694
|
|
|
1695
1695
|
/***/ },
|
|
1696
1696
|
|
|
@@ -1877,7 +1877,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
1877
1877
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
1878
1878
|
|
|
1879
1879
|
"use strict";
|
|
1880
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ _detectType: () => (/* binding */ _detectType),\n/* harmony export */ getType: () => (/* binding */ getType),\n/* harmony export */ isAudio: () => (/* binding */ isAudio),\n/* harmony export */ isImage: () => (/* binding */ isImage)\n/* harmony export */ });\n/* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node:path */ \"./node_modules/path-browserify/index.js\");\n/* harmony import */ var currify__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\n\nconst isAudio = name => /\\.(mp3|ogg|m4a)$/i.test(name);\nconst testRegExp = currify__WEBPACK_IMPORTED_MODULE_1__((name, reg) => reg.test(name));\nconst getRegExp = ext => RegExp(`\\\\.${ext}$`, 'i');\nconst isPDF = a => /\\.pdf$/i.test(a);\nconst isHTML = a => a.endsWith('.html');\nconst isMarkdown = a => /.\\.md$/.test(a);\nconst getType = async path => {\n const ext = (0,node_path__WEBPACK_IMPORTED_MODULE_0__.extname)(path);\n if (!ext) path = await detectType(path);\n if (isPDF(path)) return 'pdf';\n if (isImage(path)) return 'image';\n if (isMedia(path)) return 'media';\n if (isHTML(path)) return 'html';\n if (isMarkdown(path)) return 'markdown';\n};\nfunction isImage(name) {\n const images = ['jp(e|g|eg)', 'gif', 'png', 'bmp', 'webp', 'svg', 'ico'];\n return images.map(getRegExp).some(testRegExp(name));\n}\nfunction isMedia(name) {\n return isAudio(name) || isVideo(name);\n}\nfunction isVideo(name) {\n return /\\.(mp4|avi|webm)$/i.test(name);\n}\nconst _detectType = detectType;\nasync function detectType(path) {\n const {\n headers\n } = await fetch(path, {\n method: 'HEAD'\n });\n for (const [name, value] of headers) {\n if (name === 'content-type') return `.${value.split('/').pop()}`;\n }\n return '';\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/modules/view/types.js\n}");
|
|
1880
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ _detectType: () => (/* binding */ _detectType),\n/* harmony export */ getType: () => (/* binding */ getType),\n/* harmony export */ isAudio: () => (/* binding */ isAudio),\n/* harmony export */ isImage: () => (/* binding */ isImage)\n/* harmony export */ });\n/* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node:path */ \"./node_modules/path-browserify/index.js\");\n/* harmony import */ var currify__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\n\nconst isAudio = name => /\\.(mp3|ogg|m4a|flac)$/i.test(name);\nconst testRegExp = currify__WEBPACK_IMPORTED_MODULE_1__((name, reg) => reg.test(name));\nconst getRegExp = ext => RegExp(`\\\\.${ext}$`, 'i');\nconst isPDF = a => /\\.pdf$/i.test(a);\nconst isHTML = a => a.endsWith('.html');\nconst isMarkdown = a => /.\\.md$/.test(a);\nconst getType = async path => {\n const ext = (0,node_path__WEBPACK_IMPORTED_MODULE_0__.extname)(path);\n if (!ext) path = await detectType(path);\n if (isPDF(path)) return 'pdf';\n if (isImage(path)) return 'image';\n if (isMedia(path)) return 'media';\n if (isHTML(path)) return 'html';\n if (isMarkdown(path)) return 'markdown';\n};\nfunction isImage(name) {\n const images = ['jp(e|g|eg)', 'gif', 'png', 'bmp', 'webp', 'svg', 'ico'];\n return images.map(getRegExp).some(testRegExp(name));\n}\nfunction isMedia(name) {\n return isAudio(name) || isVideo(name);\n}\nfunction isVideo(name) {\n return /\\.(mp4|avi|webm)$/i.test(name);\n}\nconst _detectType = detectType;\nasync function detectType(path) {\n const {\n headers\n } = await fetch(path, {\n method: 'HEAD'\n });\n for (const [name, value] of headers) {\n if (name === 'content-type') return `.${value.split('/').pop()}`;\n }\n return '';\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/modules/view/types.js\n}");
|
|
1881
1881
|
|
|
1882
1882
|
/***/ },
|
|
1883
1883
|
|
package/dist-dev/sw.js
CHANGED
|
@@ -37,7 +37,7 @@ eval("{// shim for using process in browser\nvar process = module.exports = {};\
|
|
|
37
37
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
38
38
|
|
|
39
39
|
"use strict";
|
|
40
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var node_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node:process */ \"./node_modules/process/browser.js\");\n/* harmony import */ var try_to_catch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n/* harmony import */ var currify__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\n\n\nconst isDev = \"development\" === 'development';\nconst isGet = a => a.method === 'GET';\nconst isBasic = a => a.type === 'basic';\nconst wait = currify__WEBPACK_IMPORTED_MODULE_2__((f, e) => e.waitUntil(f()));\nconst respondWith = currify__WEBPACK_IMPORTED_MODULE_2__((f, e) => {\n const {\n request\n } = e;\n const {\n url\n } = request;\n const pathname = getPathName(url);\n if (url.endsWith('/') || /\\^\\/fs/.test(pathname)) return;\n if (!isGet(request)) return;\n if (!isBasic(request)) return;\n if (pathname.startsWith('/api')) return;\n if (/^socket.io/.test(pathname)) return;\n e.respondWith(f(e));\n});\nconst getPathName = url => new URL(url).pathname;\nconst date = \"Tue May 26 2026
|
|
40
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var node_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node:process */ \"./node_modules/process/browser.js\");\n/* harmony import */ var try_to_catch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n/* harmony import */ var currify__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\n\n\nconst isDev = \"development\" === 'development';\nconst isGet = a => a.method === 'GET';\nconst isBasic = a => a.type === 'basic';\nconst wait = currify__WEBPACK_IMPORTED_MODULE_2__((f, e) => e.waitUntil(f()));\nconst respondWith = currify__WEBPACK_IMPORTED_MODULE_2__((f, e) => {\n const {\n request\n } = e;\n const {\n url\n } = request;\n const pathname = getPathName(url);\n if (url.endsWith('/') || /\\^\\/fs/.test(pathname)) return;\n if (!isGet(request)) return;\n if (!isBasic(request)) return;\n if (pathname.startsWith('/api')) return;\n if (/^socket.io/.test(pathname)) return;\n e.respondWith(f(e));\n});\nconst getPathName = url => new URL(url).pathname;\nconst date = \"Tue May 26 2026 23:16:57 GMT+0300 (Eastern European Summer Time)\";\nconst NAME = `cloudcmd: ${date}`;\nconst createRequest = a => new Request(a, {\n credentials: 'same-origin'\n});\nconst getRequest = (a, request) => {\n if (a !== '/') return request;\n return createRequest('/');\n};\nglobalThis.addEventListener('install', wait(onInstall));\nglobalThis.addEventListener('fetch', respondWith(onFetch));\nglobalThis.addEventListener('activate', wait(onActivate));\nasync function onActivate() {\n console.info(`cloudcmd: sw: activate: ${NAME}`);\n await globalThis.clients.claim();\n const keys = await caches.keys();\n const deleteCache = caches.delete.bind(caches);\n await Promise.all(keys.map(deleteCache));\n}\nasync function onInstall() {\n console.info(`cloudcmd: sw: install: ${NAME}`);\n await globalThis.skipWaiting();\n}\nasync function onFetch(event) {\n const {\n request\n } = event;\n const {\n url\n } = request;\n const pathname = getPathName(url);\n const newRequest = getRequest(pathname, event.request);\n const cache = await caches.open(NAME);\n const response = await cache.match(request);\n if (!isDev && response) return response;\n const [e, resp] = await (0,try_to_catch__WEBPACK_IMPORTED_MODULE_1__.tryToCatch)(fetch, newRequest, {\n credentials: 'same-origin'\n });\n if (e) return new Response(e.message);\n await addToCache(request, resp.clone());\n return resp;\n}\nasync function addToCache(request, response) {\n const cache = await caches.open(NAME);\n return cache.put(request, response);\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/sw/sw.js\n}");
|
|
41
41
|
|
|
42
42
|
/***/ },
|
|
43
43
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudcmd",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.19.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "File manager for the web with console and editor",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"fix:lint": "madrun fix:lint",
|
|
56
56
|
"lint:stream": "madrun lint:stream",
|
|
57
57
|
"test": "madrun test",
|
|
58
|
+
"test:e2e": "madrun test:e2e",
|
|
58
59
|
"test:client": "madrun test:client",
|
|
59
60
|
"test:server": "madrun test:server",
|
|
60
61
|
"wisdom": "madrun wisdom",
|
package/server/server.js
CHANGED
|
@@ -20,8 +20,10 @@ const RATE_WINDOW = 15 * 60 * 1000;
|
|
|
20
20
|
const bind = (f, self) => f.bind(self);
|
|
21
21
|
|
|
22
22
|
const two = currify((f, a, b) => f(a, b));
|
|
23
|
-
const shutdown = wraptile(async (promises) => {
|
|
24
|
-
|
|
23
|
+
const shutdown = wraptile(async (config, promises) => {
|
|
24
|
+
if (config('log'))
|
|
25
|
+
console.log('closing cloudcmd...');
|
|
26
|
+
|
|
25
27
|
await Promise.all(promises);
|
|
26
28
|
process.exit(0);
|
|
27
29
|
});
|
|
@@ -41,7 +43,7 @@ export default async (options, config) => {
|
|
|
41
43
|
const app = express();
|
|
42
44
|
const server = http.createServer(app);
|
|
43
45
|
|
|
44
|
-
if (logger)
|
|
46
|
+
if (config('log') && logger)
|
|
45
47
|
app.use(logger('dev'));
|
|
46
48
|
|
|
47
49
|
if (prefix)
|
|
@@ -56,6 +58,8 @@ export default async (options, config) => {
|
|
|
56
58
|
limit: RATE_LIMIT,
|
|
57
59
|
});
|
|
58
60
|
|
|
61
|
+
app.set('trust proxy', 1);
|
|
62
|
+
|
|
59
63
|
app.use(compression());
|
|
60
64
|
app.use(limiter);
|
|
61
65
|
app.use(prefix, cloudcmd({
|
|
@@ -74,16 +78,17 @@ export default async (options, config) => {
|
|
|
74
78
|
server.on('error', exitPort);
|
|
75
79
|
await listen(port, ip);
|
|
76
80
|
|
|
77
|
-
const close = shutdown([closeServer, closeSocket]);
|
|
81
|
+
const close = shutdown(config, [closeServer, closeSocket]);
|
|
78
82
|
|
|
79
83
|
process.on('SIGINT', close);
|
|
80
|
-
process.on('
|
|
84
|
+
process.on('SIGUSR1', close);
|
|
81
85
|
|
|
82
86
|
const host = config('ip') || 'localhost';
|
|
83
87
|
const port0 = port || server.address().port;
|
|
84
88
|
const url = `http://${host}:${port0}${prefix}/`;
|
|
85
89
|
|
|
86
|
-
|
|
90
|
+
if (config('log'))
|
|
91
|
+
console.log(`url: ${url}`);
|
|
87
92
|
|
|
88
93
|
if (!config('open'))
|
|
89
94
|
return;
|