aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-10-04 00:42:00 -0700
committerAdam Soltys <[email protected]>2022-10-04 00:42:00 -0700
commit81fc48aa58d932a19fb578e47170c06b3992d03a (patch)
tree30b06d929a175f0e74ef1da87e3d474f9068ad6c /src/lib
parent63f1a6780bab85ebb48ca1fc142cc6beaf772faa (diff)
downloadcoinos-ui-81fc48aa58d932a19fb578e47170c06b3992d03a.tar.gz
coinos-ui-81fc48aa58d932a19fb578e47170c06b3992d03a.zip
refactoring
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/socket.js1
-rw-r--r--src/lib/upload.js5
-rw-r--r--src/lib/utils.js14
3 files changed, 2 insertions, 18 deletions
diff --git a/src/lib/socket.js b/src/lib/socket.js
index dac2935e..6317595b 100644
--- a/src/lib/socket.js
+++ b/src/lib/socket.js
@@ -37,6 +37,7 @@ const maxReconnectDelay = 16000;
let currentReconnectDelay = initialReconnectDelay;
export function connect(t) {
+ console.log('CONNECT');
token = t;
clearInterval(interval);
diff --git a/src/lib/upload.js b/src/lib/upload.js
index d43148fb..4b03059c 100644
--- a/src/lib/upload.js
+++ b/src/lib/upload.js
@@ -1,7 +1,4 @@
-import { get } from 'svelte/store';
-import { token } from '$lib/store';
-
-export const upload = async (file, type, progress) => {
+export const upload = async (file, type, progress, token) => {
let url = `/api/upload/${type}`;
let formData = new FormData();
formData.append('file', file);
diff --git a/src/lib/utils.js b/src/lib/utils.js
index a4c77d58..7a988469 100644
--- a/src/lib/utils.js
+++ b/src/lib/utils.js
@@ -38,17 +38,6 @@ export const post = (url, body, headers) => {
});
};
-export const put = (url, body, headers) => {
- headers = { ...headers, 'content-type': 'application/json' };
- return fetch(base + url, {
- method: 'PUT',
- body: JSON.stringify(body),
- headers
- }).then(async (r) => {
- if (!r.ok) throw new Error('put failed');
- });
-};
-
export const copy = (text) => {
navigator.clipboard.writeText(text);
success('Copied!');
@@ -109,14 +98,11 @@ export const info = (m) => {
export const login = async (user, cookies) => {
let maxAge = 30 * 24 * 60 * 60;
let { token } = await post('/login', user);
- console.log('logged in', token);
let expires = new Date();
expires.setSeconds(expires.getSeconds() + maxAge);
- console.log('cs');
cookies.set('token', token, { path: '/' });
- console.log('bs');
};
export const auth = (cookies) => ({ authorization: `Bearer ${cookies.get('token')}` });