From 59e4a3b45df6ad30abaa89190175ba5bf86820dc Mon Sep 17 00:00:00 2001 From: Lordmau5 Date: Sun, 5 May 2024 12:59:08 +0200 Subject: [PATCH] =?UTF-8?q?Den=20Aufschl=C3=A4ger=20mit=20dem=20Klienten?= =?UTF-8?q?=20verbinden=20und=20arbeiten=20lassen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/.eslintignore | 6 - client/.eslintrc.cjs | 66 - client/.gitignore | 45 +- client/.npmrc | 3 - client/.vscode/extensions.json | 14 - client/.vscode/settings.json | 15 - client/README.md | 74 +- client/app.vue | 7 + client/eslint.config.mjs | 72 + client/index.html | 17 - client/jsconfig.json | 40 - .../MainLayout.vue => layouts/default.vue} | 31 +- client/nuxt.config.ts | 15 + client/package.json | 50 +- .../entry/[slug].vue} | 70 +- client/pages/index.vue | 5 + client/pnpm-lock.yaml | 9014 +++++++++++++---- client/postcss.config.cjs | 27 - client/public/favicon.ico | Bin 64483 -> 4286 bytes client/public/icons/favicon-128x128.png | Bin 12324 -> 0 bytes client/public/icons/favicon-16x16.png | Bin 859 -> 0 bytes client/public/icons/favicon-32x32.png | Bin 2039 -> 0 bytes client/public/icons/favicon-96x96.png | Bin 9643 -> 0 bytes client/public/muchbild.png | Bin 10069 -> 0 bytes client/quasar.config.js | 212 - client/scripts/api.ts | 23 + client/server/tsconfig.json | 3 + client/src/App.vue | 13 - client/src/assets/quasar-logo-vertical.svg | 15 - client/src/boot/.gitkeep | 0 client/src/css/app.scss | 1 - client/src/css/quasar.variables.scss | 25 - client/src/pages/ErrorNotFound.vue | 34 - client/src/router/index.js | 30 - client/src/router/routes.js | 19 - client/src/stores/personen-store.js | 25 - client/src/stores/store-flag.d.ts | 10 - .../{src/stores/index.js => stores/index.ts} | 0 client/stores/personen-store.ts | 17 + client/tsconfig.json | 4 + server/src/db/database.ts | 4 +- server/src/entries/entries.controller.ts | 2 +- server/src/main.ts | 3 +- 43 files changed, 7601 insertions(+), 2410 deletions(-) delete mode 100644 client/.eslintignore delete mode 100644 client/.eslintrc.cjs delete mode 100644 client/.npmrc delete mode 100644 client/.vscode/extensions.json delete mode 100644 client/.vscode/settings.json create mode 100644 client/app.vue create mode 100644 client/eslint.config.mjs delete mode 100644 client/index.html delete mode 100644 client/jsconfig.json rename client/{src/layouts/MainLayout.vue => layouts/default.vue} (57%) create mode 100644 client/nuxt.config.ts rename client/{src/pages/RechnerSeite.vue => pages/entry/[slug].vue} (85%) create mode 100644 client/pages/index.vue delete mode 100644 client/postcss.config.cjs delete mode 100644 client/public/icons/favicon-128x128.png delete mode 100644 client/public/icons/favicon-16x16.png delete mode 100644 client/public/icons/favicon-32x32.png delete mode 100644 client/public/icons/favicon-96x96.png delete mode 100644 client/public/muchbild.png delete mode 100644 client/quasar.config.js create mode 100644 client/scripts/api.ts create mode 100644 client/server/tsconfig.json delete mode 100644 client/src/App.vue delete mode 100644 client/src/assets/quasar-logo-vertical.svg delete mode 100644 client/src/boot/.gitkeep delete mode 100644 client/src/css/app.scss delete mode 100644 client/src/css/quasar.variables.scss delete mode 100644 client/src/pages/ErrorNotFound.vue delete mode 100644 client/src/router/index.js delete mode 100644 client/src/router/routes.js delete mode 100644 client/src/stores/personen-store.js delete mode 100644 client/src/stores/store-flag.d.ts rename client/{src/stores/index.js => stores/index.ts} (100%) create mode 100644 client/stores/personen-store.ts create mode 100644 client/tsconfig.json diff --git a/client/.eslintignore b/client/.eslintignore deleted file mode 100644 index 263e5eb..0000000 --- a/client/.eslintignore +++ /dev/null @@ -1,6 +0,0 @@ -/dist -/src-capacitor -/src-cordova -/.quasar -/node_modules -.eslintrc.js diff --git a/client/.eslintrc.cjs b/client/.eslintrc.cjs deleted file mode 100644 index b749b88..0000000 --- a/client/.eslintrc.cjs +++ /dev/null @@ -1,66 +0,0 @@ -module.exports = { - // https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy - // This option interrupts the configuration hierarchy at this file - // Remove this if you have an higher level ESLint config file (it usually happens into a monorepos) - root: true, - parserOptions: { - ecmaVersion: '2021', // Allows for the parsing of modern ECMAScript features - }, - env: { - node: true, - browser: true, - 'vue/setup-compiler-macros': true, - }, - - // Rules order is important, please avoid shuffling them - extends: ['plugin:vue/vue3-recommended', 'eslint:recommended'], - plugins: [ - // https://eslint.vuejs.org/user-guide/#why-doesn-t-it-work-on-vue-files - // required to lint *.vue files - 'vue', - ], - globals: { - ga: 'readonly', // Google Analytics - cordova: 'readonly', - __statics: 'readonly', - __QUASAR_SSR__: 'readonly', - __QUASAR_SSR_SERVER__: 'readonly', - __QUASAR_SSR_CLIENT__: 'readonly', - __QUASAR_SSR_PWA__: 'readonly', - process: 'readonly', - Capacitor: 'readonly', - chrome: 'readonly', - }, - - // add your custom rules here - rules: { - 'no-param-reassign': 'off', - 'no-void': 'off', - 'no-nested-ternary': 'off', - 'max-classes-per-file': 'off', - 'prefer-promise-reject-errors': 'off', - - // allow debugger during development only - 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', - - // custom - 'vue/require-prop-types': 0, - 'vue/html-indent': ['error', 'tab'], - 'vue/multi-word-component-names': 0, - indent: ['error', 'tab'], - 'linebreak-style': ['error', 'unix'], - quotes: ['error', 'single'], - semi: ['error', 'always'], - 'space-before-function-paren': ['error', 'always'], - 'comma-dangle': ['error', 'always-multiline'], - 'no-multiple-empty-lines': ['error', { 'max': 1, 'maxEOF': 0 }], - }, - overrides: [ - { - files: ['*.html'], - rules: { - 'vue/comment-directive': 'off', - }, - }, - ], -}; diff --git a/client/.gitignore b/client/.gitignore index 06ff1aa..4a7f73a 100644 --- a/client/.gitignore +++ b/client/.gitignore @@ -1,29 +1,24 @@ -.DS_Store -.thumbs.db +# Nuxt dev/build outputs +.output +.data +.nuxt +.nitro +.cache +dist + +# Node dependencies node_modules -# Quasar core related directories -.quasar -/dist +# Logs +logs +*.log -# Cordova related directories and files -/src-cordova/node_modules -/src-cordova/platforms -/src-cordova/plugins -/src-cordova/www - -# Capacitor related directories and files -/src-capacitor/www -/src-capacitor/node_modules - -# Log files -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# Editor directories and files +# Misc +.DS_Store +.fleet .idea -*.suo -*.ntvs* -*.njsproj -*.sln + +# Local env files +.env +.env.* +!.env.example diff --git a/client/.npmrc b/client/.npmrc deleted file mode 100644 index 32bd84d..0000000 --- a/client/.npmrc +++ /dev/null @@ -1,3 +0,0 @@ -# pnpm-related options -shamefully-hoist=true -strict-peer-dependencies=false diff --git a/client/.vscode/extensions.json b/client/.vscode/extensions.json deleted file mode 100644 index 518f8c8..0000000 --- a/client/.vscode/extensions.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "recommendations": [ - "dbaeumer.vscode-eslint", - "editorconfig.editorconfig", - "vue.volar", - "wayou.vscode-todo-highlight" - ], - "unwantedRecommendations": [ - "octref.vetur", - "hookyqr.beautify", - "dbaeumer.jshint", - "ms-vscode.vscode-typescript-tslint-plugin" - ] -} \ No newline at end of file diff --git a/client/.vscode/settings.json b/client/.vscode/settings.json deleted file mode 100644 index fc76e75..0000000 --- a/client/.vscode/settings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "editor.bracketPairColorization.enabled": true, - "editor.guides.bracketPairs": true, - "editor.formatOnSave": true, - "editor.defaultFormatter": "dbaeumer.vscode-eslint", - "editor.codeActionsOnSave": [ - "source.fixAll.eslint" - ], - "eslint.validate": [ - "javascript", - "javascriptreact", - "typescript", - "vue" - ] -} \ No newline at end of file diff --git a/client/README.md b/client/README.md index c743fc1..f5db2a2 100644 --- a/client/README.md +++ b/client/README.md @@ -1,33 +1,75 @@ -# It's Bingo Time (itsbingotime) +# Nuxt 3 Minimal Starter -A bingo editor and generator +Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more. + +## Setup + +Make sure to install the dependencies: -## Install the dependencies ```bash -yarn -# or +# npm npm install + +# pnpm +pnpm install + +# yarn +yarn install + +# bun +bun install ``` -### Start the app in development mode (hot-code reloading, error reporting, etc.) +## Development Server + +Start the development server on `http://localhost:3000`: + ```bash -quasar dev +# npm +npm run dev + +# pnpm +pnpm run dev + +# yarn +yarn dev + +# bun +bun run dev ``` +## Production + +Build the application for production: -### Lint the files ```bash -yarn lint -# or -npm run lint +# npm +npm run build + +# pnpm +pnpm run build + +# yarn +yarn build + +# bun +bun run build ``` +Locally preview production build: - -### Build the app for production ```bash -quasar build +# npm +npm run preview + +# pnpm +pnpm run preview + +# yarn +yarn preview + +# bun +bun run preview ``` -### Customize the configuration -See [Configuring quasar.config.js](https://v2.quasar.dev/quasar-cli-vite/quasar-config-js). +Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information. diff --git a/client/app.vue b/client/app.vue new file mode 100644 index 0000000..acde7b0 --- /dev/null +++ b/client/app.vue @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/client/eslint.config.mjs b/client/eslint.config.mjs new file mode 100644 index 0000000..32371be --- /dev/null +++ b/client/eslint.config.mjs @@ -0,0 +1,72 @@ +import withNuxt from './.nuxt/eslint.config.mjs' + +export default withNuxt( + { + // https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy + // This option interrupts the configuration hierarchy at this file + // Remove this if you have an higher level ESLint config file (it usually happens into a monorepos) + root: true, + // parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: '2021', // Allows for the parsing of modern ECMAScript features + parser: '@typescript-eslint/parser', + }, + env: { + node: true, + browser: true, + 'vue/setup-compiler-macros': true, + }, + + // Rules order is important, please avoid shuffling them + extends: ['plugin:vue/vue3-recommended', 'eslint:recommended'], + plugins: [ + // https://eslint.vuejs.org/user-guide/#why-doesn-t-it-work-on-vue-files + // required to lint *.vue files + 'vue', + ], + globals: { + ga: 'readonly', // Google Analytics + cordova: 'readonly', + __statics: 'readonly', + __QUASAR_SSR__: 'readonly', + __QUASAR_SSR_SERVER__: 'readonly', + __QUASAR_SSR_CLIENT__: 'readonly', + __QUASAR_SSR_PWA__: 'readonly', + process: 'readonly', + Capacitor: 'readonly', + chrome: 'readonly', + }, + + // add your custom rules here + rules: { + 'no-param-reassign': 'off', + 'no-void': 'off', + 'no-nested-ternary': 'off', + 'max-classes-per-file': 'off', + 'prefer-promise-reject-errors': 'off', + + // allow debugger during development only + 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', + + // custom + 'vue/require-prop-types': 0, + 'vue/html-indent': ['error', 'tab'], + 'vue/multi-word-component-names': 0, + indent: ['error', 'tab'], + 'linebreak-style': ['error', 'unix'], + quotes: ['error', 'single'], + semi: ['error', 'always'], + 'space-before-function-paren': ['error', 'always'], + 'comma-dangle': ['error', 'always-multiline'], + 'no-multiple-empty-lines': ['error', { 'max': 1, 'maxEOF': 0 }], + }, + overrides: [ + { + files: ['*.html'], + rules: { + 'vue/comment-directive': 'off', + }, + }, + ], + } +) \ No newline at end of file diff --git a/client/index.html b/client/index.html deleted file mode 100644 index 314acb3..0000000 --- a/client/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - <%= productName %> - - - - - - - - - - - - - diff --git a/client/jsconfig.json b/client/jsconfig.json deleted file mode 100644 index 5a570a8..0000000 --- a/client/jsconfig.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "compilerOptions": { - "allowJs": true, - "baseUrl": ".", - "paths": { - "src/*": [ - "src/*" - ], - "app/*": [ - "*" - ], - "components/*": [ - "src/components/*" - ], - "layouts/*": [ - "src/layouts/*" - ], - "pages/*": [ - "src/pages/*" - ], - "assets/*": [ - "src/assets/*" - ], - "boot/*": [ - "src/boot/*" - ], - "stores/*": [ - "src/stores/*" - ], - "vue$": [ - "node_modules/vue/dist/vue.runtime.esm-bundler.js" - ] - } - }, - "exclude": [ - "dist", - ".quasar", - "node_modules" - ] -} \ No newline at end of file diff --git a/client/src/layouts/MainLayout.vue b/client/layouts/default.vue similarity index 57% rename from client/src/layouts/MainLayout.vue rename to client/layouts/default.vue index efc414f..1c556a4 100644 --- a/client/src/layouts/MainLayout.vue +++ b/client/layouts/default.vue @@ -30,33 +30,44 @@ - + + - diff --git a/client/src/assets/quasar-logo-vertical.svg b/client/src/assets/quasar-logo-vertical.svg deleted file mode 100644 index 8210831..0000000 --- a/client/src/assets/quasar-logo-vertical.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/client/src/boot/.gitkeep b/client/src/boot/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/client/src/css/app.scss b/client/src/css/app.scss deleted file mode 100644 index ecac98f..0000000 --- a/client/src/css/app.scss +++ /dev/null @@ -1 +0,0 @@ -// app global css in SCSS form diff --git a/client/src/css/quasar.variables.scss b/client/src/css/quasar.variables.scss deleted file mode 100644 index 3996ce1..0000000 --- a/client/src/css/quasar.variables.scss +++ /dev/null @@ -1,25 +0,0 @@ -// Quasar SCSS (& Sass) Variables -// -------------------------------------------------- -// To customize the look and feel of this app, you can override -// the Sass/SCSS variables found in Quasar's source Sass/SCSS files. - -// Check documentation for full list of Quasar variables - -// Your own variables (that are declared here) and Quasar's own -// ones will be available out of the box in your .vue/.scss/.sass files - -// It's highly recommended to change the default colors -// to match your app's branding. -// Tip: Use the "Theme Builder" on Quasar's documentation website. - -$primary : #1976D2; -$secondary : #26A69A; -$accent : #9C27B0; - -$dark : #1D1D1D; -$dark-page : #121212; - -$positive : #21BA45; -$negative : #C10015; -$info : #31CCEC; -$warning : #F2C037; diff --git a/client/src/pages/ErrorNotFound.vue b/client/src/pages/ErrorNotFound.vue deleted file mode 100644 index fd55ead..0000000 --- a/client/src/pages/ErrorNotFound.vue +++ /dev/null @@ -1,34 +0,0 @@ - - - diff --git a/client/src/router/index.js b/client/src/router/index.js deleted file mode 100644 index 0ca0ba8..0000000 --- a/client/src/router/index.js +++ /dev/null @@ -1,30 +0,0 @@ -import { route } from 'quasar/wrappers'; -import { createRouter, createMemoryHistory, createWebHistory, createWebHashHistory } from 'vue-router'; -import routes from './routes'; - -/* - * If not building with SSR mode, you can - * directly export the Router instantiation; - * - * The function below can be async too; either use - * async/await or return a Promise which resolves - * with the Router instance. - */ - -export default route(function (/* { store, ssrContext } */) { - const createHistory = process.env.SERVER - ? createMemoryHistory - : (process.env.VUE_ROUTER_MODE === 'history' ? createWebHistory : createWebHashHistory); - - const Router = createRouter({ - scrollBehavior: () => ({ left: 0, top: 0 }), - routes, - - // Leave this as is and make changes in quasar.conf.js instead! - // quasar.conf.js -> build -> vueRouterMode - // quasar.conf.js -> build -> publicPath - history: createHistory(process.env.VUE_ROUTER_BASE), - }); - - return Router; -}); diff --git a/client/src/router/routes.js b/client/src/router/routes.js deleted file mode 100644 index 4076900..0000000 --- a/client/src/router/routes.js +++ /dev/null @@ -1,19 +0,0 @@ - -const routes = [ - { - path: '/', - component: () => import('layouts/MainLayout.vue'), - children: [ - { path: '', component: () => import('pages/RechnerSeite.vue') }, - ], - }, - - // Always leave this as last one, - // but you can also remove it - { - path: '/:catchAll(.*)*', - component: () => import('pages/ErrorNotFound.vue'), - }, -]; - -export default routes; diff --git a/client/src/stores/personen-store.js b/client/src/stores/personen-store.js deleted file mode 100644 index bbe72d8..0000000 --- a/client/src/stores/personen-store.js +++ /dev/null @@ -1,25 +0,0 @@ -import { defineStore } from 'pinia'; - -export const usePersonenStore = defineStore('personen', { - state: () => ({ - personen: {}, - }), - actions: { - load () { - this.personen.value = {}; - - try { - if (localStorage.personen) - this.personen.value = JSON.parse(localStorage.getItem('personen')); - - console.log(this.personen.value); - } - catch(_) { - // Nothing - } - }, - save () { - localStorage.setItem('personen', JSON.stringify(this.personen.value)); - }, - }, -}); diff --git a/client/src/stores/store-flag.d.ts b/client/src/stores/store-flag.d.ts deleted file mode 100644 index 7677175..0000000 --- a/client/src/stores/store-flag.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* eslint-disable */ -// THIS FEATURE-FLAG FILE IS AUTOGENERATED, -// REMOVAL OR CHANGES WILL CAUSE RELATED TYPES TO STOP WORKING -import "quasar/dist/types/feature-flag"; - -declare module "quasar/dist/types/feature-flag" { - interface QuasarFeatureFlags { - store: true; - } -} diff --git a/client/src/stores/index.js b/client/stores/index.ts similarity index 100% rename from client/src/stores/index.js rename to client/stores/index.ts diff --git a/client/stores/personen-store.ts b/client/stores/personen-store.ts new file mode 100644 index 0000000..84426e7 --- /dev/null +++ b/client/stores/personen-store.ts @@ -0,0 +1,17 @@ +import { defineStore } from 'pinia'; +import { getEntryBySlug, updateEntry } from '~/scripts/api.js'; + +export const usePersonenStore = defineStore('personen', { + state: () => ({ + personen: {} as { [key: string]: any }, + }), + actions: { + async loadRemote(slug: string) { + const result = await getEntryBySlug(slug); + this.personen = result?.data || {}; + }, + async saveRemote(slug: string) { + await updateEntry(slug, this.personen); + } + }, +}); diff --git a/client/tsconfig.json b/client/tsconfig.json new file mode 100644 index 0000000..a746f2a --- /dev/null +++ b/client/tsconfig.json @@ -0,0 +1,4 @@ +{ + // https://nuxt.com/docs/guide/concepts/typescript + "extends": "./.nuxt/tsconfig.json" +} diff --git a/server/src/db/database.ts b/server/src/db/database.ts index 606ed11..68385ce 100644 --- a/server/src/db/database.ts +++ b/server/src/db/database.ts @@ -38,13 +38,13 @@ class Database { DEFINE INDEX slug_index ON TABLE entries COLUMNS slug UNIQUE; DEFINE FIELD expires_at ON TABLE entries TYPE datetime - DEFAULT time::now() + duration::from::secs(30); + DEFAULT time::now() + duration::from::days(7); DEFINE FIELD data ON TABLE entries FLEXIBLE TYPE object DEFAULT {}; DEFINE EVENT updated ON TABLE entries WHEN $before.data != $after.data THEN ( - UPDATE entries SET expires_at = (time::now() + duration::from::secs(30)) WHERE slug = $after.slug + UPDATE entries SET expires_at = (time::now() + duration::from::days(7)) WHERE slug = $after.slug ); `); } diff --git a/server/src/entries/entries.controller.ts b/server/src/entries/entries.controller.ts index 3f4fcbc..616523e 100644 --- a/server/src/entries/entries.controller.ts +++ b/server/src/entries/entries.controller.ts @@ -2,7 +2,7 @@ import { Body, Controller, Delete, Get, Param, Post, Put } from '@nestjs/common' import { EntriesService } from '~/entries/entries.service'; import { Entry } from '~/entries/interfaces/entry.type'; -@Controller('entries') +@Controller('api/entries') export class EntriesController { constructor(private entriesService: EntriesService) {} diff --git a/server/src/main.ts b/server/src/main.ts index 4a73d5a..0989cd2 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -7,6 +7,7 @@ async function bootstrap() { await Database.init(); const app = await NestFactory.create(AppModule); - await app.listen(3000); + app.enableCors(); + await app.listen(3001); } bootstrap();