Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotBraem committed Feb 1, 2025
1 parent 790ab71 commit 2753375
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 85 deletions.
25 changes: 16 additions & 9 deletions backend/src/__tests__/mocks/twitter-service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ export class MockTwitterService extends TwitterService {
logout: async () => {},
getCookies: async () => [],
setCookies: async () => {},
fetchSearchTweets: async (query: string, count: number, mode: SearchMode) => {
fetchSearchTweets: async (
query: string,
count: number,
mode: SearchMode,
) => {
// Filter tweets that match the query (mentions @test_bot)
const matchingTweets = this.mockTweets.filter(tweet =>
tweet.text?.includes("@test_bot")
const matchingTweets = this.mockTweets.filter((tweet) =>
tweet.text?.includes("@test_bot"),
);

// Sort by ID descending (newest first) to match Twitter search behavior
Expand Down Expand Up @@ -87,7 +91,9 @@ export class MockTwitterService extends TwitterService {
inReplyToStatusId: tweet.inReplyToStatusId,
};
this.mockTweets.push(fullTweet);
logger.info(`Mock: Added tweet "${fullTweet.text}" from @${fullTweet.username}${tweet.inReplyToStatusId ? ` as reply to ${tweet.inReplyToStatusId}` : ''}`);
logger.info(
`Mock: Added tweet "${fullTweet.text}" from @${fullTweet.username}${tweet.inReplyToStatusId ? ` as reply to ${tweet.inReplyToStatusId}` : ""}`,
);
return fullTweet;
}

Expand Down Expand Up @@ -127,7 +133,7 @@ export class MockTwitterService extends TwitterService {
const bId = BigInt(b.id);
return bId > aId ? -1 : bId < aId ? 1 : 0; // Descending order (newest first)
})
.filter(tweet => {
.filter((tweet) => {
const tweetId = BigInt(tweet.id);
return !lastCheckedId || tweetId > lastCheckedId;
})
Expand All @@ -139,9 +145,10 @@ export class MockTwitterService extends TwitterService {
}

// Filter for mentions
const newMentions = latestTweets.filter(tweet =>
tweet.text?.includes("@test_bot") ||
tweet.mentions?.some(m => m.username === "test_bot")
const newMentions = latestTweets.filter(
(tweet) =>
tweet.text?.includes("@test_bot") ||
tweet.mentions?.some((m) => m.username === "test_bot"),
);

// Sort chronologically (oldest to newest) to match real service
Expand All @@ -165,7 +172,7 @@ export class MockTwitterService extends TwitterService {
this.testLastCheckedTweetId = tweetId;
logger.info(`Last checked tweet ID updated to: ${tweetId}`);
}

async getTweet(tweetId: string): Promise<Tweet | null> {
return this.mockTweets.find((t) => t.id === tweetId) || null;
}
Expand Down
16 changes: 14 additions & 2 deletions backend/src/routes/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import { MockTwitterService } from "../__tests__/mocks/twitter-service.mock";
const mockTwitterService = new MockTwitterService();

// Helper to create a tweet object
const createTweet = (id: string, text: string, username: string, inReplyToStatusId?: string, hashtags?: string[]): Tweet => {
const createTweet = (
id: string,
text: string,
username: string,
inReplyToStatusId?: string,
hashtags?: string[],
): Tweet => {
return {
id,
text,
Expand All @@ -33,7 +39,13 @@ export const testRoutes = new Elysia({ prefix: "/api/test" })
},
})
.post("/tweets", async ({ body }) => {
const { id, text, username, inReplyToStatusId, hashtags } = body as { id: string; text: string; username: string; inReplyToStatusId?: string; hashtags?: string[] };
const { id, text, username, inReplyToStatusId, hashtags } = body as {
id: string;
text: string;
username: string;
inReplyToStatusId?: string;
hashtags?: string[];
};
const tweet = createTweet(id, text, username, inReplyToStatusId, hashtags);
mockTwitterService.addMockTweet(tweet);
return tweet;
Expand Down
10 changes: 8 additions & 2 deletions backend/src/services/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ export class ConfigService {
private constructor() {
// Use test config in development mode
if (process.env.NODE_ENV === "development") {
this.configPath = path.resolve(__dirname, "../../../../curate.config.test.json");
this.configPath = path.resolve(
__dirname,
"../../../../curate.config.test.json",
);
logger.info("Using test configuration");
} else {
this.configPath = path.resolve(__dirname, "../../../../curate.config.json");
this.configPath = path.resolve(
__dirname,
"../../../../curate.config.json",
);
logger.info("Using production configuration");
}
}
Expand Down
142 changes: 71 additions & 71 deletions frontend/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,123 +10,123 @@

// Import Routes

import { Route as rootRoute } from './routes/__root'
import { Route as TestImport } from './routes/test'
import { Route as SettingsImport } from './routes/settings'
import { Route as IndexImport } from './routes/index'
import { Route as FeedFeedIdImport } from './routes/feed.$feedId'
import { Route as rootRoute } from "./routes/__root";
import { Route as TestImport } from "./routes/test";
import { Route as SettingsImport } from "./routes/settings";
import { Route as IndexImport } from "./routes/index";
import { Route as FeedFeedIdImport } from "./routes/feed.$feedId";

// Create/Update Routes

const TestRoute = TestImport.update({
id: '/test',
path: '/test',
id: "/test",
path: "/test",
getParentRoute: () => rootRoute,
} as any)
} as any);

const SettingsRoute = SettingsImport.update({
id: '/settings',
path: '/settings',
id: "/settings",
path: "/settings",
getParentRoute: () => rootRoute,
} as any)
} as any);

const IndexRoute = IndexImport.update({
id: '/',
path: '/',
id: "/",
path: "/",
getParentRoute: () => rootRoute,
} as any)
} as any);

const FeedFeedIdRoute = FeedFeedIdImport.update({
id: '/feed/$feedId',
path: '/feed/$feedId',
id: "/feed/$feedId",
path: "/feed/$feedId",
getParentRoute: () => rootRoute,
} as any)
} as any);

