Browse Source

Add REST routes and future dependencies

staging
David Ludwig 4 years ago
parent
commit
95ba463ab1
6 changed files with 58 additions and 19 deletions
  1. +1
    -1
      services/torrent-webui/.env.example
  2. +1
    -1
      services/torrent-webui/index.html
  3. +3
    -0
      services/torrent-webui/package.json
  4. +23
    -16
      services/torrent-webui/src/server/index.ts
  5. +8
    -1
      services/torrent-webui/tailwind.config.js
  6. +22
    -0
      services/torrent-webui/yarn.lock

+ 1
- 1
services/torrent-webui/.env.example View File

@ -1,2 +1,2 @@
SERVER_PORT = 3100
SERVER_PORT = 3300
TORRENT_CLIENT_IPC_SOCKET = /tmp/torrent_client.sock

+ 1
- 1
services/torrent-webui/index.html View File

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Autoplex Torrent</title>
</head>
<body>
<body class="bg-gray-900">
<div id="app"></div>
<script type="module" src="/src/app/index.ts"></script>
</body>


+ 3
- 0
services/torrent-webui/package.json View File

@ -15,6 +15,7 @@
"start:dev": "nodemon"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.3",
"fastify": "^3.14.1",
"fastify-formbody": "^5.0.0",
"fastify-http-proxy": "^5.0.0",
@ -22,6 +23,8 @@
"fastify-static": "^4.0.1",
"node-ipc": "^9.1.4",
"vue": "^3.0.5",
"vue-router": "^4.0.6",
"vuedraggable": "^4.0.1",
"websocket": "^1.0.33"
},
"devDependencies": {


+ 23
- 16
services/torrent-webui/src/server/index.ts View File

@ -54,23 +54,30 @@ server.get("/api/torrent/:infoHash", async (request, reply) => {
server.post("/api/torrent/add", async (request, reply) => {
let result: string[] = [];
if (request.isMultipart()) {
let files = request.files();
for await (let file of files) {
let torrentFile = await file.toBuffer();
let infoHash = await ipc.add(torrentFile);
result.push(infoHash);
}
} else {
assert(request.body !== undefined, "Invalid request: empty body");
let links = (<any>request.body)["link"];
assert(links !== undefined, "Invalid request: empty links");
for (let link of (Array.isArray(links) ? links : [links])) {
let infoHash = await ipc.add(link);
result.push(infoHash);
}
if (request.isMultipart()) {
let files = request.files();
for await (let file of files) {
let torrentFile = await file.toBuffer();
let infoHash = await ipc.add(torrentFile);
result.push(infoHash);
}
return { result: result };
} else {
assert(request.body !== undefined, "Invalid request: empty body");
let links = (<any>request.body)["link"];
assert(links !== undefined, "Invalid request: empty links");
for (let link of (Array.isArray(links) ? links : [links])) {
let infoHash = await ipc.add(link);
result.push(infoHash);
}
}
return { result: result };
});
server.delete("/api/torrent/remove/:infoHash", async (request, reply) => {
let infoHash: string = (<any>request.params)["infoHash"];
assert(infoHash != undefined);
await ipc.remove(infoHash);
return {}
});
// -------------------------------------------------------------------------------------------------


+ 8
- 1
services/torrent-webui/tailwind.config.js View File

@ -2,7 +2,14 @@ module.exports = {
purge: ["./index.html", "src/app/*.{vue,ts}"],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
extend: {
colors: {
ui: {
bg: "#191726",
fg: "#202332",
}
},
},
},
variants: {
extend: {},


+ 22
- 0
services/torrent-webui/yarn.lock View File

@ -34,6 +34,11 @@
"@fastify/forwarded" "^1.0.0"
ipaddr.js "^2.0.0"
"@fortawesome/fontawesome-free@^5.15.3":
version "5.15.3"
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.3.tgz#c36ffa64a2a239bf948541a97b6ae8d729e09a9a"
integrity sha512-rFnSUN/QOtnOAgqFRooTA3H57JLDm0QEG/jPdk+tLQNL/eWd+Aok8g3qCI+Q1xuDPWpGW/i9JySpJVsq8Q0s9w==
"@fullhuman/postcss-purgecss@^3.1.3":
version "3.1.3"
resolved "https://registry.yarnpkg.com/@fullhuman/postcss-purgecss/-/postcss-purgecss-3.1.3.tgz#47af7b87c9bfb3de4bc94a38f875b928fffdf339"
@ -2144,6 +2149,11 @@ sonic-boom@^1.0.2:
atomic-sleep "^1.0.0"
flatstr "^1.0.12"
sortablejs@1.10.2:
version "1.10.2"
resolved "https://registry.yarnpkg.com/sortablejs/-/sortablejs-1.10.2.tgz#6e40364d913f98b85a14f6678f92b5c1221f5290"
integrity sha512-YkPGufevysvfwn5rfdlGyrGjt7/CRHwvRPogD/lC+TnvcN29jDpCifKP+rBqf+LRldfXSTh+0CGLcSg0VIxq3A==
source-map-support@^0.5.17:
version "0.5.19"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61"
@ -2470,6 +2480,11 @@ vite@^2.1.5:
optionalDependencies:
fsevents "~2.3.1"
vue-router@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-4.0.6.tgz#91750db507d26642f225b0ec6064568e5fe448d6"
integrity sha512-Y04llmK2PyaESj+N33VxLjGCUDuv9t4q2OpItEGU7POZiuQZaugV6cJpE6Qm1sVFtxufodLKN2y2dQl9nk0Reg==
vue-tsc@^0.0.15:
version "0.0.15"
resolved "https://registry.yarnpkg.com/vue-tsc/-/vue-tsc-0.0.15.tgz#2951f0479bf0b966c828748927e8ea5b82a15070"
@ -2486,6 +2501,13 @@ vue@^3.0.5:
"@vue/runtime-dom" "3.0.11"
"@vue/shared" "3.0.11"
vuedraggable@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/vuedraggable/-/vuedraggable-4.0.1.tgz#3bcaab0808b7944030b7d9a29f9a63d59dfa12c5"
integrity sha512-7qN5jhB1SLfx5P+HCm3JUW+pvgA1bSLgYLSVOeLWBDH9z+zbaEH0OlyZBVMLOxFR+JUHJjwDD0oy7T4r9TEgDA==
dependencies:
sortablejs "1.10.2"
websocket@^1.0.33:
version "1.0.33"
resolved "https://registry.yarnpkg.com/websocket/-/websocket-1.0.33.tgz#407f763fc58e74a3fa41ca3ae5d78d3f5e3b82a5"


Loading…
Cancel
Save