server workspace

Massimo Melina committed Mar 5, 2022 at 19:13 UTC 2c272bd6d7bbb2f0a268b5ff4a6e01b1a5719808
34 files changed +153 -84
package-lock.json
+90 -40
@@ -9,56 +9,18 @@
9 "version": "0.12.0",
10 "license": "GPL-3.0",
11 "workspaces": [
12 + "server",
13 "admin",
14 "frontend"
15 ],
15 - "dependencies": {
16 - "@koa/router": "^10.1.1",
17 - "@node-rs/crc32": "^1.3.1",
18 - "buffer-crc32": "https://github.com/rejetto/buffer-crc32.git",
19 - "fast-glob": "^3.2.7",
20 - "find-process": "^1.4.7",
21 - "koa": "^2.13.4",
22 - "koa-compress": "^5.1.0",
23 - "koa-mount": "^4.0.0",
24 - "koa-session": "^6.2.0",
25 - "limiter": "^2.1.0",
26 - "lodash": "^4.17.21",
27 - "minimist": "^1.2.5",
28 - "open": "^8.4.0",
29 - "tssrp6a": "^3.0.0",
30 - "yaml": "^2.0.0-10"
31 - },
16 "bin": {
17 "hfs": "dist/src/index.js"
18 },
35 - "devDependencies": {
36 - "@types/archiver": "^5.1.1",
37 - "@types/axios": "^0.14.0",
38 - "@types/koa": "^2.13.4",
39 - "@types/koa__router": "^8.0.11",
40 - "@types/koa-compress": "^4.0.3",
41 - "@types/koa-mount": "^4.0.1",
42 - "@types/koa-session": "^5.10.4",
43 - "@types/lodash": "^4.14.178",
44 - "@types/micromatch": "^4.0.2",
45 - "@types/mime-types": "^2.1.1",
46 - "@types/minimist": "^1.2.2",
47 - "@types/mocha": "^9.0.0",
48 - "@types/node": "^16.11.12",
49 - "axios": "^0.24.0",
50 - "koa-better-http-proxy": "^0.2.9",
51 - "mocha": "^9.1.3",
52 - "nm-prune": "^5.0.0",
53 - "nodemon": "^2.0.15",
54 - "ts-node": "^10.4.0"
55 - },
19 "engines": {
20 "node": ">=16.13.0"
21 }
22 },
23 "admin": {
61 - "version": "0.12.0",
24 "dependencies": {
25 "@emotion/react": "^11.7.1",
26 "@emotion/styled": "^11.6.0",
@@ -87,7 +49,6 @@
49 }
50 },
51 "frontend": {
90 - "version": "0.12.0",
52 "dependencies": {
53 "js-sha512": "^0.8.0",
54 "lodash": "^4.17.21",
@@ -17615,6 +17576,10 @@
17576 "node": ">= 0.8.0"
17577 }
17578 },
17579 + "node_modules/server": {
17580 + "resolved": "server",
17581 + "link": true
17582 + },
17583 "node_modules/setprototypeof": {
17584 "version": "1.2.0",
17585 "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
@@ -20361,6 +20326,52 @@
20326 "funding": {
20327 "url": "https://github.com/sponsors/sindresorhus"
20328 }
20329 + },
20330 + "server": {
20331 + "dependencies": {
20332 + "@koa/router": "^10.1.1",
20333 + "@node-rs/crc32": "^1.3.1",
20334 + "buffer-crc32": "https://github.com/rejetto/buffer-crc32.git",
20335 + "fast-glob": "^3.2.7",
20336 + "find-process": "^1.4.7",
20337 + "koa": "^2.13.4",
20338 + "koa-compress": "^5.1.0",
20339 + "koa-mount": "^4.0.0",
20340 + "koa-session": "^6.2.0",
20341 + "limiter": "^2.1.0",
20342 + "lodash": "^4.17.21",
20343 + "minimist": "^1.2.5",
20344 + "open": "^8.4.0",
20345 + "tssrp6a": "^3.0.0",
20346 + "yaml": "^2.0.0-10"
20347 + },
20348 + "bin": {
20349 + "hfs": "dist/src/index.js"
20350 + },
20351 + "devDependencies": {
20352 + "@types/archiver": "^5.1.1",
20353 + "@types/axios": "^0.14.0",
20354 + "@types/koa": "^2.13.4",
20355 + "@types/koa__router": "^8.0.11",
20356 + "@types/koa-compress": "^4.0.3",
20357 + "@types/koa-mount": "^4.0.1",
20358 + "@types/koa-session": "^5.10.4",
20359 + "@types/lodash": "^4.14.178",
20360 + "@types/micromatch": "^4.0.2",
20361 + "@types/mime-types": "^2.1.1",
20362 + "@types/minimist": "^1.2.2",
20363 + "@types/mocha": "^9.0.0",
20364 + "@types/node": "^16.11.12",
20365 + "axios": "^0.24.0",
20366 + "koa-better-http-proxy": "^0.2.9",
20367 + "mocha": "^9.1.3",
20368 + "nm-prune": "^5.0.0",
20369 + "nodemon": "^2.0.15",
20370 + "ts-node": "^10.4.0"
20371 + },
20372 + "engines": {
20373 + "node": ">=16.13.0"
20374 + }
20375 }
20376 },
20377 "dependencies": {
@@ -33350,6 +33361,45 @@
33361 "send": "0.17.2"
33362 }
33363 },
33364 + "server": {
33365 + "version": "file:server",
33366 + "requires": {
33367 + "@koa/router": "^10.1.1",
33368 + "@node-rs/crc32": "^1.3.1",
33369 + "@types/archiver": "^5.1.1",
33370 + "@types/axios": "^0.14.0",
33371 + "@types/koa": "^2.13.4",
33372 + "@types/koa__router": "^8.0.11",
33373 + "@types/koa-compress": "^4.0.3",
33374 + "@types/koa-mount": "^4.0.1",
33375 + "@types/koa-session": "^5.10.4",
33376 + "@types/lodash": "^4.14.178",
33377 + "@types/micromatch": "^4.0.2",
33378 + "@types/mime-types": "^2.1.1",
33379 + "@types/minimist": "^1.2.2",
33380 + "@types/mocha": "^9.0.0",
33381 + "@types/node": "^16.11.12",
33382 + "axios": "^0.24.0",
33383 + "buffer-crc32": "https://github.com/rejetto/buffer-crc32.git",
33384 + "fast-glob": "^3.2.7",
33385 + "find-process": "^1.4.7",
33386 + "koa": "^2.13.4",
33387 + "koa-better-http-proxy": "^0.2.9",
33388 + "koa-compress": "^5.1.0",
33389 + "koa-mount": "^4.0.0",
33390 + "koa-session": "^6.2.0",
33391 + "limiter": "^2.1.0",
33392 + "lodash": "^4.17.21",
33393 + "minimist": "^1.2.5",
33394 + "mocha": "^9.1.3",
33395 + "nm-prune": "^5.0.0",
33396 + "nodemon": "^2.0.15",
33397 + "open": "^8.4.0",
33398 + "ts-node": "^10.4.0",
33399 + "tssrp6a": "^3.0.0",
33400 + "yaml": "^2.0.0-10"
33401 + }
33402 + },
33403 "setprototypeof": {
33404 "version": "1.2.0",
33405 "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
package.json
+5 -43
@@ -9,16 +9,16 @@
9 "homepage": "https://rejetto.com/hfs",
10 "license": "GPL-3.0",
11 "author": "Massimo Melina <a@rejetto.com>",
12 - "workspaces": [ "admin", "frontend" ],
12 + "workspaces": [ "server", "admin", "frontend" ],
13 "scripts": {
14 - "watch-server": "nodemon --ignore tests/ --watch src -e ts,tsx --exec ts-node src/index.ts",
14 + "watch-server": "nodemon --ignore server/tests/ --watch server/src -e ts,tsx --exec ts-node server/src/index.ts",
15 "start-frontend": "cd frontend && npm run start",
16 "start-admin": "cd admin && npm run start",
17 "start": "node dist",
18 - "build": "npm install && rm -rf dist/src && tsc --target es2018 && cp -v -r package*.json READ* plugins dist && cd dist && npm ci --production && cd .. && node afterbuild",
18 + "build": "npm install && rm -rf dist/src && tsc --target es2018 && cp -v -r package-lock.json server/package.json READ* plugins dist && cd dist && npm ci --production && cd .. && node afterbuild",
19 "build-all": "rm -rf dist && npm run build && npm run build-frontend && npm run build-admin && npm audit --production && echo COMPLETED",
20 - "build-frontend": "cd frontend && npm install && npm run build",
21 - "build-admin": "cd admin && npm install && npm run build",
20 + "build-frontend": "cd frontend && npm run build",
21 + "build-admin": "cd admin && npm run build",
22 "test": "mocha -r ts-node/register 'tests/**/*.ts'",
23 "zip-dist": "cd dist && zip hfs.zip -r * -x *.zip *.exe",
24 "exe-dist": "pkg . -C brotli && cd dist && zip hfs.exe.zip hfs.exe -r plugins",
@@ -46,43 +46,5 @@
46 "node16-win"
47 ],
48 "outputPath": "dist"
49 - },
50 - "dependencies": {
51 - "@koa/router": "^10.1.1",
52 - "@node-rs/crc32": "^1.3.1",
53 - "buffer-crc32": "https://github.com/rejetto/buffer-crc32.git",
54 - "fast-glob": "^3.2.7",
55 - "find-process": "^1.4.7",
56 - "koa": "^2.13.4",
57 - "koa-compress": "^5.1.0",
58 - "koa-mount": "^4.0.0",
59 - "koa-session": "^6.2.0",
60 - "limiter": "^2.1.0",
61 - "lodash": "^4.17.21",
62 - "minimist": "^1.2.5",
63 - "open": "^8.4.0",
64 - "tssrp6a": "^3.0.0",
65 - "yaml": "^2.0.0-10"
66 - },
67 - "devDependencies": {
68 - "@types/archiver": "^5.1.1",
69 - "@types/axios": "^0.14.0",
70 - "@types/koa": "^2.13.4",
71 - "@types/koa__router": "^8.0.11",
72 - "@types/koa-compress": "^4.0.3",
73 - "@types/koa-mount": "^4.0.1",
74 - "@types/koa-session": "^5.10.4",
75 - "@types/lodash": "^4.14.178",
76 - "@types/micromatch": "^4.0.2",
77 - "@types/mime-types": "^2.1.1",
78 - "@types/minimist": "^1.2.2",
79 - "@types/mocha": "^9.0.0",
80 - "@types/node": "^16.11.12",
81 - "axios": "^0.24.0",
82 - "koa-better-http-proxy": "^0.2.9",
83 - "mocha": "^9.1.3",
84 - "nm-prune": "^5.0.0",
85 - "nodemon": "^2.0.15",
86 - "ts-node": "^10.4.0"
49 }
50 }
server/package.json new
+50
@@ -0,0 +1,50 @@
1 +{
2 + "name": "server",
3 + "engines": {
4 + "node": ">=16.13.0"
5 + },
6 + "files": [
7 + "dist/**/*"
8 + ],
9 + "bin": {
10 + "hfs": "dist/src/index.js"
11 + },
12 + "dependencies": {
13 + "@koa/router": "^10.1.1",
14 + "@node-rs/crc32": "^1.3.1",
15 + "buffer-crc32": "https://github.com/rejetto/buffer-crc32.git",
16 + "fast-glob": "^3.2.7",
17 + "find-process": "^1.4.7",
18 + "koa": "^2.13.4",
19 + "koa-compress": "^5.1.0",
20 + "koa-mount": "^4.0.0",
21 + "koa-session": "^6.2.0",
22 + "limiter": "^2.1.0",
23 + "lodash": "^4.17.21",
24 + "minimist": "^1.2.5",
25 + "open": "^8.4.0",
26 + "tssrp6a": "^3.0.0",
27 + "yaml": "^2.0.0-10"
28 + },
29 + "devDependencies": {
30 + "@types/archiver": "^5.1.1",
31 + "@types/axios": "^0.14.0",
32 + "@types/koa": "^2.13.4",
33 + "@types/koa__router": "^8.0.11",
34 + "@types/koa-compress": "^4.0.3",
35 + "@types/koa-mount": "^4.0.1",
36 + "@types/koa-session": "^5.10.4",
37 + "@types/lodash": "^4.14.178",
38 + "@types/micromatch": "^4.0.2",
39 + "@types/mime-types": "^2.1.1",
40 + "@types/minimist": "^1.2.2",
41 + "@types/mocha": "^9.0.0",
42 + "@types/node": "^16.11.12",
43 + "axios": "^0.24.0",
44 + "koa-better-http-proxy": "^0.2.9",
45 + "mocha": "^9.1.3",
46 + "nm-prune": "^5.0.0",
47 + "nodemon": "^2.0.15",
48 + "ts-node": "^10.4.0"
49 + }
50 +}
server/src/QuickZipStream.ts renamed
server/src/ThrottledStream.ts renamed
server/src/adminApis.ts renamed
server/src/api.accounts.ts renamed
server/src/api.auth.ts renamed
+7
@@ -117,3 +117,10 @@ export const change_password: ApiHandler = async ({ newPassword }, ctx) => {
117 export const change_srp: ApiHandler = async ({ salt, verifier }, ctx) => {
118 return changeSrpHelper(ctx.state.account, salt, verifier)
119 }
120 +
121 +/*
122 +export const admin_port: ApiHandler = async ({}, ctx) => {
123 + return ctx.state.admin ? { admin_port: getListeningAdminPort() }
124 + : new ApiError(403)
125 +}
126 +*/
server/src/api.file_list.ts renamed
server/src/api.helpers.ts renamed
server/src/api.vfs.ts renamed
server/src/apis.ts renamed
server/src/config.ts renamed
server/src/connections.ts renamed
server/src/const.ts renamed
server/src/crypt.ts renamed
server/src/events.ts renamed
server/src/frontEndApis.ts renamed
server/src/index.ts renamed
server/src/listen.ts renamed
server/src/log.ts renamed
server/src/middlewares.ts renamed
server/src/misc.ts renamed
server/src/pbkdf2.ts renamed
server/src/perm.ts renamed
server/src/plugins.ts renamed
server/src/serveFile.ts renamed
server/src/serveFrontend.ts renamed
server/src/sse.ts renamed
server/src/throttler.ts renamed
server/src/vfs.ts renamed
server/src/watchLoad.ts renamed
server/src/zip.ts renamed
tsconfig.json
+1 -1
@@ -26,7 +26,7 @@
26
27 /* Modules */
28 "module": "commonjs", /* Specify what module code is generated. */
29 - // "rootDir": "./", /* Specify the root folder within your source files. */
29 + "rootDir": "server/src", /* Specify the root folder within your source files. */
30 // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
31 // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32 // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */