diff --git a/ecosystem.config.js b/ecosystem.config.js index 57f494cc..8c5e3220 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -5,7 +5,7 @@ module.exports = { name: pkg.name, exec_mode: 'cluster', instances: 1, // 'max' Or a number of instances - script: './api/app.js', // './node_modules/nuxt/bin/nuxt.js', + script: './src/api/app.cjs', // './node_modules/nuxt/bin/nuxt.js', args: 'start' } ] diff --git a/package.json b/package.json index fdc92265..aad3dd5b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pi-control", "productName": "Pi-Control 🐱‍👤", - "version": "0.0.1-alpha.2", + "version": "0.0.1-alpha.3", "description": "Pi-Control helps with gathering information, as well as to simplify controlling your raspberry pi.", "author": "borsTiHD", "license": "MIT", @@ -11,11 +11,13 @@ }, "type": "module", "scripts": { - "dev:nuxt": "nuxt", - "dev:api": "node -r dotenv/config ./api/app.js", + "dev:nuxt": "nuxt src/client", + "dev:api": "node -r dotenv/config ./src/api/app.js", "dev": "cross-env NODE_ENV=development concurrently \"yarn dev:api\" \"yarn dev:nuxt\"", - "generate": "nuxt generate", - "start": "node -r dotenv/config ./api/app.js", + "generate:nuxt": "nuxt generate src/client", + "build:server": "webpack", + "build": "yarn generate:nuxt && yarn build:server", + "start": "node -r dotenv/config ./dist/server/app.cjs", "lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .", "lint": "yarn lint:js" }, @@ -49,6 +51,9 @@ "passport": "^0.4.1", "passport-jwt": "^4.0.0", "passport-local": "^1.0.0", - "vue-toastification": "^1.7.11" + "vue-toastification": "^1.7.11", + "webpack": "^5.38.1", + "webpack-cli": "^4.7.0", + "webpack-node-externals": "^3.0.0" } } diff --git a/api/app.js b/src/api/app.js similarity index 86% rename from api/app.js rename to src/api/app.js index 0a383fa0..9f8269f9 100644 --- a/api/app.js +++ b/src/api/app.js @@ -1,4 +1,5 @@ // Imports +import path from 'path' import createError from 'http-errors' import express from 'express' import cors from 'cors' @@ -12,15 +13,16 @@ import baseRoutes from './router.js' // Development const isDev = process.env.NODE_ENV === 'development' -console.log('[App] -> Development:', isDev) +console.log('[Server] -> Development:', isDev) // Config const PORT = process.env.PORT || 8800 // Default Port: 8800 +const DIST_DIR = path.join('dist', 'client') // Express Init const app = express() if (isDev) app.use(cors()) // CORS policy only in dev -app.use(express.static('dist')) +app.use(express.static(DIST_DIR)) app.use(express.json()) app.use(express.urlencoded({ extended: true })) // for form data app.use(cookieParser()) // Cookies @@ -53,5 +55,5 @@ app.use((err, req, res, next) => { // Listening on port app.listen(PORT, () => { - console.log(`[App] -> App is running on ${PORT}`) + console.log(`[Server] -> App is running on ${PORT}`) }) diff --git a/classes/ChildProcessClass.js b/src/api/classes/ChildProcessClass.js similarity index 100% rename from classes/ChildProcessClass.js rename to src/api/classes/ChildProcessClass.js diff --git a/api/controllers/authentication.controller.js b/src/api/controllers/authentication.controller.js similarity index 100% rename from api/controllers/authentication.controller.js rename to src/api/controllers/authentication.controller.js diff --git a/api/controllers/scripts.controller.js b/src/api/controllers/scripts.controller.js similarity index 99% rename from api/controllers/scripts.controller.js rename to src/api/controllers/scripts.controller.js index 37ab970a..ce558d4d 100644 --- a/api/controllers/scripts.controller.js +++ b/src/api/controllers/scripts.controller.js @@ -8,7 +8,7 @@ import isCustomScript from '../middleware/isCustomScript.js' // Testing if given import zipDirectory from '../middleware/zipDirectory.js' // Zipping file/folder middleware // ChildProcess Spawn Import -import ChildProcessClass from '../../classes/ChildProcessClass.js' +import ChildProcessClass from '../classes/ChildProcessClass.js' const childProcessSpawn = new ChildProcessClass() // Script Directory diff --git a/api/middleware/asyncHandler.js b/src/api/middleware/asyncHandler.js similarity index 100% rename from api/middleware/asyncHandler.js rename to src/api/middleware/asyncHandler.js diff --git a/api/middleware/isCustomScript.js b/src/api/middleware/isCustomScript.js similarity index 100% rename from api/middleware/isCustomScript.js rename to src/api/middleware/isCustomScript.js diff --git a/api/middleware/zipDirectory.js b/src/api/middleware/zipDirectory.js similarity index 100% rename from api/middleware/zipDirectory.js rename to src/api/middleware/zipDirectory.js diff --git a/api/models/user.js b/src/api/models/user.js similarity index 100% rename from api/models/user.js rename to src/api/models/user.js diff --git a/api/router.js b/src/api/router.js similarity index 100% rename from api/router.js rename to src/api/router.js diff --git a/api/routes/authentication.js b/src/api/routes/authentication.js similarity index 100% rename from api/routes/authentication.js rename to src/api/routes/authentication.js diff --git a/api/routes/help.js b/src/api/routes/help.js similarity index 100% rename from api/routes/help.js rename to src/api/routes/help.js diff --git a/api/routes/index.js b/src/api/routes/index.js similarity index 100% rename from api/routes/index.js rename to src/api/routes/index.js diff --git a/api/routes/scripts.js b/src/api/routes/scripts.js similarity index 100% rename from api/routes/scripts.js rename to src/api/routes/scripts.js diff --git a/assets/README.md b/src/client/assets/README.md similarity index 100% rename from assets/README.md rename to src/client/assets/README.md diff --git a/assets/variables.scss b/src/client/assets/variables.scss similarity index 100% rename from assets/variables.scss rename to src/client/assets/variables.scss diff --git a/components/alerts/Alert.vue b/src/client/components/alerts/Alert.vue similarity index 100% rename from components/alerts/Alert.vue rename to src/client/components/alerts/Alert.vue diff --git a/components/alerts/Alerts.vue b/src/client/components/alerts/Alerts.vue similarity index 100% rename from components/alerts/Alerts.vue rename to src/client/components/alerts/Alerts.vue diff --git a/components/dashboard/CpuInfo.vue b/src/client/components/dashboard/CpuInfo.vue similarity index 100% rename from components/dashboard/CpuInfo.vue rename to src/client/components/dashboard/CpuInfo.vue diff --git a/components/dashboard/Device.vue b/src/client/components/dashboard/Device.vue similarity index 100% rename from components/dashboard/Device.vue rename to src/client/components/dashboard/Device.vue diff --git a/components/dashboard/Diskspace.vue b/src/client/components/dashboard/Diskspace.vue similarity index 100% rename from components/dashboard/Diskspace.vue rename to src/client/components/dashboard/Diskspace.vue diff --git a/components/dashboard/Memory.vue b/src/client/components/dashboard/Memory.vue similarity index 100% rename from components/dashboard/Memory.vue rename to src/client/components/dashboard/Memory.vue diff --git a/components/dashboard/Swap.vue b/src/client/components/dashboard/Swap.vue similarity index 100% rename from components/dashboard/Swap.vue rename to src/client/components/dashboard/Swap.vue diff --git a/components/dashboard/System.vue b/src/client/components/dashboard/System.vue similarity index 100% rename from components/dashboard/System.vue rename to src/client/components/dashboard/System.vue diff --git a/components/dashboard/Temperature.vue b/src/client/components/dashboard/Temperature.vue similarity index 100% rename from components/dashboard/Temperature.vue rename to src/client/components/dashboard/Temperature.vue diff --git a/components/dashboard/Uptime.vue b/src/client/components/dashboard/Uptime.vue similarity index 100% rename from components/dashboard/Uptime.vue rename to src/client/components/dashboard/Uptime.vue diff --git a/components/dev/Tests.vue b/src/client/components/dev/Tests.vue similarity index 100% rename from components/dev/Tests.vue rename to src/client/components/dev/Tests.vue diff --git a/components/display/AppUpdateChip.vue b/src/client/components/display/AppUpdateChip.vue similarity index 100% rename from components/display/AppUpdateChip.vue rename to src/client/components/display/AppUpdateChip.vue diff --git a/components/display/AppVersion.vue b/src/client/components/display/AppVersion.vue similarity index 97% rename from components/display/AppVersion.vue rename to src/client/components/display/AppVersion.vue index 93766de0..6792078b 100644 --- a/components/display/AppVersion.vue +++ b/src/client/components/display/AppVersion.vue @@ -35,7 +35,7 @@ import axios from 'axios' import { mapGetters, mapActions } from 'vuex' -import pkg from '~~/package.json' +import pkg from 'projRoot/package.json' export default { name: 'AppVersion', @@ -49,7 +49,7 @@ export default { getReleaseData: 'getReleaseData' }), currentVersion() { - return `v.${pkg.version}` + return `v${pkg.version}` }, latestVersion() { if (this.getReleaseData) { diff --git a/components/forms/AuthentiactionForm.vue b/src/client/components/forms/AuthentiactionForm.vue similarity index 100% rename from components/forms/AuthentiactionForm.vue rename to src/client/components/forms/AuthentiactionForm.vue diff --git a/components/layout/Footer.vue b/src/client/components/layout/Footer.vue similarity index 96% rename from components/layout/Footer.vue rename to src/client/components/layout/Footer.vue index 13f7ba96..56ec40a1 100644 --- a/components/layout/Footer.vue +++ b/src/client/components/layout/Footer.vue @@ -9,7 +9,7 @@