Skip to content

Commit c881c42

Browse files
elliotBraemitexpert120coderabbitai[bot]
authored
Upgrade staging (#195)
* moderation handle platform_user_id and near account id * standardize activity * fmt * delete tests * fix shared types * activity leaderboard * throw not error * fix services * feat: use tanstack table for leaderboard (#183) * fix: mobile layout improvement feed page (#185) * Refactors create feed flow, steps use router (#188) * wip * feed types * better feed form * Update packages/shared-db/tsconfig.json Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update apps/app/src/routes/_layout/create/feed/settings.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update apps/app/src/routes/_layout/create/feed/index.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * set lock * nitpicks * fmt --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Implements JWT auth flow with 7 day tokens (#187) * better auth services * nit picks * nonce validation * nitpicks * clean up * fix error types * import error * fix auth requests * fix: toast colors not correct (#189) * fix: toast colors not corrent * fmt * fix feed * fix zod type * fix @ and config * fmt * feat: add settings page UI * feat: add route based tab navigation * feat: welcome route for new feed (#192) * feat: welcome route for new feed * fix: feed overflow in top feeds column of leaderboard * fix: coderabbit comments * moderate submissions * fmt * fmt * adds auto approval * auto approval * upgrade fastintear * fix auth flow * upgrade packages * nitpicks * Introduces worker service w/ queues, enables auto-approval (#196) * init * clean up * fmt * build fixes * init * running * working auto approval * init * clean up * fmt * build fixes * init * running * working auto approval * clean up * nitpicks * update pnpm lock * add @roamhq/wrtc * docker and type module * agent-twitter-client * add rspack * REDIS_URL * bullmq workaround * clean config * fix auth flow * same flow * logger * better logger * railway logger --------- Co-authored-by: Zeeshan Ahmad <itexpert120@outlook.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 3d2bb77 commit c881c42

File tree

108 files changed

+2954
-2254
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+2954
-2254
lines changed

apps/api/.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ JWT_SECRET=your_jwt_secret
1212
# CORS Configuration
1313
ALLOWED_ORIGINS=https://example.com,https://api.example.com
1414

15+
# Redis Configuration
16+
REDIS_HOST=localhost
17+
REDIS_PORT=6379
18+
1519
#PLUGINS
1620

1721
# Telegram Distributor Configuration

apps/api/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ COPY --from=pruner /app/turbo.json ./turbo.json
2929
COPY --from=pruner /app/pnpm-workspace.yaml ./pnpm-workspace.yaml
3030
COPY --from=pruner /app/tsconfig.json ./tsconfig.json
3131

32+
# Install build dependencies for native modules
33+
RUN apk add --no-cache python3 make g++
34+
3235
# Install ALL dependencies for the pruned monorepo subset (including devDependencies for build processes)
3336
RUN pnpm install --frozen-lockfile
3437

apps/api/package.json

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,54 +21,40 @@
2121
]
2222
},
2323
"devDependencies": {
24-
"@module-federation/node": "^2.6.30",
24+
"@module-federation/node": "^2.7.7",
2525
"@rspack/binding": "1.2.8",
2626
"@rspack/cli": "1.2.8",
2727
"@rspack/core": "1.2.8",
28-
"@types/mustache": "^4.2.6",
29-
"axios": "^1.6.8",
30-
"concurrently": "^9.1.2",
31-
"drizzle-seed": "^0.3.1",
32-
"nock": "^13.5.4",
33-
"typescript": "^5.3.3",
34-
"wait-on": "^8.0.2",
35-
"zod": "^3.25.62"
28+
"@types/lodash": "^4.17.18",
29+
"@types/pg": "^8.15.4",
30+
"concurrently": "^9.2.0",
31+
"typescript": "^5.8.3",
32+
"wait-on": "^8.0.3"
3633
},
3734
"dependencies": {
3835
"@crosspost/scheduler-sdk": "^0.1.1",
39-
"@crosspost/sdk": "^0.3.0",
40-
"@crosspost/types": "^0.3.0",
36+
"@crosspost/sdk": "^0.3.1",
37+
"@crosspost/types": "^0.3.1",
38+
"@curatedotfun/core-services": "workspace:*",
4139
"@curatedotfun/shared-db": "workspace:*",
40+
"@curatedotfun/shared-queue": "workspace:*",
4241
"@curatedotfun/types": "workspace:*",
4342
"@curatedotfun/utils": "workspace:*",
44-
"@fastnear/utils": "^0.9.7",
45-
"@hono/node-server": "^1.8.2",
46-
"@hono/zod-openapi": "^0.9.5",
43+
"@hono/node-server": "^1.14.4",
4744
"@hono/zod-validator": "^0.5.0",
48-
"@module-federation/runtime": "^0.11.1",
49-
"@t3-oss/env-core": "^0.13.6",
50-
"@types/async-retry": "^1.4.9",
51-
"@types/lodash": "^4.17.16",
52-
"@types/pg": "^8.11.11",
53-
"agent-twitter-client": "^0.0.16",
54-
"async-retry": "^1.3.3",
55-
"dotenv": "^16.4.7",
56-
"drizzle-kit": "^0.31.1",
45+
"@module-federation/runtime": "^0.11.4",
46+
"agent-twitter-client": "0.0.16",
47+
"bullmq": "^5.56.0",
48+
"dotenv": "^16.5.0",
5749
"drizzle-orm": "^0.43.1",
58-
"drizzle-zod": "^0.7.1",
59-
"hono": "^4.0.5",
60-
"jose": "^6.0.11",
61-
"lodash": "^4.17.21",
62-
"mustache": "^4.2.0",
63-
"near-api-js": "^5.1.1",
64-
"near-sign-verify": "^0.4.1",
65-
"ora": "^8.1.1",
66-
"pg": "^8.15.6",
50+
"hono": "^4.8.2",
51+
"ora": "^8.2.0",
52+
"pg": "^8.16.2",
6753
"pinata-web3": "^0.5.4",
68-
"pino": "^9.6.0",
54+
"pino": "^9.7.0",
6955
"pino-pretty": "^13.0.0",
70-
"remeda": "^2.22.5",
7156
"string-width": "^7.2.0",
57+
"zod": "^3.25.67",
7258
"zod-to-json-schema": "^3.24.5"
7359
},
7460
"packageManager": "pnpm@10.11.0"