// Populate the FileRoutesByPath interface

declare module '@tanstack/react-router' {
declare module "@tanstack/react-router" {
interface FileRoutesByPath {
'/': {
id: '/'
path: '/'
fullPath: '/'
preLoaderRoute: typeof IndexImport
parentRoute: typeof rootRoute
}
'/settings': {
id: '/settings'
path: '/settings'
fullPath: '/settings'
preLoaderRoute: typeof SettingsImport
parentRoute: typeof rootRoute
}
'/test': {
id: '/test'
path: '/test'
fullPath: '/test'
preLoaderRoute: typeof TestImport
parentRoute: typeof rootRoute
}
'/feed/$feedId': {
id: '/feed/$feedId'
path: '/feed/$feedId'
fullPath: '/feed/$feedId'
preLoaderRoute: typeof FeedFeedIdImport
parentRoute: typeof rootRoute
}
"/": {
id: "/";
path: "/";
fullPath: "/";
preLoaderRoute: typeof IndexImport;
parentRoute: typeof rootRoute;
};
"/settings": {
id: "/settings";
path: "/settings";
fullPath: "/settings";
preLoaderRoute: typeof SettingsImport;
parentRoute: typeof rootRoute;
};
"/test": {
id: "/test";
path: "/test";
fullPath: "/test";
preLoaderRoute: typeof TestImport;
parentRoute: typeof rootRoute;
};
"/feed/$feedId": {
id: "/feed/$feedId";
path: "/feed/$feedId";
fullPath: "/feed/$feedId";
preLoaderRoute: typeof FeedFeedIdImport;
parentRoute: typeof rootRoute;
};
}
}

// Create and export the route tree

export interface FileRoutesByFullPath {
'/': typeof IndexRoute
'/settings': typeof SettingsRoute
'/test': typeof TestRoute
'/feed/$feedId': typeof FeedFeedIdRoute
"/": typeof IndexRoute;
"/settings": typeof SettingsRoute;
"/test": typeof TestRoute;
"/feed/$feedId": typeof FeedFeedIdRoute;
}

export interface FileRoutesByTo {
'/': typeof IndexRoute
'/settings': typeof SettingsRoute
'/test': typeof TestRoute
'/feed/$feedId': typeof FeedFeedIdRoute
"/": typeof IndexRoute;
"/settings": typeof SettingsRoute;
"/test": typeof TestRoute;
"/feed/$feedId": typeof FeedFeedIdRoute;
}

export interface FileRoutesById {
__root__: typeof rootRoute
'/': typeof IndexRoute
'/settings': typeof SettingsRoute
'/test': typeof TestRoute
'/feed/$feedId': typeof FeedFeedIdRoute
__root__: typeof rootRoute;
"/": typeof IndexRoute;
"/settings": typeof SettingsRoute;
"/test": typeof TestRoute;
"/feed/$feedId": typeof FeedFeedIdRoute;
}

export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
fullPaths: '/' | '/settings' | '/test' | '/feed/$feedId'
fileRoutesByTo: FileRoutesByTo
to: '/' | '/settings' | '/test' | '/feed/$feedId'
id: '__root__' | '/' | '/settings' | '/test' | '/feed/$feedId'
fileRoutesById: FileRoutesById
fileRoutesByFullPath: FileRoutesByFullPath;
fullPaths: "/" | "/settings" | "/test" | "/feed/$feedId";
fileRoutesByTo: FileRoutesByTo;
to: "/" | "/settings" | "/test" | "/feed/$feedId";
id: "__root__" | "/" | "/settings" | "/test" | "/feed/$feedId";
fileRoutesById: FileRoutesById;
}

export interface RootRouteChildren {
IndexRoute: typeof IndexRoute
SettingsRoute: typeof SettingsRoute
TestRoute: typeof TestRoute
FeedFeedIdRoute: typeof FeedFeedIdRoute
IndexRoute: typeof IndexRoute;
SettingsRoute: typeof SettingsRoute;
TestRoute: typeof TestRoute;
FeedFeedIdRoute: typeof FeedFeedIdRoute;
}

const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
SettingsRoute: SettingsRoute,
TestRoute: TestRoute,
FeedFeedIdRoute: FeedFeedIdRoute,
}
};

export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes<FileRouteTypes>()
._addFileTypes<FileRouteTypes>();

/* ROUTE_MANIFEST_START
{
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/routes/test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export const Route = createFileRoute("/test")({

function TestPage() {
const [selectedFeed, setSelectedFeed] = useState("test");
const [submissionTweetId, setSubmissionTweetId] = useState<string | null>(null);
const [submissionTweetId, setSubmissionTweetId] = useState<string | null>(
null,
);
const [tweetText, setTweetText] = useState("");
const [username, setUsername] = useState("curator");

Expand Down

0 comments on commit 2753375

Please sign in to comment.