From cf39835eb59948fcf7688eb28182eb8ed6190028 Mon Sep 17 00:00:00 2001 From: Yuri Date: Thu, 13 Jul 2023 14:15:39 +0200 Subject: [PATCH] prettify - add .prettierrc (lowest impact configuration) - add .prettierignore (types) --- .prettierignore | 1 + .prettierrc | 8 ++++++++ src/api/index.ts | 7 ------- src/lib/consts.ts | 10 ++++------ src/lib/env.ts | 2 +- src/lib/fetch.ts | 6 +----- src/lib/index.ts | 2 +- src/lib/map.ts | 37 +++++++++++++++++++++++++------------ 8 files changed, 41 insertions(+), 32 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..7bcc0fd --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +src/types \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..9c85e28 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "semi": true, + "singleQuote": true, + "printWidth": 100, + "tabWidth": 2, + "useTabs": false, + "trailingComma": "es5" +} diff --git a/src/api/index.ts b/src/api/index.ts index 6925d65..7ac29ca 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -7,8 +7,6 @@ console.log('Initializing API server on port', port); const app = new Hono(); - - // Endpoint to get user profiles based on userName app.get('/api/users', async (context) => { try { @@ -69,7 +67,6 @@ app.get('/api/threads/:threadId/replies', async (context) => { } }); - // Endpoint to get user profile threads app.get('/api/users/:userId/threads', async (context) => { try { @@ -90,10 +87,6 @@ app.get('/api/users/:userId/threads', async (context) => { } }); - - - - app.use('*', async (c) => { c.notFound(); }); diff --git a/src/lib/consts.ts b/src/lib/consts.ts index 0f23a7f..9b34071 100644 --- a/src/lib/consts.ts +++ b/src/lib/consts.ts @@ -1,14 +1,12 @@ -export const THREADS_APP_ID = "238260118697367" -export const GRAPHQL_ENDPOINT = 'https://www.threads.net/api/graphql' +export const THREADS_APP_ID = '238260118697367'; +export const GRAPHQL_ENDPOINT = 'https://www.threads.net/api/graphql'; export const ENDPOINTS_DOCUMENT_ID = { - USER_PROFILE: 23996318473300828, USER_PROFILE_THREADS: 6451898791498605, USER_PROFILE_THREADS_REPLIES: 6529829603744567, USER_REPLIES: 6684830921547925, THREADS_REPLIES: 6960296570650501, - -} +}; -export const getMidudev = () => `pheralb` +export const getMidudev = () => `pheralb`; diff --git a/src/lib/env.ts b/src/lib/env.ts index 6c25fef..27c9833 100644 --- a/src/lib/env.ts +++ b/src/lib/env.ts @@ -1 +1 @@ -export const IS_DEBUG = Boolean(Bun.env.DEBUG) \ No newline at end of file +export const IS_DEBUG = Boolean(Bun.env.DEBUG); diff --git a/src/lib/fetch.ts b/src/lib/fetch.ts index 9753296..63c2bc8 100644 --- a/src/lib/fetch.ts +++ b/src/lib/fetch.ts @@ -1,8 +1,4 @@ -import { - ENDPOINTS_DOCUMENT_ID, - THREADS_APP_ID, - GRAPHQL_ENDPOINT, -} from './consts'; +import { ENDPOINTS_DOCUMENT_ID, THREADS_APP_ID, GRAPHQL_ENDPOINT } from './consts'; import { IS_DEBUG } from './env'; import { ThreadsUserProfileResponse } from '../types/threads-api'; import { mapUserProfile } from './map'; diff --git a/src/lib/index.ts b/src/lib/index.ts index a478a1f..71ef5d0 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -1 +1 @@ -export * from './fetch'; \ No newline at end of file +export * from './fetch'; diff --git a/src/lib/map.ts b/src/lib/map.ts index 70837dc..77bab80 100644 --- a/src/lib/map.ts +++ b/src/lib/map.ts @@ -1,20 +1,33 @@ -import { ThreadsUserProfileResponse} from '../types/threads-api' +import { ThreadsUserProfileResponse } from '../types/threads-api'; /* {"data":{"userData":{"user":{"is_private":false,"profile_pic_url":"https://scontent.cdninstagram.com/v/t51.2885-19/358174537_954616899107816_8099109910283809308_n.jpg?stp=dst-jpg_s150x150&_nc_ht=scontent.cdninstagram.com&_nc_cat=108&_nc_ohc=s5qTOIc_KREAX8qfpDD&edm=APs17CUBAAAA&ccb=7-5&oh=00_AfDaktW3vHUeFvaE14qoy7LmddGuAqWUh2uirC7ulm_TsQ&oe=64B34341&_nc_sid=10d13b","username":"midu.dev","hd_profile_pic_versions":[{"height":320,"url":"https://scontent.cdninstagram.com/v/t51.2885-19/358174537_954616899107816_8099109910283809308_n.jpg?stp=dst-jpg_s320x320&_nc_ht=scontent.cdninstagram.com&_nc_cat=108&_nc_ohc=s5qTOIc_KREAX8qfpDD&edm=APs17CUBAAAA&ccb=7-5&oh=00_AfBUgVik0k-VaqXmyuuJUp6bEmAyDHIkkB3ssbnHYwGg_A&oe=64B34341&_nc_sid=10d13b","width":320},{"height":640,"url":"https://scontent.cdninstagram.com/v/t51.2885-19/358174537_954616899107816_8099109910283809308_n.jpg?stp=dst-jpg_s640x640&_nc_ht=scontent.cdninstagram.com&_nc_cat=108&_nc_ohc=s5qTOIc_KREAX8qfpDD&edm=APs17CUBAAAA&ccb=7-5&oh=00_AfCG0VVjm58zezRMrUgG_HlTuOL0MlMMsUpGRDgn4CrMiA&oe=64B34341&_nc_sid=10d13b","width":640}],"is_verified":false,"biography":"👨‍💻 Ingeniero de Software + JavaScript\n⌨️ Aprende Programación conmigo\n🏆 Google Expert + GitHub Star\n🙌 Comparto recursos y tutoriales","biography_with_entities":null,"follower_count":34756,"profile_context_facepile_users":null,"bio_links":[{"url":"https://twitch.tv/midudev"}],"pk":"8242141302","full_name":"midudev • Programación y Desarrollo JavaScript","id":null}}},"extensions":{"is_final":true}} */ export const mapUserProfile = (rawResponse: ThreadsUserProfileResponse) => { - const userApiResponse = rawResponse?.data?.userData?.user - if (!userApiResponse) return null + const userApiResponse = rawResponse?.data?.userData?.user; + if (!userApiResponse) return null; - const { username, is_verified, biography, follower_count, bio_links, pk: id, full_name, hd_profile_pic_versions, profile_pic_url } = userApiResponse + const { + username, + is_verified, + biography, + follower_count, + bio_links, + pk: id, + full_name, + hd_profile_pic_versions, + profile_pic_url, + } = userApiResponse; - const profile_pics = [{ - height: 150, - width: 150, - url: profile_pic_url - }, ...hd_profile_pic_versions] + const profile_pics = [ + { + height: 150, + width: 150, + url: profile_pic_url, + }, + ...hd_profile_pic_versions, + ]; return { id, @@ -24,6 +37,6 @@ export const mapUserProfile = (rawResponse: ThreadsUserProfileResponse) => { follower_count, bio_links, full_name, - profile_pics - } -} \ No newline at end of file + profile_pics, + }; +};