apps/api/rspack.config.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ module.exports = {
1313
externals: {
1414
bufferutil: "commonjs bufferutil",
1515
"pg-native": "commonjs pg-native",
16+
"@roamhq/wrtc": "commonjs @roamhq/wrtc",
17+
"utf-8-validate": "commonjs utf-8-validate",
1618
},
1719
output: {
1820
path: path.resolve(__dirname, "dist"),
@@ -35,11 +37,7 @@ module.exports = {
3537
resolve: {
3638
extensions: [".ts", ".ts", ".js"],
3739
alias: {
38-
services: path.resolve(__dirname, "src/services"),
39-
utils: path.resolve(__dirname, "src/utils"),
40-
types: path.resolve(__dirname, "src/types"),
41-
routes: path.resolve(__dirname, "src/routes"),
42-
validation: path.resolve(__dirname, "src/validation"),
40+
"@": path.resolve(__dirname, "./src"),
4341
},
4442
},
4543
plugins: [

apps/api/src/app.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
1+
import { ServiceProvider } from "@curatedotfun/core-services";
2+
import { createLogger } from "@curatedotfun/utils";
13
import { Hono } from "hono";
24
import { cors } from "hono/cors";
35
import { secureHeaders } from "hono/secure-headers";
46
import { db } from "./db";
7+
import { createAuthMiddleware } from "./middlewares/auth.middleware";
58
import { apiRoutes } from "./routes/api";
69
import { AppInstance, Env } from "./types/app";
710
import { getAllowedOrigins } from "./utils/config";
811
import { errorHandler } from "./utils/error";
9-
import { ServiceProvider } from "./utils/service-provider";
10-
import { logger } from "utils/logger";
11-
import { createAuthMiddleware } from "./middlewares/auth.middleware";
1212

1313
const ALLOWED_ORIGINS = getAllowedOrigins();
1414

1515
export async function createApp(): Promise<AppInstance> {
16-
ServiceProvider.initialize();
17-
const sp = ServiceProvider.getInstance();
16+
const logger = createLogger({ service: "api" });
17+
const sp = ServiceProvider.getInstance({
18+
db,
19+
logger,
20+
env: {
21+
NODE_ENV: process.env.NODE_ENV || "development",
22+
SUPER_ADMIN_ACCOUNTS: process.env.SUPER_ADMIN_ACCOUNTS,
23+
TWITTER_USERNAME: process.env.TWITTER_USERNAME,
24+
TWITTER_PASSWORD: process.env.TWITTER_PASSWORD,
25+
TWITTER_EMAIL: process.env.TWITTER_EMAIL,
26+
TWITTER_2FA_SECRET: process.env.TWITTER_2FA_SECRET,
27+
MASTER_KEYPAIR: process.env.MASTER_KEYPAIR,
28+
},
29+
});
30+
await sp.init();
1831

1932
const app = new Hono<Env>();
2033

@@ -26,11 +39,9 @@ export async function createApp(): Promise<AppInstance> {
2639
"*",
2740
cors({
2841
origin: (origin) => {
29-
// Check if origin is in the allowed list
3042
if (ALLOWED_ORIGINS.includes(origin)) {
3143
return origin;
3244
}
33-
// Otherwise, allow same-origin requests (frontend)
3445
return origin;
3546
},
3647
allowMethods: ["GET", "POST"],

apps/api/src/db/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { schema, type DB } from "@curatedotfun/shared-db";
22
import { drizzle } from "drizzle-orm/node-postgres";
33
import { Pool } from "pg";
44

5+
if (!process.env.DATABASE_URL) {
6+
throw new Error("DATABASE_URL environment variable is required");
7+
}
8+
59
const pool = new Pool({
610
connectionString: process.env.DATABASE_URL!,
711
});

apps/api/src/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
createSection,
1212
logger,
1313
} from "./utils/logger";
14-
import { ServiceProvider } from "./utils/service-provider";
14+
import { ServiceProvider } from "@curatedotfun/core-services";
1515

1616
const PORT = Number(process.env.PORT) || 3000;
1717

@@ -22,8 +22,6 @@ async function startServer() {
2222
const { app } = await createApp();
2323
const sp = ServiceProvider.getInstance();
2424

25-
await sp.init();
26-
2725
app.get("/health", (c) => {
2826
const health = {
2927
status: "OK",

apps/api/src/routes/api/activity.ts

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1+
import { ActivityServiceError } from "@curatedotfun/utils";
12
import { zValidator } from "@hono/zod-validator";
23
import { Hono } from "hono";
34
import { ContentfulStatusCode } from "hono/utils/http-status";
45
import { Env } from "../../types/app";
5-
import { ActivityServiceError } from "../../types/errors";
6-
import { ServiceProvider } from "../../utils/service-provider";
76

87
import {
98
ActivityFeedPathParamsSchema,
9+
ActivityListResponseSchema,
1010
ActivityUserPathParamsSchema,
11+
ApiErrorResponseSchema,
12+
FeedInfoListResponseSchema,
1113
GetLeaderboardApiQuerySchema,
1214
GetUserActivitiesApiQuerySchema,
13-
ActivityListResponseSchema,
14-
LeaderboardResponseSchema,
1515
GlobalStatsResponseSchema,
16-
FeedInfoListResponseSchema,
16+
LeaderboardResponseSchema,
1717
UserFeedRankResponseSchema,
18-
ApiErrorResponseSchema,
1918
} from "@curatedotfun/types";
2019

2120
const activityRoutes = new Hono<Env>();
@@ -31,8 +30,8 @@ activityRoutes.get(
3130
try {
3231
const options = c.req.valid("query");
3332

34-
const activityService =
35-
ServiceProvider.getInstance().getActivityService();
33+
const sp = c.var.sp;
34+
const activityService = sp.getActivityService();
3635
const leaderboard =
3736
await activityService.getUserRankingLeaderboard(options);
3837

@@ -81,7 +80,8 @@ activityRoutes.get(
8180
*/
8281
activityRoutes.get("/stats", async (c) => {
8382
try {
84-
const activityService = ServiceProvider.getInstance().getActivityService();
83+
const sp = c.var.sp;
84+
const activityService = sp.getActivityService();
8585
const stats = await activityService.getGlobalStats();
8686

8787
return c.json(
@@ -138,8 +138,8 @@ activityRoutes.get("/user/me", async (c) => {
138138

139139
try {
140140
// Get services from the service provider
141-
const serviceProvider = ServiceProvider.getInstance();
142-
const activityService = serviceProvider.getActivityService();
141+
const sp = c.var.sp;
142+
const activityService = sp.getActivityService();
143143

144144
const activities = await activityService.getUserActivities(accountId);
145145

@@ -187,9 +187,8 @@ activityRoutes.get(
187187
try {
188188
const { accountId } = c.req.valid("param");
189189
const options = c.req.valid("query");
190-
191-
const activityService =
192-
ServiceProvider.getInstance().getActivityService();
190+
const sp = c.var.sp;
191+
const activityService = sp.getActivityService();
193192
const activities = await activityService.getUserActivities(
194193
accountId,
195194
options,
@@ -255,10 +254,9 @@ activityRoutes.get("/feeds/curated-by/me", async (c) => {
255254
}
256255

257256
try {
258-
// Get services from the service provider
259-
const serviceProvider = ServiceProvider.getInstance();
260-
const userService = serviceProvider.getUserService();
261-
const activityService = serviceProvider.getActivityService();
257+
const sp = c.var.sp;
258+
const userService = sp.getUserService();
259+
const activityService = sp.getActivityService();
262260

263261
const user = await userService.findUserByNearAccountId(accountId);
264262

@@ -332,10 +330,9 @@ activityRoutes.get("/feeds/approved-by/me", async (c) => {
332330
}
333331

334332
try {
335-
// Get services from the service provider
336-
const serviceProvider = ServiceProvider.getInstance();
337-
const userService = serviceProvider.getUserService();
338-
const activityService = serviceProvider.getActivityService();
333+
const sp = c.var.sp;
334+
const userService = sp.getUserService();
335+
const activityService = sp.getActivityService();
339336

340337
const user = await userService.findUserByNearAccountId(accountId);
341338

@@ -414,10 +411,9 @@ activityRoutes.get(
414411
try {
415412
const { feedId } = c.req.valid("param");
416413

417-
// Get services from the service provider
418-
const serviceProvider = ServiceProvider.getInstance();
419-
const userService = serviceProvider.getUserService();
420-
const activityService = serviceProvider.getActivityService();
414+
const sp = c.var.sp;
415+
const userService = sp.getUserService();
416+
const activityService = sp.getActivityService();
421417

422418
const user = await userService.findUserByNearAccountId(accountId);
423419

apps/api/src/routes/api/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Hono } from "hono";
22
import { zValidator } from "@hono/zod-validator";
33
import { z } from "zod";
4-
import { AuthService } from "../../services/auth.service";
54
import { Env } from "../../types/app";
65
import { setCookie } from "hono/cookie";
6+
import type { AuthService } from "@curatedotfun/core-services";
77

88
export const authRoutes = new Hono<Env>();
99

apps/api/src/routes/api/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Hono } from "hono";
2-
import { Env } from "types/app";
2+
import { Env } from "@/types/app";
33

44
const configRoutes = new Hono<Env>();
55

0 commit comments

Comments
 (0)