bun run format

This commit is contained in:
2026-01-27 19:43:32 -03:00
parent 37f1b46306
commit e1864660a7
19 changed files with 115 additions and 121 deletions

View File

@@ -1,16 +1,16 @@
import { apiBase } from "@/stores/url";
import { get } from "svelte/store";
import { apiBase } from '@/stores/url';
import { get } from 'svelte/store';
export async function checkEmail(email: string) {
try {
const req = await fetch(`${get(apiBase)}/api/users/check-email/${email}`, {
method: "GET"
});
if (req.ok){
return (await req.json()).available;
}
return false;
} catch {
return false;
}
try {
const req = await fetch(`${get(apiBase)}/api/users/check-email/${email}`, {
method: 'GET'
});
if (req.ok) {
return (await req.json()).available;
}
return false;
} catch {
return false;
}
}

View File

@@ -1,16 +1,16 @@
import { apiBase } from "@/stores/url";
import { get } from "svelte/store";
import { apiBase } from '@/stores/url';
import { get } from 'svelte/store';
export async function checkUsername(username: string) {
try {
const req = await fetch(`${get(apiBase)}/api/users/check-username/${username}`, {
method: "GET"
});
if (req.ok){
return (await req.json()).available;
}
return false;
} catch {
return false;
}
try {
const req = await fetch(`${get(apiBase)}/api/users/check-username/${username}`, {
method: 'GET'
});
if (req.ok) {
return (await req.json()).available;
}
return false;
} catch {
return false;
}
}

View File

@@ -1,6 +1,6 @@
import { apiBase } from "@/stores/url";
import { sesionStore } from "@/stores/usuario";
import { get } from "svelte/store";
import { apiBase } from '@/stores/url';
import { sesionStore } from '@/stores/usuario';
import { get } from 'svelte/store';
import type { Post } from '../../types';
import { PAGE_SIZE } from '../stores/posts';
@@ -10,12 +10,11 @@ export async function getPosts(page: number = 1): Promise<Post[]> {
const headers: HeadersInit = {};
if (token) headers.Authorization = `Bearer ${token}`;
const res = await fetch(
`${get(apiBase)}/timeline?page=${page}&pageSize=${PAGE_SIZE}`,
{ headers }
);
const res = await fetch(`${get(apiBase)}/timeline?page=${page}&pageSize=${PAGE_SIZE}`, {
headers
});
if (!res.ok) throw new Error('Error cargando posts');
return res.json();
}
}

View File

@@ -4,7 +4,7 @@ import { sesionStore } from '@/stores/usuario';
import type { Post } from '../../types';
export async function likePost(post: Post) {
let method = post.isLiked ? "DELETE" : "POST";
let method = post.isLiked ? 'DELETE' : 'POST';
try {
const req = await fetch(get(apiBase) + `/api/posts/${post.id}/like`, {
method: method,

View File

@@ -24,7 +24,7 @@ export async function loadMorePosts() {
if (newPosts.length < PAGE_SIZE) {
finished = true;
} else {
page.update(p => p + 1);
page.update((p) => p + 1);
}
} finally {
loadingPosts.set(false);

View File

@@ -13,13 +13,16 @@ export async function obtenerSeguidoresPorUsuario(
const fetchFunc = fetch2 || fetch;
const skip = (page - 1) * limit;
const response = await fetchFunc(`${get(apiBase)}/api/users/${id}/followers?skip=${skip}&limit=${limit}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
const response = await fetchFunc(
`${get(apiBase)}/api/users/${id}/followers?skip=${skip}&limit=${limit}`,
{
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
}
}
});
);
if (!response.ok) {
return null;
@@ -30,4 +33,4 @@ export async function obtenerSeguidoresPorUsuario(
} catch (error) {
return null;
}
}
}

View File

@@ -13,13 +13,16 @@ export async function obtenerSeguidosPorUsuario(
const fetchFunc = fetch2 || fetch;
const skip = (page - 1) * limit;
const response = await fetchFunc(`${get(apiBase)}/api/users/${id}/following?skip=${skip}&limit=${limit}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
const response = await fetchFunc(
`${get(apiBase)}/api/users/${id}/following?skip=${skip}&limit=${limit}`,
{
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
}
}
});
);
if (!response.ok) {
return null;
@@ -30,4 +33,4 @@ export async function obtenerSeguidosPorUsuario(
} catch (error) {
return null;
}
}
}

View File

@@ -1,27 +1,27 @@
import { addPost } from "@/stores/posts";
import { apiBase } from "@/stores/url";
import { sesionStore } from "@/stores/usuario";
import { get } from "svelte/store";
import { addPost } from '@/stores/posts';
import { apiBase } from '@/stores/url';
import { sesionStore } from '@/stores/usuario';
import { get } from 'svelte/store';
export async function publicarPost(formData: FormData){
try{
const req = fetch(get(apiBase) + '/api/posts', {
method: 'POST',
//credentials: 'include',
headers: {
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
},
body: formData
});
export async function publicarPost(formData: FormData) {
try {
const req = fetch(get(apiBase) + '/api/posts', {
method: 'POST',
//credentials: 'include',
headers: {
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
},
body: formData
});
const res = await req;
if (res.ok) {
const post = await res.json();
addPost(post);
return '';
}
return 'No se pudo crear el post.';
} catch {
return 'Fallo al alcanzar el servidor';
const res = await req;
if (res.ok) {
const post = await res.json();
addPost(post);
return '';
}
return 'No se pudo crear el post.';
} catch {
return 'Fallo al alcanzar el servidor';
}
}

View File

@@ -1,7 +1,4 @@
export async function updateImagenDePerfil(){
try{
}catch{
}
export async function updateImagenDePerfil() {
try {
} catch {}
}

View File

@@ -5,9 +5,9 @@ import { sesionStore } from '@/stores/usuario';
export async function updatePost(post: Post, callbackfn: Function, message: string) {
try {
const formData = new FormData();
formData.append("content", post.content);
formData.append("image", post.image||"");
const formData = new FormData();
formData.append('content', post.content);
formData.append('image', post.image || '');
const req = await fetch(get(apiBase) + `/api/posts/${post.id}`, {
method: 'PUT',