From 30a817563e1e049cc501867fb63a02db08456972 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Fri, 24 Feb 2023 10:47:35 +0000 Subject: [PATCH 1/7] remove deprecated .use() loader calls --- frontend/src/routes/(admin)/settings/migration/index.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/src/routes/(admin)/settings/migration/index.tsx b/frontend/src/routes/(admin)/settings/migration/index.tsx index 56c793c..9998c90 100644 --- a/frontend/src/routes/(admin)/settings/migration/index.tsx +++ b/frontend/src/routes/(admin)/settings/migration/index.tsx @@ -15,6 +15,8 @@ export const loader = loader$(async ({ redirect }) => { }) export default component$(() => { + loader() + return (

Account Migration

From c184d28e4f530fd788a0ef618a86dcbe8bd797d1 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Fri, 24 Feb 2023 11:00:49 +0000 Subject: [PATCH 2/7] improve dev/todo loaders --- frontend/src/routes/(admin)/settings/aliases/index.tsx | 2 +- frontend/src/routes/(admin)/settings/layout.tsx | 9 +++++++++ frontend/src/routes/(admin)/settings/migration/index.tsx | 2 -- frontend/src/routes/(frontend)/about/index.tsx | 7 ++++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/frontend/src/routes/(admin)/settings/aliases/index.tsx b/frontend/src/routes/(admin)/settings/aliases/index.tsx index 4a5d1e3..decfc0a 100644 --- a/frontend/src/routes/(admin)/settings/aliases/index.tsx +++ b/frontend/src/routes/(admin)/settings/aliases/index.tsx @@ -3,7 +3,7 @@ import { loader$ } from '@builder.io/qwik-city' import { WildebeestEnv } from '~/types' import { checkAuth } from '~/utils/checkAuth' -export const loader = loader$(async ({ request, platform, redirect }) => { +export const loader = loader$(async ({ request, platform, redirect }) => { const isAuthorized = await checkAuth(request, platform) if (!isAuthorized) { diff --git a/frontend/src/routes/(admin)/settings/layout.tsx b/frontend/src/routes/(admin)/settings/layout.tsx index db131f0..2f9b6e1 100644 --- a/frontend/src/routes/(admin)/settings/layout.tsx +++ b/frontend/src/routes/(admin)/settings/layout.tsx @@ -1,7 +1,16 @@ import { component$, Slot } from '@builder.io/qwik' import { WildebeestLogo } from '~/components/MastodonLogo' +import { loader$ } from '@builder.io/qwik-city' +import { getNotFoundHtml } from '~/utils/getNotFoundHtml/getNotFoundHtml' + +export const loader = loader$(({ html }) => { + html(404, getNotFoundHtml()) +}) + export default component$(() => { + loader() + return (
diff --git a/frontend/src/routes/(admin)/settings/migration/index.tsx b/frontend/src/routes/(admin)/settings/migration/index.tsx index 9998c90..56c793c 100644 --- a/frontend/src/routes/(admin)/settings/migration/index.tsx +++ b/frontend/src/routes/(admin)/settings/migration/index.tsx @@ -15,8 +15,6 @@ export const loader = loader$(async ({ redirect }) => { }) export default component$(() => { - loader() - return (

Account Migration

diff --git a/frontend/src/routes/(frontend)/about/index.tsx b/frontend/src/routes/(frontend)/about/index.tsx index 891bcf4..d24a8b9 100644 --- a/frontend/src/routes/(frontend)/about/index.tsx +++ b/frontend/src/routes/(frontend)/about/index.tsx @@ -7,6 +7,7 @@ import { HtmlContent } from '~/components/HtmlContent/HtmlContent' import { george } from '~/dummyData/accounts' import { Account } from '~/types' import { getDocumentHead } from '~/utils/getDocumentHead' +import { getNotFoundHtml } from '~/utils/getNotFoundHtml/getNotFoundHtml' import { instanceLoader } from '../layout' type AboutInfo = { @@ -23,9 +24,9 @@ type AboutInfo = { } } -export const aboutInfoLoader = loader$>(async ({ resolveValue, request, redirect }) => { - // TODO: properly implement loader and remove redirect - throw redirect(302, '/') +export const aboutInfoLoader = loader$>(async ({ resolveValue, request, html }) => { + // TODO: properly implement loader and remove the following 404 throw + throw html(404, getNotFoundHtml()) const instance = await resolveValue(instanceLoader) return { From 3d39ca74c5688e354e80f9276da518b89bb3ae21 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Fri, 24 Feb 2023 15:50:12 +0000 Subject: [PATCH 3/7] remove unneeded top level concurrently dependency --- package.json | 1 - yarn.lock | 53 +++------------------------------------------------- 2 files changed, 3 insertions(+), 51 deletions(-) diff --git a/package.json b/package.json index 82315a8..ce8b5d9 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "@typescript-eslint/eslint-plugin": "^5.46.1", "@typescript-eslint/parser": "^5.46.1", "better-sqlite3": "8", - "concurrently": "^7.6.0", "eslint": "^8.29.0", "jest": "^29.3.1", "jest-environment-miniflare": "^2.11.0", diff --git a/yarn.lock b/yarn.lock index 0e7addd..ac6621e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1369,7 +1369,7 @@ chalk@^2.0.0, chalk@^2.4.1: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^4.0.0, chalk@^4.1.0: +chalk@^4.0.0: version "4.1.2" resolved "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz" integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== @@ -1460,21 +1460,6 @@ concat-map@0.0.1: resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== -concurrently@^7.6.0: - version "7.6.0" - resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-7.6.0.tgz#531a6f5f30cf616f355a4afb8f8fcb2bba65a49a" - integrity sha512-BKtRgvcJGeZ4XttiDiNcFiRlxoAeZOseqUvyYRUp/Vtd+9p1ULmeoSqGsDA+2ivdeDFpqrJvGvmI+StKfKl5hw== - dependencies: - chalk "^4.1.0" - date-fns "^2.29.1" - lodash "^4.17.21" - rxjs "^7.0.0" - shell-quote "^1.7.3" - spawn-command "^0.0.2-1" - supports-color "^8.1.0" - tree-kill "^1.2.2" - yargs "^17.3.1" - convert-source-map@^1.6.0, convert-source-map@^1.7.0: version "1.9.0" resolved "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz" @@ -1520,11 +1505,6 @@ cross-spawn@^7.0.2, cross-spawn@^7.0.3: shebang-command "^2.0.0" which "^2.0.1" -date-fns@^2.29.1: - version "2.29.3" - resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.29.3.tgz#27402d2fc67eb442b511b70bbdf98e6411cd68a8" - integrity sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA== - debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.4: version "4.3.4" resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz" @@ -3090,11 +3070,6 @@ lodash.merge@^4.6.2: resolved "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lodash@^4.17.21: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - lru-cache@^6.0.0: version "6.0.0" resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz" @@ -3721,13 +3696,6 @@ run-parallel@^1.1.9: dependencies: queue-microtask "^1.2.2" -rxjs@^7.0.0: - version "7.8.0" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.0.tgz#90a938862a82888ff4c7359811a595e14e1e09a4" - integrity sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg== - dependencies: - tslib "^2.1.0" - safe-buffer@^5.0.1, safe-buffer@~5.2.0: version "5.2.1" resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz" @@ -3800,7 +3768,7 @@ shebang-regex@^3.0.0: resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== -shell-quote@^1.6.1, shell-quote@^1.7.3: +shell-quote@^1.6.1: version "1.7.4" resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.4.tgz#33fe15dee71ab2a81fcbd3a52106c5cfb9fb75d8" integrity sha512-8o/QEhSSRb1a5i7TFR0iM4G16Z0vYB2OQVs4G3aAFXjn3T6yEx8AZxy1PgDF7I00LZHYA3WxaSYIf5e5sAX8Rw== @@ -3874,11 +3842,6 @@ sourcemap-codec@^1.4.8: resolved "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz" integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== -spawn-command@^0.0.2-1: - version "0.0.2-1" - resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0" - integrity sha512-n98l9E2RMSJ9ON1AKisHzz7V42VDiBQGY6PB1BwRglz99wpVsSuGzQ+jOi6lFXBGVTCrRpltvjm+/XA+tpeJrg== - spdx-correct@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" @@ -4029,7 +3992,7 @@ supports-color@^7.1.0: dependencies: has-flag "^4.0.0" -supports-color@^8.0.0, supports-color@^8.1.0: +supports-color@^8.0.0: version "8.1.1" resolved "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz" integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== @@ -4102,11 +4065,6 @@ toucan-js@^3.1.0: "@sentry/types" "7.28.1" "@sentry/utils" "7.28.1" -tree-kill@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc" - integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A== - ts-jest@^29.0.3: version "29.0.3" resolved "https://registry.npmjs.org/ts-jest/-/ts-jest-29.0.3.tgz" @@ -4126,11 +4084,6 @@ tslib@^1.8.1, tslib@^1.9.3: resolved "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== -tslib@^2.1.0: - version "2.4.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.1.tgz#0d0bfbaac2880b91e22df0768e55be9753a5b17e" - integrity sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA== - tsutils@^3.21.0: version "3.21.0" resolved "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz" From da893972098f40ed40fec5a809aea5f61182860f Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Fri, 24 Feb 2023 15:51:28 +0000 Subject: [PATCH 4/7] improve frontend watch script and remove no longer needed concurrently dependency --- frontend/package.json | 4 +-- frontend/yarn.lock | 83 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 83 insertions(+), 4 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index dd75947..d3b2f25 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -10,7 +10,7 @@ "lint": "eslint src mock-db adaptors", "build": "vite build && vite build -c adaptors/cloudflare-pages/vite.config.ts", "dev": "vite --mode ssr", - "watch": "concurrently \"vite build -w\" \"vite build -w -c adaptors/cloudflare-pages/vite.config.ts\"" + "watch": "nodemon -w ./src --ext tsx,ts --exec npm run build" }, "devDependencies": { "@builder.io/qwik": "0.18.1", @@ -22,12 +22,12 @@ "@typescript-eslint/eslint-plugin": "5.46.1", "@typescript-eslint/parser": "5.46.1", "autoprefixer": "10.4.11", - "concurrently": "^7.6.0", "eslint": "8.30.0", "eslint-plugin-qwik": "0.16.1", "jest": "^29.3.1", "lorem-ipsum": "^2.0.8", "node-fetch": "3.3.0", + "nodemon": "^2.0.20", "postcss": "^8.4.16", "prettier": "2.8.1", "sass": "^1.57.0", diff --git a/frontend/yarn.lock b/frontend/yarn.lock index cc93c0f..1599b1a 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -1031,6 +1031,11 @@ "@typescript-eslint/types" "5.46.1" eslint-visitor-keys "^3.3.0" +abbrev@1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" + integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== + acorn-jsx@^5.0.0, acorn-jsx@^5.3.2: version "5.3.2" resolved "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz" @@ -1356,7 +1361,7 @@ character-reference-invalid@^2.0.0: resolved "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-2.0.1.tgz" integrity sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw== -"chokidar@>=3.0.0 <4.0.0", chokidar@^3.5.3: +"chokidar@>=3.0.0 <4.0.0", chokidar@^3.5.2, chokidar@^3.5.3: version "3.5.3" resolved "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz" integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== @@ -1500,6 +1505,13 @@ date-fns@^2.29.1: resolved "https://registry.npmjs.org/date-fns/-/date-fns-2.29.3.tgz" integrity sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA== +debug@^3.2.7: + version "3.2.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" + integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== + dependencies: + ms "^2.1.1" + debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.4: version "4.3.4" resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz" @@ -2149,6 +2161,11 @@ human-signals@^2.1.0: resolved "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== +ignore-by-default@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/ignore-by-default/-/ignore-by-default-1.0.1.tgz#48ca6d72f6c6a3af00a9ad4ae6876be3889e2b09" + integrity sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA== + ignore@^5.2.0: version "5.2.4" resolved "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz" @@ -3311,6 +3328,11 @@ ms@2.1.2: resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== +ms@^2.1.1: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + mz@^2.7.0: version "2.7.0" resolved "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz" @@ -3359,6 +3381,29 @@ node-releases@^2.0.6: resolved "https://registry.npmjs.org/node-releases/-/node-releases-2.0.8.tgz" integrity sha512-dFSmB8fFHEH/s81Xi+Y/15DQY6VHW81nXRj86EMSL3lmuTmK1e+aT4wrFCkTbm+gSwkw4KpX+rT/pMM2c1mF+A== +nodemon@^2.0.20: + version "2.0.20" + resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-2.0.20.tgz#e3537de768a492e8d74da5c5813cb0c7486fc701" + integrity sha512-Km2mWHKKY5GzRg6i1j5OxOHQtuvVsgskLfigG25yTtbyfRGn/GNvIbRyOf1PSCKJ2aT/58TiuUsuOU5UToVViw== + dependencies: + chokidar "^3.5.2" + debug "^3.2.7" + ignore-by-default "^1.0.1" + minimatch "^3.1.2" + pstree.remy "^1.1.8" + semver "^5.7.1" + simple-update-notifier "^1.0.7" + supports-color "^5.5.0" + touch "^3.1.0" + undefsafe "^2.0.5" + +nopt@~1.0.10: + version "1.0.10" + resolved "https://registry.yarnpkg.com/nopt/-/nopt-1.0.10.tgz#6ddd21bd2a31417b92727dd585f8a6f37608ebee" + integrity sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg== + dependencies: + abbrev "1" + normalize-path@^3.0.0, normalize-path@~3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz" @@ -3621,6 +3666,11 @@ property-information@^6.0.0: resolved "https://registry.npmjs.org/property-information/-/property-information-6.2.0.tgz" integrity sha512-kma4U7AFCTwpqq5twzC1YVIDXSqg6qQK6JN0smOw8fgRy1OkMi0CYSzFmsy6dnqSenamAtj0CyXMUJ1Mf6oROg== +pstree.remy@^1.1.8: + version "1.1.8" + resolved "https://registry.yarnpkg.com/pstree.remy/-/pstree.remy-1.1.8.tgz#c242224f4a67c21f686839bbdb4ac282b8373d3a" + integrity sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w== + punycode@^2.1.0: version "2.1.1" resolved "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz" @@ -3790,11 +3840,21 @@ semver@7.x, semver@^7.3.5, semver@^7.3.7: dependencies: lru-cache "^6.0.0" +semver@^5.7.1: + version "5.7.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" + integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== + semver@^6.0.0, semver@^6.3.0: version "6.3.0" resolved "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== +semver@~7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e" + integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A== + shebang-command@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz" @@ -3817,6 +3877,13 @@ signal-exit@^3.0.3, signal-exit@^3.0.7: resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== +simple-update-notifier@^1.0.7: + version "1.1.0" + resolved "https://registry.yarnpkg.com/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz#67694c121de354af592b347cdba798463ed49c82" + integrity sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg== + dependencies: + semver "~7.0.0" + sisteransi@^1.0.5: version "1.0.5" resolved "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz" @@ -3948,7 +4015,7 @@ sucrase@^3.20.3: pirates "^4.0.1" ts-interface-checker "^0.1.9" -supports-color@^5.3.0: +supports-color@^5.3.0, supports-color@^5.5.0: version "5.5.0" resolved "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz" integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== @@ -4048,6 +4115,13 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" +touch@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/touch/-/touch-3.1.0.tgz#fe365f5f75ec9ed4e56825e0bb76d24ab74af83b" + integrity sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA== + dependencies: + nopt "~1.0.10" + tree-kill@^1.2.2: version "1.2.2" resolved "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz" @@ -4135,6 +4209,11 @@ typescript@4.9.4: resolved "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz" integrity sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg== +undefsafe@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c" + integrity sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA== + undici@5.19.1: version "5.19.1" resolved "https://registry.yarnpkg.com/undici/-/undici-5.19.1.tgz#92b1fd3ab2c089b5a6bd3e579dcda8f1934ebf6d" From b131e83aa0cf8514f2d3b1380c760a0153de6770 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Mon, 27 Feb 2023 20:13:44 +0000 Subject: [PATCH 5/7] bump qwik and qwikcity --- frontend/package.json | 4 ++-- frontend/yarn.lock | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index d3b2f25..48d8ceb 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -13,8 +13,8 @@ "watch": "nodemon -w ./src --ext tsx,ts --exec npm run build" }, "devDependencies": { - "@builder.io/qwik": "0.18.1", - "@builder.io/qwik-city": "0.2.1", + "@builder.io/qwik": "0.19.2", + "@builder.io/qwik-city": "0.4.0", "@types/eslint": "8.4.10", "@types/jest": "^29.2.4", "@types/node": "^18.11.16", diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 1599b1a..e7405e0 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -297,10 +297,10 @@ resolved "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@builder.io/qwik-city@0.2.1": - version "0.2.1" - resolved "https://registry.yarnpkg.com/@builder.io/qwik-city/-/qwik-city-0.2.1.tgz#c57f481a75534ff54ddb0f38403acc66b5d02f41" - integrity sha512-g+ZC4Neo1XYQ/8uquUp6GKwr0eagpuCyQ3LkAtFhaIARaO67+cZfR6EFLJzf9wz5AVSt8/0QSD7wJEpni1i4IA== +"@builder.io/qwik-city@0.4.0": + version "0.4.0" + resolved "https://registry.yarnpkg.com/@builder.io/qwik-city/-/qwik-city-0.4.0.tgz#9afb97ba0e11119e44a2527f545e0d84a8fe9759" + integrity sha512-XNpmHzSHam7ZYrd12kJdwFerMEck0iOk3Wgb9IlVIuaN/nLuN033qrNWLVq+ZzlhplUea9DGc4job8qMix7WWA== dependencies: "@mdx-js/mdx" "2.3.0" "@types/mdx" "2.0.3" @@ -308,10 +308,10 @@ vfile "5.3.7" zod "^3.20.6" -"@builder.io/qwik@0.18.1": - version "0.18.1" - resolved "https://registry.yarnpkg.com/@builder.io/qwik/-/qwik-0.18.1.tgz#341d01c5749a07230c700a5e4df859b857654cd0" - integrity sha512-11qx5Wh6WRxgvHDJDppJORhykzkACUYuu9qRKEGdS3vTkBQ2Rr8NFDjYon2x6+8Wu9WukHk84ANywWnS91gS/w== +"@builder.io/qwik@0.19.2": + version "0.19.2" + resolved "https://registry.yarnpkg.com/@builder.io/qwik/-/qwik-0.19.2.tgz#d2f7d39bf6adb6de8497690cb3c41ad62a5fc1c6" + integrity sha512-Rxdyx96ucx0+nABLsg1sH7SgrlMdHgpxbR+NR3c53Ux4Jj+Xf+QHNQSIKF9zTV8KClrzmDlqILgmkDU4uMTVcg== "@cush/relative@^1.0.0": version "1.0.0" From 246edfc78944479da5db9b06d5ca204c9dfb6090 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Fri, 24 Feb 2023 15:53:10 +0000 Subject: [PATCH 6/7] add both FE and BE for server settings (including rules) --- backend/src/activitypub/actors/index.ts | 9 +- frontend/mock-db/init.ts | 19 ++- frontend/src/components/Settings/TextArea.tsx | 34 +++++ .../src/components/Settings/TextInput.tsx | 36 ++++++ .../routes/(admin)/oauth/authorize/index.tsx | 79 +++++------- .../settings/server-settings/about/index.tsx | 69 ++++++++++ .../server-settings/branding/index.tsx | 71 ++++++++++ .../settings/server-settings/index.tsx | 8 ++ .../settings/server-settings/layout.tsx | 74 +++++++++++ .../server-settings/rules/edit/[id]/index.tsx | 96 ++++++++++++++ .../settings/server-settings/rules/index.tsx | 122 ++++++++++++++++++ .../routes/(frontend)/[accountId]/layout.tsx | 3 +- .../src/routes/(frontend)/about/index.tsx | 108 +++++++++------- frontend/src/routes/(frontend)/layout.tsx | 5 +- frontend/src/utils/getJwtEmail.ts | 23 ++++ frontend/src/utils/isUserAdmin.ts | 17 +++ frontend/yarn.lock | 56 +------- functions/api/v1/instance/rules.ts | 18 +++ functions/api/wb/settings/server/admins.ts | 26 ++++ functions/api/wb/settings/server/rules.ts | 65 ++++++++++ functions/api/wb/settings/server/server.ts | 64 +++++++++ functions/first-login.ts | 21 ++- migrations/0008_add_server-settings.sql | 11 ++ package.json | 4 +- 24 files changed, 864 insertions(+), 174 deletions(-) create mode 100644 frontend/src/components/Settings/TextArea.tsx create mode 100644 frontend/src/components/Settings/TextInput.tsx create mode 100644 frontend/src/routes/(admin)/settings/server-settings/about/index.tsx create mode 100644 frontend/src/routes/(admin)/settings/server-settings/branding/index.tsx create mode 100644 frontend/src/routes/(admin)/settings/server-settings/index.tsx create mode 100644 frontend/src/routes/(admin)/settings/server-settings/layout.tsx create mode 100644 frontend/src/routes/(admin)/settings/server-settings/rules/edit/[id]/index.tsx create mode 100644 frontend/src/routes/(admin)/settings/server-settings/rules/index.tsx create mode 100644 frontend/src/utils/getJwtEmail.ts create mode 100644 frontend/src/utils/isUserAdmin.ts create mode 100644 functions/api/v1/instance/rules.ts create mode 100644 functions/api/wb/settings/server/admins.ts create mode 100644 functions/api/wb/settings/server/rules.ts create mode 100644 functions/api/wb/settings/server/server.ts create mode 100644 migrations/0008_add_server-settings.sql diff --git a/backend/src/activitypub/actors/index.ts b/backend/src/activitypub/actors/index.ts index 7156827..25f64b1 100644 --- a/backend/src/activitypub/actors/index.ts +++ b/backend/src/activitypub/actors/index.ts @@ -150,7 +150,8 @@ export async function createPerson( db: Database, userKEK: string, email: string, - properties: PersonProperties = {} + properties: PersonProperties = {}, + admin: boolean = false ): Promise { const userKeyPair = await generateUserKey(userKEK) @@ -198,12 +199,12 @@ export async function createPerson( const row = await db .prepare( ` - INSERT INTO actors(id, type, email, pubkey, privkey, privkey_salt, properties) - VALUES(?, ?, ?, ?, ?, ?, ?) + INSERT INTO actors(id, type, email, pubkey, privkey, privkey_salt, properties, is_admin) + VALUES(?, ?, ?, ?, ?, ?, ?, ?) RETURNING * ` ) - .bind(id, PERSON, email, userKeyPair.pubKey, privkey, salt, JSON.stringify(properties)) + .bind(id, PERSON, email, userKeyPair.pubKey, privkey, salt, JSON.stringify(properties), admin ? 1 : null) .first() return personFromRow(row) diff --git a/frontend/mock-db/init.ts b/frontend/mock-db/init.ts index dc97a27..a9cde78 100644 --- a/frontend/mock-db/init.ts +++ b/frontend/mock-db/init.ts @@ -74,12 +74,21 @@ async function getOrCreatePerson( db: Database, { username, avatar, display_name }: Account ): Promise { - const person = await getPersonByEmail(db, username) + const isAdmin = username === 'george' + const email = `${username}@test.email` + const person = await getPersonByEmail(db, email) if (person) return person - const newPerson = await createPerson(domain, db, 'test-kek', username, { - icon: { url: avatar }, - name: display_name, - }) + const newPerson = await createPerson( + domain, + db, + 'test-kek', + email, + { + icon: { url: avatar }, + name: display_name, + }, + isAdmin + ) if (!newPerson) { throw new Error('Could not create Actor ' + username) } diff --git a/frontend/src/components/Settings/TextArea.tsx b/frontend/src/components/Settings/TextArea.tsx new file mode 100644 index 0000000..f83f302 --- /dev/null +++ b/frontend/src/components/Settings/TextArea.tsx @@ -0,0 +1,34 @@ +import { component$, useSignal } from '@builder.io/qwik' + +type Props = { + label: string + name?: string + description?: string + class?: string + invalid?: boolean + value?: string + required?: boolean +} + +export const TextArea = component$( + ({ class: className, label, name, description, invalid, value, required }) => { + const inputId = useSignal(`${label.replace(/\s+/g, '_')}___${crypto.randomUUID()}`).value + return ( +
+ + {!!description &&
{description}
} +