mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 13:59:16 +01:00
Replace eslint and prettier with Biome
This commit is contained in:
parent
4a5a2ea590
commit
af0d627f19
199 changed files with 16493 additions and 16361 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
// Import Tailwind style reset
|
||||
import '@unocss/reset/tailwind-compat.css'
|
||||
import "@unocss/reset/tailwind-compat.css";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { ref } from "vue";
|
||||
|
||||
const props = defineProps<{
|
||||
label: string;
|
||||
|
|
@ -26,5 +26,5 @@ const checkValid = (e: Event) => {
|
|||
} else {
|
||||
isInvalid.value = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
import { createApp } from "vue";
|
||||
import "./style.css";
|
||||
import "virtual:uno.css";
|
||||
import { createApp } from "vue";
|
||||
import { createRouter, createWebHistory } from "vue-router";
|
||||
import App from "./App.vue";
|
||||
import routes from "./routes";
|
||||
import "./style.css";
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes: routes,
|
||||
history: createWebHistory(),
|
||||
routes: routes,
|
||||
});
|
||||
|
||||
const app = createApp(App);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { ref } from "vue";
|
||||
|
||||
const location = window.location;
|
||||
const version = __VERSION__;
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@
|
|||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useRoute } from 'vue-router';
|
||||
import LoginInput from "../../components/LoginInput.vue"
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
import LoginInput from "../../components/LoginInput.vue";
|
||||
|
||||
const query = useRoute().query;
|
||||
|
||||
|
|
@ -64,18 +64,21 @@ const client_id = query.client_id;
|
|||
const scope = query.scope;
|
||||
const error = decodeURIComponent(query.error as string);
|
||||
|
||||
const oauthProviders = ref<{
|
||||
name: string;
|
||||
icon: string;
|
||||
id: string
|
||||
}[] | null>(null);
|
||||
const oauthProviders = ref<
|
||||
| {
|
||||
name: string;
|
||||
icon: string;
|
||||
id: string;
|
||||
}[]
|
||||
| null
|
||||
>(null);
|
||||
|
||||
const getOauthProviders = async () => {
|
||||
const response = await fetch('/oauth/providers');
|
||||
return await response.json() as any;
|
||||
}
|
||||
const response = await fetch("/oauth/providers");
|
||||
return await response.json();
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
oauthProviders.value = await getOauthProviders();
|
||||
})
|
||||
oauthProviders.value = await getOauthProviders();
|
||||
});
|
||||
</script>
|
||||
|
|
@ -53,7 +53,7 @@
|
|||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
const query = useRoute().query;
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ const application = query.application;
|
|||
const website = decodeURIComponent(query.website as string);
|
||||
const redirect_uri = query.redirect_uri as string;
|
||||
const client_id = query.client_id;
|
||||
const scope = decodeURIComponent(query.scope as string || "");
|
||||
const scope = decodeURIComponent((query.scope as string) || "");
|
||||
const code = query.code;
|
||||
|
||||
const oauthScopeText: Record<string, string> = {
|
||||
|
|
@ -79,7 +79,7 @@ const oauthScopeText: Record<string, string> = {
|
|||
"w:conversations": "Edit your conversations",
|
||||
"w:media": "Upload media",
|
||||
"w:reports": "Report users",
|
||||
}
|
||||
};
|
||||
|
||||
const scopes = scope.split(" ");
|
||||
|
||||
|
|
@ -89,30 +89,56 @@ const scopes = scope.split(" ");
|
|||
// Return an array of strings to display
|
||||
// "read write:accounts" returns all the fields with $VERB as read, plus the accounts field with $VERB as write
|
||||
const getScopeText = (fullScopes: string[]) => {
|
||||
let scopeTexts = [];
|
||||
const scopeTexts = [];
|
||||
|
||||
const readScopes = fullScopes.filter(scope => scope.includes("read"));
|
||||
const writeScopes = fullScopes.filter(scope => scope.includes("write"));
|
||||
const readScopes = fullScopes.filter((scope) => scope.includes("read"));
|
||||
const writeScopes = fullScopes.filter((scope) => scope.includes("write"));
|
||||
|
||||
for (const possibleScope of Object.keys(oauthScopeText)) {
|
||||
const [scopeAction, scopeName] = possibleScope.split(':');
|
||||
const [scopeAction, scopeName] = possibleScope.split(":");
|
||||
|
||||
if (scopeAction.includes("rw") && (readScopes.includes(`read:${scopeName}`) || readScopes.find(scope => scope === "read")) && (writeScopes.includes(`write:${scopeName}`) || writeScopes.find(scope => scope === "write"))) {
|
||||
if (oauthScopeText[possibleScope].includes("$VERB")) scopeTexts.push(["Read and write", oauthScopeText[possibleScope].replace("$VERB", "")]);
|
||||
if (
|
||||
scopeAction.includes("rw") &&
|
||||
(readScopes.includes(`read:${scopeName}`) ||
|
||||
readScopes.find((scope) => scope === "read")) &&
|
||||
(writeScopes.includes(`write:${scopeName}`) ||
|
||||
writeScopes.find((scope) => scope === "write"))
|
||||
) {
|
||||
if (oauthScopeText[possibleScope].includes("$VERB"))
|
||||
scopeTexts.push([
|
||||
"Read and write",
|
||||
oauthScopeText[possibleScope].replace("$VERB", ""),
|
||||
]);
|
||||
else scopeTexts.push(["", oauthScopeText[possibleScope]]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (scopeAction.includes('r') && (readScopes.includes(`read:${scopeName}`) || readScopes.find(scope => scope === "read"))) {
|
||||
if (oauthScopeText[possibleScope].includes("$VERB")) scopeTexts.push(["Read", oauthScopeText[possibleScope].replace("$VERB", "")]);
|
||||
if (
|
||||
scopeAction.includes("r") &&
|
||||
(readScopes.includes(`read:${scopeName}`) ||
|
||||
readScopes.find((scope) => scope === "read"))
|
||||
) {
|
||||
if (oauthScopeText[possibleScope].includes("$VERB"))
|
||||
scopeTexts.push([
|
||||
"Read",
|
||||
oauthScopeText[possibleScope].replace("$VERB", ""),
|
||||
]);
|
||||
else scopeTexts.push(["", oauthScopeText[possibleScope]]);
|
||||
}
|
||||
|
||||
if (scopeAction.includes('w') && (writeScopes.includes(`write:${scopeName}`) || writeScopes.find(scope => scope === "write"))) {
|
||||
if (oauthScopeText[possibleScope].includes("$VERB")) scopeTexts.push(["Write", oauthScopeText[possibleScope].replace("$VERB", "")]);
|
||||
if (
|
||||
scopeAction.includes("w") &&
|
||||
(writeScopes.includes(`write:${scopeName}`) ||
|
||||
writeScopes.find((scope) => scope === "write"))
|
||||
) {
|
||||
if (oauthScopeText[possibleScope].includes("$VERB"))
|
||||
scopeTexts.push([
|
||||
"Write",
|
||||
oauthScopeText[possibleScope].replace("$VERB", ""),
|
||||
]);
|
||||
else scopeTexts.push(["", oauthScopeText[possibleScope]]);
|
||||
}
|
||||
}
|
||||
return scopeTexts;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
@ -98,12 +98,14 @@
|
|||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from "vue";
|
||||
import type { APIInstance } from "~types/entities/instance";
|
||||
import LoginInput from "../../components/LoginInput.vue"
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import LoginInput from "../../components/LoginInput.vue";
|
||||
|
||||
const instanceInfo = await fetch("/api/v1/instance").then(res => res.json()) as APIInstance & {
|
||||
tos_url: string
|
||||
const instanceInfo = (await fetch("/api/v1/instance").then((res) =>
|
||||
res.json(),
|
||||
)) as APIInstance & {
|
||||
tos_url: string;
|
||||
};
|
||||
|
||||
const errors = ref<{
|
||||
|
|
@ -124,26 +126,40 @@ const registerUser = (e: Event) => {
|
|||
e.preventDefault();
|
||||
const formData = new FormData();
|
||||
|
||||
formData.append("email", (e.target as any).email.value);
|
||||
formData.append("password", (e.target as any).password.value);
|
||||
formData.append("username", (e.target as any).username.value);
|
||||
const target = e.target as unknown as Record<string, HTMLInputElement>;
|
||||
|
||||
formData.append("email", target.email.value);
|
||||
formData.append("password", target.password.value);
|
||||
formData.append("username", target.username.value);
|
||||
formData.append("reason", reason.value);
|
||||
formData.append("locale", "en")
|
||||
formData.append("locale", "en");
|
||||
formData.append("agreement", "true");
|
||||
// @ts-ignore
|
||||
fetch("/api/v1/accounts", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then(async res => {
|
||||
if (res.status === 422) {
|
||||
errors.value = (await res.json() as any).details;
|
||||
console.log(errors.value)
|
||||
} else {
|
||||
// @ts-ignore
|
||||
window.location.href = "/register/success";
|
||||
}
|
||||
}).catch(async err => {
|
||||
console.error(err);
|
||||
})
|
||||
}
|
||||
.then(async (res) => {
|
||||
if (res.status === 422) {
|
||||
errors.value = (
|
||||
(await res.json()) as Record<
|
||||
string,
|
||||
{
|
||||
[key: string]: {
|
||||
error: string;
|
||||
description: string;
|
||||
}[];
|
||||
}
|
||||
>
|
||||
).details;
|
||||
console.log(errors.value);
|
||||
} else {
|
||||
// @ts-ignore
|
||||
window.location.href = "/register/success";
|
||||
}
|
||||
})
|
||||
.catch(async (err) => {
|
||||
console.error(err);
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
|
@ -6,9 +6,9 @@ import registerIndexVue from "./pages/register/index.vue";
|
|||
import successVue from "./pages/register/success.vue";
|
||||
|
||||
export default [
|
||||
{ path: "/", component: indexVue },
|
||||
{ path: "/oauth/authorize", component: authorizeVue },
|
||||
{ path: "/oauth/redirect", component: redirectVue },
|
||||
{ path: "/register", component: registerIndexVue },
|
||||
{ path: "/register/success", component: successVue },
|
||||
{ path: "/", component: indexVue },
|
||||
{ path: "/oauth/authorize", component: authorizeVue },
|
||||
{ path: "/oauth/redirect", component: redirectVue },
|
||||
{ path: "/register", component: registerIndexVue },
|
||||
{ path: "/register/success", component: successVue },
|
||||
] as RouteRecordRaw[];
|
||||
|
|
|
|||
|
|
@ -1,35 +1,35 @@
|
|||
import { defineConfig } from "vite";
|
||||
import UnoCSS from "unocss/vite";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import UnoCSS from "unocss/vite";
|
||||
import { defineConfig } from "vite";
|
||||
import pkg from "../package.json";
|
||||
|
||||
export default defineConfig({
|
||||
base: "/",
|
||||
build: {
|
||||
outDir: "./dist",
|
||||
},
|
||||
// main.ts is in pages/ directory
|
||||
resolve: {
|
||||
alias: {
|
||||
vue: "vue/dist/vue.esm-bundler",
|
||||
},
|
||||
},
|
||||
server: {
|
||||
hmr: {
|
||||
clientPort: 5173,
|
||||
},
|
||||
},
|
||||
define: {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
__VERSION__: JSON.stringify(pkg.version),
|
||||
},
|
||||
ssr: {
|
||||
noExternal: ["@prisma/client"],
|
||||
},
|
||||
plugins: [
|
||||
UnoCSS({
|
||||
mode: "global",
|
||||
}),
|
||||
vue(),
|
||||
],
|
||||
base: "/",
|
||||
build: {
|
||||
outDir: "./dist",
|
||||
},
|
||||
// main.ts is in pages/ directory
|
||||
resolve: {
|
||||
alias: {
|
||||
vue: "vue/dist/vue.esm-bundler",
|
||||
},
|
||||
},
|
||||
server: {
|
||||
hmr: {
|
||||
clientPort: 5173,
|
||||
},
|
||||
},
|
||||
define: {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
__VERSION__: JSON.stringify(pkg.version),
|
||||
},
|
||||
ssr: {
|
||||
noExternal: ["@prisma/client"],
|
||||
},
|
||||
plugins: [
|
||||
UnoCSS({
|
||||
mode: "global",
|
||||
}),
|
||||
vue(),
|
||||
],
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue