mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-09 12:30:54 +01:00
🚨 Cleaned up linter errors and added basic html
This commit is contained in:
parent
1f8ca1c8b3
commit
68f77c98cd
2 changed files with 19 additions and 13 deletions
|
@ -1,12 +1,5 @@
|
||||||
import { renderCard } from '../helpers/card';
|
|
||||||
import { Constants } from '../constants';
|
import { Constants } from '../constants';
|
||||||
import { fetchConversation, fetchUser } from '../fetch';
|
import { 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';
|
|
||||||
|
|
||||||
/* This function does the heavy lifting of processing data from Twitter API
|
/* This function does the heavy lifting of processing data from Twitter API
|
||||||
and using it to create FixTweet's streamlined API responses */
|
and using it to create FixTweet's streamlined API responses */
|
||||||
|
|
23
src/user.ts
23
src/user.ts
|
@ -1,8 +1,5 @@
|
||||||
import { Constants } from './constants';
|
import { Constants } from './constants';
|
||||||
import { handleQuote } from './helpers/quote';
|
|
||||||
import { formatNumber, sanitizeText } from './helpers/utils';
|
|
||||||
import { Strings } from './strings';
|
import { Strings } from './strings';
|
||||||
import { getAuthorText } from './helpers/author';
|
|
||||||
import { userAPI } from './api/user';
|
import { userAPI } from './api/user';
|
||||||
|
|
||||||
export const returnError = (error: string): StatusResponse => {
|
export const returnError = (error: string): StatusResponse => {
|
||||||
|
@ -32,7 +29,7 @@ export const handleProfile = async (
|
||||||
|
|
||||||
/* Catch this request if it's an API response */
|
/* Catch this request if it's an API response */
|
||||||
// For now we just always return the API response while testing
|
// For now we just always return the API response while testing
|
||||||
if (flags?.api || true) {
|
if (flags?.api) {
|
||||||
return {
|
return {
|
||||||
response: new Response(JSON.stringify(api), {
|
response: new Response(JSON.stringify(api), {
|
||||||
headers: { ...Constants.RESPONSE_HEADERS, ...Constants.API_RESPONSE_HEADERS },
|
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 */
|
/* If there was any errors fetching the User, we'll return it */
|
||||||
switch (api.code || true) {
|
switch (api.code) {
|
||||||
case 401:
|
case 401:
|
||||||
return returnError(Strings.ERROR_PRIVATE);
|
return returnError(Strings.ERROR_PRIVATE);
|
||||||
case 404:
|
case 404:
|
||||||
|
@ -50,4 +47,20 @@ export const handleProfile = async (
|
||||||
case 500:
|
case 500:
|
||||||
return returnError(Strings.ERROR_API_FAIL);
|
return returnError(Strings.ERROR_API_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Base headers included in all responses */
|
||||||
|
const headers = [
|
||||||
|
`<meta property="twitter:site" content="@${user.screen_name}"/>`,
|
||||||
|
];
|
||||||
|
|
||||||
|
// 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
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue