Browse Source

Initial Commit with Fastify and Vite

staging
David Ludwig 4 years ago
parent
commit
8a3f70f198
19 changed files with 2530 additions and 0 deletions
  1. +0
    -0
      services/torrent-webui/.env.example
  2. +118
    -0
      services/torrent-webui/.gitignore
  3. +2
    -0
      services/torrent-webui/Dockerfile
  4. +3
    -0
      services/torrent-webui/README.md
  5. +13
    -0
      services/torrent-webui/index.html
  6. +6
    -0
      services/torrent-webui/nodemon.json
  7. +38
    -0
      services/torrent-webui/package.json
  8. BIN
      services/torrent-webui/public/favicon.ico
  9. +27
    -0
      services/torrent-webui/src/app/App.vue
  10. BIN
      services/torrent-webui/src/app/assets/logo.png
  11. +65
    -0
      services/torrent-webui/src/app/components/HelloWorld.vue
  12. +4
    -0
      services/torrent-webui/src/app/index.ts
  13. +5
    -0
      services/torrent-webui/src/app/shims-vue.d.ts
  14. +31
    -0
      services/torrent-webui/src/server/index.ts
  15. +74
    -0
      services/torrent-webui/tsconfig.json
  16. +12
    -0
      services/torrent-webui/tsconfig.server.json
  17. +22
    -0
      services/torrent-webui/tsconfig.vite.json
  18. +12
    -0
      services/torrent-webui/vite.config.ts
  19. +2098
    -0
      services/torrent-webui/yarn.lock

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


+ 118
- 0
services/torrent-webui/.gitignore View File

@ -0,0 +1,118 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
.data/
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
build
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

+ 2
- 0
services/torrent-webui/Dockerfile View File

@ -0,0 +1,2 @@
FROM node:14-alpine AS base
WORKDIR /app

+ 3
- 0
services/torrent-webui/README.md View File

@ -0,0 +1,3 @@
# Autoplex Torrent Web UI
A simple web interface for interfacing with the Autoplex Torrent client

+ 13
- 0
services/torrent-webui/index.html View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Autoplex Torrent</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/app/index.ts"></script>
</body>
</html>

+ 6
- 0
services/torrent-webui/nodemon.json View File

@ -0,0 +1,6 @@
{
"watch": ["src/server"],
"ext": "ts,json",
"ignore": ["src/**/*.spec.ts"],
"exec": "node --inspect=0.0.0.0:9229 -r ts-node/register src/server/index.ts"
}

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

@ -0,0 +1,38 @@
{
"name": "torrent-webui",
"version": "0.0.0",
"keywords": [],
"author": "David Ludwig",
"license": "ISC",
"main": "./build/server/index.js",
"scripts": {
"clean": "rimraf ./build",
"dev": "vite",
"build": "yarn run build:backend && yarn run build:frontend",
"build:backend": "tsc -p ./tsconfig.server.json",
"build:frontend": "vue-tsc --noEmit -p ./tsconfig.vite.json && vite build",
"start": "NODE_ENV=production node .",
"start:dev": "nodemon"
},
"dependencies": {
"fastify": "^3.14.1",
"fastify-formbody": "^5.0.0",
"fastify-http-proxy": "^5.0.0",
"fastify-multipart": "^4.0.3",
"fastify-static": "^4.0.1",
"node-ipc": "^9.1.4",
"vue": "^3.0.5",
"websocket": "^1.0.33"
},
"devDependencies": {
"@types/node-ipc": "^9.1.3",
"@vitejs/plugin-vue": "^1.2.1",
"@vue/compiler-sfc": "^3.0.5",
"nodemon": "^2.0.7",
"rimraf": "^3.0.2",
"ts-node": "^9.1.1",
"typescript": "^4.1.3",
"vite": "^2.1.5",
"vue-tsc": "^0.0.15"
}
}

BIN
services/torrent-webui/public/favicon.ico View File

Before After

+ 27
- 0
services/torrent-webui/src/app/App.vue View File

@ -0,0 +1,27 @@
<template>
<img alt="Vue logo" src="./assets/logo.png" />
<HelloWorld msg="Hello Vue 3 + TypeScript + Vite" />
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import HelloWorld from './components/HelloWorld.vue'
export default defineComponent({
name: 'App',
components: {
HelloWorld
}
})
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>

