From 68f77c98cdeb5058d662f07c5d92ab8aa57cbf45 Mon Sep 17 00:00:00 2001 From: Wazbat Date: Sat, 15 Apr 2023 20:14:52 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20Cleaned=20up=20linter=20errors?= =?UTF-8?q?=20and=20added=20basic=20html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user.ts | 9 +-------- src/user.ts | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/api/user.ts b/src/api/user.ts index 79e4c8d..12a968e 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -1,12 +1,5 @@ -import { renderCard } from '../helpers/card'; import { Constants } from '../constants'; -import { fetchConversation, fetchUser } from '../fetch'; -import { linkFixer } from '../helpers/linkFixer'; -import { handleMosaic } from '../helpers/mosaic'; -import { colorFromPalette } from '../helpers/palette'; -import { translateTweet } from '../helpers/translate'; -import { unescapeText } from '../helpers/utils'; -import { processMedia } from '../helpers/media'; +import { fetchUser } from '../fetch'; /* This function does the heavy lifting of processing data from Twitter API and using it to create FixTweet's streamlined API responses */ diff --git a/src/user.ts b/src/user.ts index ac4037d..a41fc8a 100644 --- a/src/user.ts +++ b/src/user.ts @@ -1,8 +1,5 @@ import { Constants } from './constants'; -import { handleQuote } from './helpers/quote'; -import { formatNumber, sanitizeText } from './helpers/utils'; import { Strings } from './strings'; -import { getAuthorText } from './helpers/author'; import { userAPI } from './api/user'; export const returnError = (error: string): StatusResponse => { @@ -32,7 +29,7 @@ export const handleProfile = async ( /* Catch this request if it's an API response */ // For now we just always return the API response while testing - if (flags?.api || true) { + if (flags?.api) { return { response: new Response(JSON.stringify(api), { headers: { ...Constants.RESPONSE_HEADERS, ...Constants.API_RESPONSE_HEADERS }, @@ -42,7 +39,7 @@ export const handleProfile = async ( } /* If there was any errors fetching the User, we'll return it */ - switch (api.code || true) { + switch (api.code) { case 401: return returnError(Strings.ERROR_PRIVATE); case 404: @@ -50,4 +47,20 @@ export const handleProfile = async ( case 500: return returnError(Strings.ERROR_API_FAIL); } + + /* Base headers included in all responses */ + const headers = [ + ``, + ]; + + // TODO Add card creation logic here + + /* Finally, after all that work we return the response HTML! */ + return { + text: Strings.BASE_HTML.format({ + lang: `lang="en"`, + headers: headers.join('') + }), + cacheControl: null + }; };