npm run format

This commit is contained in:
Ilion Beyst 2021-12-31 11:38:06 +01:00
parent 74d0189d37
commit 8d3b8fd8aa
10 changed files with 207 additions and 210 deletions

View file

@ -1,20 +1,20 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
plugins: ['svelte3', '@typescript-eslint'],
ignorePatterns: ['*.cjs'],
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
parser: "@typescript-eslint/parser",
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
plugins: ["svelte3", "@typescript-eslint"],
ignorePatterns: ["*.cjs"],
overrides: [{ files: ["*.svelte"], processor: "svelte3/svelte3" }],
settings: {
'svelte3/typescript': () => require('typescript')
"svelte3/typescript": () => require("typescript"),
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020
sourceType: "module",
ecmaVersion: 2020,
},
env: {
browser: true,
es2017: true,
node: true
}
node: true,
},
};

View file

@ -1,7 +1,7 @@
export function set_session_token(token: string) {
window.localStorage.setItem('session', token);
window.localStorage.setItem("session", token);
}
export function get_session_token(): string | null {
return window.localStorage.getItem('session');
return window.localStorage.getItem("session");
}

View file

@ -1,55 +1,55 @@
<script lang="ts" context="module">
import { get_session_token } from '$lib/auth';
import { get_session_token } from "$lib/auth";
/** @type {import('@sveltejs/kit').Load} */
export async function load({ params, fetch, session, stuff }) {
const token = get_session_token();
const res = await fetch('/api/bots/my_bots', {
const res = await fetch("/api/bots/my_bots", {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
}
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
});
if (res.ok) {
return {
props: {
bots: await res.json()
}
bots: await res.json(),
},
};
}
return {
status: res.status,
error: new Error('Could not load bots')
error: new Error("Could not load bots"),
};
}
</script>
<script lang="ts">
import { goto } from '$app/navigation';
import { goto } from "$app/navigation";
export let bots: object[];
let name: string | undefined;
async function createBot() {
const token = get_session_token();
const res = await fetch('/api/bots', {
method: 'POST',
const res = await fetch("/api/bots", {
method: "POST",
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({
name: name
})
name: name,
}),
});
if (res.ok) {
let bot = await res.json();
goto(`/bots/${bot['id']}`);
goto(`/bots/${bot["id"]}`);
} else {
new Error('creation failed');
new Error("creation failed");
}
}
</script>
@ -63,8 +63,8 @@
<ul>
{#each bots as bot}
<li>
<a target="_blank" href={`bots/${bot['id']}`}>
{bot['name']}
<a target="_blank" href={`bots/${bot["id"]}`}>
{bot["name"]}
</a>
</li>
{/each}

View file

@ -1,20 +1,20 @@
<script lang="ts">
import { get_session_token, set_session_token } from '$lib/auth';
import { goto } from '$app/navigation';
import { get_session_token, set_session_token } from "$lib/auth";
import { goto } from "$app/navigation";
let username: string | undefined;
let password: string | undefined;
const onSubmit = () => {
fetch('/api/login', {
method: 'POST',
fetch("/api/login", {
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json",
},
body: JSON.stringify({
username,
password
})
password,
}),
})
.then((response) => {
if (!response.ok) {
@ -24,12 +24,12 @@
})
.then((token) => {
set_session_token(token);
goto("/")
goto("/");
});
};
function loggedIn(): boolean {
return get_session_token() != null
return get_session_token() != null;
}
</script>

View file

@ -3,23 +3,23 @@
let password: string | undefined;
const onSubmit = () => {
if (username === undefined || username.trim() === '') {
if (username === undefined || username.trim() === "") {
return;
}
if (password === undefined || password.trim() === '') {
if (password === undefined || password.trim() === "") {
return;
}
fetch('/api/register', {
method: 'POST',
fetch("/api/register", {
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json",
},
body: JSON.stringify({
username,
password
})
password,
}),
})
.then((resp) => resp.json())
.then((data) => {

View file

@ -1,9 +1,8 @@
import adapter from '@sveltejs/adapter-auto';
import preprocess from 'svelte-preprocess';
import adapter from "@sveltejs/adapter-auto";
import preprocess from "svelte-preprocess";
// import { svelte } from '@sveltejs/vite-plugin-svelte'
import { viteCommonjs } from '@originjs/vite-plugin-commonjs'
import wasmPack from 'vite-plugin-wasm-pack';
import { viteCommonjs } from "@originjs/vite-plugin-commonjs";
import wasmPack from "vite-plugin-wasm-pack";
/** @type {import('@sveltejs/kit').Config} */
const config = {
@ -15,7 +14,7 @@ const config = {
adapter: adapter(),
// hydrate the <div id="svelte"> element in src/app.html
target: '#svelte',
target: "#svelte",
ssr: false,
vite: {
plugins: [
@ -37,13 +36,11 @@ const config = {
},
fs: {
// Allow serving files from one level up to the project root
allow: ['..']
}
allow: [".."],
},
},
},
}
},
};
export default config;