BIN
services/torrent-webui/src/app/assets/logo.png View File

Before After
Width: 200  |  Height: 200  |  Size: 6.7 KiB

+ 65
- 0
services/torrent-webui/src/app/components/HelloWorld.vue View File

@ -0,0 +1,65 @@
<template>
<h1>{{ msg }}</h1>
<p>
Recommended IDE setup:
<a href="https://code.visualstudio.com/" target="_blank">VSCode</a>
+
<a
href="https://marketplace.visualstudio.com/items?itemName=octref.vetur"
target="_blank"
>Vetur</a>
or
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
(if using
<code>&lt;script setup&gt;</code>)
</p>
<p>See <code>README.md</code> for more information.</p>
<p>
<a href="https://vitejs.dev/guide/features.html" target="_blank">Vite Docs</a> |
<a href="https://v3.vuejs.org/" target="_blank">Vue 3 Docs</a>
</p>
<button @click="count++">count is: {{ count }}</button>
<p>
Edit
<code>components/HelloWorld.vue</code> to test hot module replacement.
</p>
</template>
<script lang="ts">
import { ref, defineComponent } from 'vue'
export default defineComponent({
name: 'HelloWorld',
props: {
msg: {
type: String,
required: true
}
},
setup: () => {
const count = ref(0)
return { count }
}
})
</script>
<style scoped>
a {
color: #42b983;
}
label {
margin: 0 0.5em;
font-weight: bold;
}
code {
background-color: #eee;
padding: 2px 4px;
border-radius: 4px;
color: #304455;
}
</style>

+ 4
- 0
services/torrent-webui/src/app/index.ts View File

@ -0,0 +1,4 @@
import { createApp } from 'vue'
import App from './App.vue'
createApp(App).mount('#app')

+ 5
- 0
services/torrent-webui/src/app/shims-vue.d.ts View File

@ -0,0 +1,5 @@
declare module '*.vue' {
import { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}

+ 31
- 0
services/torrent-webui/src/server/index.ts View File

@ -0,0 +1,31 @@
import fastify from "fastify";
import fastifyStatic from "fastify-static";
import fastifyHttpProxy from "fastify-http-proxy";
import { join } from "path";
let server = fastify();
/**
* If the app is in production mode, serve static assets.
* If the app is in development mode, forward 404's to Vite.
* NOTE: Static assets may be moved to nginx later... not sure yet
*/
if (process.env["NODE_ENV"] == "production") {
server.register(fastifyStatic, {
root: join(__dirname, "../public")
});
server.setNotFoundHandler((request, reply) => {
console.log("Replying with default");
return reply.sendFile("index.html");
});
} else {
server.register(fastifyHttpProxy, {
upstream: "http://localhost:3000"
});
}
server.get("/test", (request, reply) => {
reply.send({result: "Success"})
});
server.listen(parseInt(<string>process.env["SERVER_PORT"]), "0.0.0.0");

+ 74
- 0
services/torrent-webui/tsconfig.json View File

@ -0,0 +1,74 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
// "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
// "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./build", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
"emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"include": [
"src"
]
}

+ 12
- 0
services/torrent-webui/tsconfig.server.json View File

@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"outDir": "build/server", /* Redirect output structure to the directory. */
"sourceRoot": "src/server" /* Specify the location where debugger should locate TypeScript files instead of source locations. */
},
"exclude": [
"src/app"
]
}

+ 22
- 0
services/torrent-webui/tsconfig.vite.json View File

@ -0,0 +1,22 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"jsx": "preserve",
"resolveJsonModule": true,
"lib": ["esnext", "dom"],
"types": ["vite/client"],
"sourceRoot": "src/app"
},
"include": [
"src/app/**/*.ts",
"src/app**/*.d.ts",
"src/app/**/*.tsx",
"src/app/**/*.vue"
],
"exclude": [
"src/server"
]
}

+ 12
- 0
services/torrent-webui/vite.config.ts View File

@ -0,0 +1,12 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from "path";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
build: {
manifest: true,
outDir: "./build/public"
}
})

+ 2098
- 0
services/torrent-webui/yarn.lock
File diff suppressed because it is too large
View File


Loading…
Cancel
Save