Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 0 additions & 93 deletions app/lib/account.ts

This file was deleted.

40 changes: 15 additions & 25 deletions app/lib/api/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ export const accountTimeline = async (
id: string,
token: string | undefined,
basePath: string,
beforeID?: string
beforeID?: string,
afterID?: string
): Promise<TimelineResponse[] | { error: string }> => {
try {
const { data: response, error } = await getV0TimelineAccountsId({
Expand All @@ -84,38 +85,27 @@ export const accountTimeline = async (
`/v0/timeline/accounts/${encodeURIComponent(id)}`
),
path: { id },
query: beforeID ? { before_id: beforeID } : undefined,
query: beforeID
? { before_id: beforeID }
: afterID
? { after_id: afterID }
: undefined,
});
if (error || !response) {
return { error: parseApiErrorMessage(error) };
}

return response.map(
(item) =>
const timelineNotes = response.map(
(note) =>
({
id: item.id,
content: item.content,
contents_warning_comment: item.contents_warning_comment,
visibility: item.visibility as "PUBLIC" | "HOME" | "FOLLOWERS",
created_at: new Date(item.created_at),
author: {
id: item.author.id,
name: item.author.name,
display_name: item.author.display_name,
bio: item.author.bio,
avatar: item.author.avatar,
header: item.author.header,
followed_count: item.author.followed_count,
following_count: item.author.following_count,
},
reactions: item.reactions.map(
(reaction): TimelineResponse["reactions"][number] => ({
emoji: reaction.emoji,
reacted_by: reaction.reacted_by,
})
),
...note,
created_at: new Date(note.created_at),
visibility: note.visibility as TimelineResponse["visibility"],
}) satisfies TimelineResponse
);
return afterID
? timelineNotes.filter((note) => note.id !== afterID).reverse()
: timelineNotes;
} catch {
return { error: "unknown error" };
}
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { LoaderFunctionArgs } from "react-router";
import { Link, useLoaderData } from "react-router";

import { account } from "~/lib/account";
import { account } from "~/lib/api/account";
import { getToken } from "~/lib/api/getToken";
import { cloudflareContext } from "~/lib/cloudflareContext";
import { parseToken } from "~/lib/parseToken";
Expand Down
4 changes: 2 additions & 2 deletions app/routes/accounts.$id._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { FollowButton } from "~/components/followButton";
import { LoadMoreNoteButton } from "~/components/loadMoreNote";
import type { NoteProps } from "~/components/note";
import { Note } from "~/components/note";
import type { AccountResponse } from "~/lib/account";
import { account, accountTimeline } from "~/lib/account";
import type { AccountResponse } from "~/lib/api/account";
import { account, accountTimeline } from "~/lib/api/account";
import { getToken } from "~/lib/api/getToken";
import { loggedInAccount } from "~/lib/api/loggedInAccount";
import { fetchNote } from "~/lib/api/note";
Expand Down
2 changes: 1 addition & 1 deletion app/routes/accounts.$id.follower.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { redirect, useLoaderData, type LoaderFunctionArgs } from "react-router";

import { FollowAccount } from "~/components/followAccount";
import { account } from "~/lib/account";
import { account } from "~/lib/api/account";
import { getFollowersList, type FollowerResponse } from "~/lib/api/followlist";
import { getToken } from "~/lib/api/getToken";
import { cloudflareContext } from "~/lib/cloudflareContext";
Expand Down
2 changes: 1 addition & 1 deletion app/routes/accounts.$id.following.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { redirect, useLoaderData, type LoaderFunctionArgs } from "react-router";

import { FollowAccount } from "~/components/followAccount";
import { account } from "~/lib/account";
import { account } from "~/lib/api/account";
import { getFollowingList, type FollowingResponse } from "~/lib/api/followlist";
import { getToken } from "~/lib/api/getToken";
import { cloudflareContext } from "~/lib/cloudflareContext";
Expand Down
5 changes: 0 additions & 5 deletions app/routes/signup._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ export const action = async ({

try {
const env = context.get(cloudflareContext).env;
if (env.API_BASE_URL == null) {
logger.error("API_BASE_URL env was not configured");
return { error: "Something went wrong" };
}

const { error } = await postV0Accounts({
...apiOptions(env.API_BASE_URL),
body: {
Expand Down
106 changes: 55 additions & 51 deletions wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,60 @@
* https://developers.cloudflare.com/workers/wrangler/configuration/
*/
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "caramel",
"compatibility_date": "2025-04-04",
"main": "./workers/app.ts",
"observability": {
"enabled": true
"$schema": "node_modules/wrangler/config-schema.json",
"name": "caramel",
"compatibility_date": "2025-04-04",
"main": "./workers/app.ts",
"observability": {
"enabled": true,
},
"vars": {
"API_BASE_URL": "http://localhost:3000",
"INSTANCE_FQDN": "example.com",
},
"env": {
"demo": {
"vars": {
"API_BASE_URL": "https://demo.pulsate.dev",
"INSTANCE_FQDN": "demo.pulsate.dev",
},
},
"env": {
"demo": {
"vars": {
"API_BASE_URL": "https://demo.pulsate.dev",
"INSTANCE_FQDN": "demo.pulsate.dev"
}
},
"ci": {
"vars": {
"API_BASE_URL": "http://localhost:3000",
"INSTANCE_FQDN": "example.com",
"TURNSTILE_KEY": "1x00000000000000000000AA"
}
}
}
/**
* Smart Placement
* Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
*/
// "placement": { "mode": "smart" },
/**
* Bindings
* Bindings allow your Worker to interact with resources on the Cloudflare Developer Platform, including
* databases, object storage, AI inference, real-time communication and more.
* https://developers.cloudflare.com/workers/runtime-apis/bindings/
*/
/**
* Environment Variables
* https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
*/
// "vars": { "MY_VARIABLE": "production_value" },
/**
* Note: Use secrets to store sensitive data.
* https://developers.cloudflare.com/workers/configuration/secrets/
*/
/**
* Static Assets
* https://developers.cloudflare.com/workers/static-assets/binding/
*/
// "assets": { "directory": "./public/", "binding": "ASSETS" },
/**
* Service Bindings (communicate between multiple Workers)
* https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
*/
// "services": [{ "binding": "MY_SERVICE", "service": "my-service" }]
"ci": {
"vars": {
"API_BASE_URL": "http://localhost:3000",
"INSTANCE_FQDN": "example.com",
"TURNSTILE_KEY": "1x00000000000000000000AA",
},
},
},
/**
* Smart Placement
* Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
*/
// "placement": { "mode": "smart" },
/**
* Bindings
* Bindings allow your Worker to interact with resources on the Cloudflare Developer Platform, including
* databases, object storage, AI inference, real-time communication and more.
* https://developers.cloudflare.com/workers/runtime-apis/bindings/
*/
/**
* Environment Variables
* https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
*/
// "vars": { "MY_VARIABLE": "production_value" },
/**
* Note: Use secrets to store sensitive data.
* https://developers.cloudflare.com/workers/configuration/secrets/
*/
/**
* Static Assets
* https://developers.cloudflare.com/workers/static-assets/binding/
*/
// "assets": { "directory": "./public/", "binding": "ASSETS" },
/**
* Service Bindings (communicate between multiple Workers)
* https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
*/
// "services": [{ "binding": "MY_SERVICE", "service": "my-service" }]
}