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,4 +1,5 @@
# Package Managers
src/lib/components/ui/
package-lock.json
pnpm-lock.yaml
yarn.lock

View File

@@ -1,12 +1,9 @@
{
"useTabs": true,
"singleQuote": true,
"singleQuote": false,
"trailingComma": "none",
"printWidth": 100,
"plugins": [
"prettier-plugin-svelte",
"prettier-plugin-tailwindcss"
],
"plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
"overrides": [
{
"files": "*.svelte",

View File

@@ -16,7 +16,10 @@
let {
post,
variant = 'icon-lg'
}: { post: Omit<Partial<Post>, 'authorId'> & { authorId: string; id: string }; variant?: 'icon-lg' | 'default' | 'sm' | 'lg' | 'icon' | 'icon-sm' } = $props();
}: {
post: Omit<Partial<Post>, 'authorId'> & { authorId: string; id: string };
variant?: 'icon-lg' | 'default' | 'sm' | 'lg' | 'icon' | 'icon-sm';
} = $props();
let seguido: boolean | null = $state(null);

View File

@@ -1,12 +1,12 @@
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"
method: 'GET'
});
if (req.ok){
if (req.ok) {
return (await req.json()).available;
}
return false;

View File

@@ -1,12 +1,12 @@
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"
method: 'GET'
});
if (req.ok){
if (req.ok) {
return (await req.json()).available;
}
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,10 +10,9 @@ 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');

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}`, {
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;

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}`, {
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;

View File

@@ -1,10 +1,10 @@
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{
export async function publicarPost(formData: FormData) {
try {
const req = fetch(get(apiBase) + '/api/posts', {
method: 'POST',
//credentials: 'include',

View File

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

View File

@@ -6,8 +6,8 @@ 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||"");
formData.append('content', post.content);
formData.append('image', post.image || '');
const req = await fetch(get(apiBase) + `/api/posts/${post.id}`, {
method: 'PUT',

View File

@@ -19,21 +19,14 @@ export const addPost = (post: Post) => {
posts.update((current) => [post, ...current]);
};
export const updatePostStore = (
postId: string,
updatedData: Partial<Post>
) => {
export const updatePostStore = (postId: string, updatedData: Partial<Post>) => {
posts.update((current) =>
current.map((post) =>
post.id === postId ? { ...post, ...updatedData } : post
)
current.map((post) => (post.id === postId ? { ...post, ...updatedData } : post))
);
};
export const removePost = (postId: string) => {
posts.update((current) =>
current.filter((post) => post.id !== postId)
);
posts.update((current) => current.filter((post) => post.id !== postId));
};
export const resetPosts = () => {

View File

@@ -1,5 +1,5 @@
import { obtenerUsuarioPorUsername } from '@/hooks/obtenerUsuario.js';
import type {UserResponseDto } from '../../types.js';
import type { UserResponseDto } from '../../types.js';
import { error } from '@sveltejs/kit';
import type { PageLoad } from './$types';
import { obtenerSeguidosPorUsuario } from '@/hooks/obtenerSeguidosPorUsuario.js';

View File

@@ -35,7 +35,6 @@
isLoading = false;
}
</script>
<div class="flex min-h-fit w-full items-center justify-center p-6 md:p-10">

View File

@@ -19,4 +19,4 @@ export const load: PageLoad = async ({ params, fetch }) => {
usuario,
seguidores: seguidoresResponse?.response || []
};
}
};

View File

@@ -35,7 +35,6 @@
isLoading = false;
}
</script>
<div class="flex min-h-fit w-full items-center justify-center p-6 md:p-10">