Skip to content

Commit 670d7ca

Browse files
Merge branch 'v0/global/db0811' of https://github.com/thinc-org/ipix into v0/global/db0811
2 parents 7cb0fa1 + 7f1f073 commit 670d7ca

File tree

6 files changed

+46
-42
lines changed

6 files changed

+46
-42
lines changed

apps/api/src/index.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,32 @@ import { spaceRouter } from "./modules/space/route.js";
1212
import { itemRouter } from "./modules/item/route.js";
1313
import cron from "@elysiajs/cron";
1414
import { createDb } from "./drizzle/client.js";
15-
import {sql} from 'drizzle-orm'
15+
import { sql } from "drizzle-orm";
1616
import { uploadRouter } from "./modules/image/upload-multipart.js";
1717

1818
const db = createDb({ databaseUrl: process.env.DATABASE_URL });
1919

2020
const app = new Elysia()
21-
.use(betterAuthMiddleware)
22-
.use(cron({
23-
name: 'alphaRecalcQueueDelete',
24-
pattern: '0 */4 * * *',
25-
async run() {
26-
await db.execute(sql`DELETE FROM item_effective_recalc_queue WHERE enqueued_at < now() - interval '2 days';`)
27-
}
28-
}))
21+
.use(betterAuthMiddleware)
22+
.use(
23+
cron({
24+
name: "alphaRecalcQueueDelete",
25+
pattern: "0 */4 * * *",
26+
async run() {
27+
await db.execute(
28+
sql`DELETE FROM item_effective_recalc_queue WHERE enqueued_at < now() - interval '2 days';`
29+
);
30+
},
31+
})
32+
)
2933
.use(
3034
cors({
3135
origin: [
32-
"http://localhost:3000",
33-
"http://[::1]:3000",
34-
"http://localhost:5173",
35-
"http://localhost:5174",
36+
// "http://localhost:3000",
37+
// "http://[::1]:3000",
38+
// "http://localhost:5173",
39+
// "http://localhost:5174",
40+
`${process.env.ACCESS_CONTROL_ALLOW_ORIGIN!}:80`,
3641
],
3742
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
3843
credentials: true,
@@ -58,4 +63,4 @@ console.log(
5863
`🦊 Elysia is running at http://${app.server?.hostname}:${app.server?.port}`
5964
);
6065

61-
export type App = typeof app
66+
export type App = typeof app;

apps/api/src/modules/auth/route.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { createAuthMiddleware, openAPI } from "better-auth/plugins";
66
import { createDb } from "../../drizzle/client.js";
77
import { authSchema, storageSchema } from "@repo/rdb/schema";
88

9-
const db = createDb({databaseUrl: process.env.DATABASE_URL,})
9+
const db = createDb({ databaseUrl: process.env.DATABASE_URL });
1010

1111
export const auth = betterAuth({
1212
databaseHooks: {
@@ -41,13 +41,13 @@ export const auth = betterAuth({
4141
itemType: "folder",
4242
})
4343
.returning();
44-
})
45-
}
46-
}
47-
}
44+
});
45+
},
46+
},
47+
},
4848
},
49-
baseURL: "http://localhost:3000/auth",
50-
trustedOrigins: ["http://localhost:3000", "http://[::1]:3000"],
49+
baseURL: `${process.env.ACCESS_CONTROL_ALLOW_ORIGIN!}:80/auth`,
50+
trustedOrigins: [`${process.env.ACCESS_CONTROL_ALLOW_ORIGIN!}:80`],
5151
advanced: {
5252
defaultCookieAttributes: {
5353
sameSite: "lax",
@@ -72,7 +72,7 @@ export const auth = betterAuth({
7272
{
7373
schema: authSchema,
7474
provider: "pg",
75-
debugLogs: true
75+
debugLogs: true,
7676
}
7777
),
7878
emailAndPassword: {
@@ -83,7 +83,7 @@ export const auth = betterAuth({
8383
enabled: true,
8484
clientId: process.env.GOOGLE_CLIENT_ID as string,
8585
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
86-
redirectURI: "http://localhost:20257/api/auth/callback/google",
86+
redirectURI: `${process.env.API_BASE_URL!}:20257/api/auth/callback/google`,
8787
accessType: "offline",
8888
prompt: "select_account",
8989
},
@@ -119,7 +119,7 @@ export const betterAuthMiddleware = new Elysia({ name: "better-auth" })
119119
.all("/api/auth/*", async (context: Context) => {
120120
if (["POST", "GET"].includes(context.request.method)) {
121121
const response = await auth.handler(context.request);
122-
122+
123123
console.log(response);
124124
// If it's a redirect response, make sure to return it properly
125125
if (response && response.status >= 300 && response.status < 400) {
@@ -171,4 +171,4 @@ export const betterAuthMiddleware = new Elysia({ name: "better-auth" })
171171
};
172172
},
173173
}),
174-
});
174+
});

apps/web/src/components/base-component/sidebar.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@ export function Sidebar({
6363
<AvatarImage src={userInfo.imageProfile} />
6464
<AvatarFallback>U</AvatarFallback>
6565
</Avatar>
66-
<div className="max-sm:text-sm">
66+
<div className="text-xs">
6767
{userInfo.email ?? (
6868
<span className="inline-block h-4 w-28 animate-pulse rounded bg-slate-200 dark:bg-slate-700" />
6969
)}
7070
</div>
7171
</div>
72-
<SignOutButton />
72+
<div className="absolute right-1 text-xs">
73+
<SignOutButton />
74+
</div>
7375
</div>
7476

7577
<nav className="space-y-2">

apps/web/src/components/base-component/sign-out-button.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ export function SignOutButton() {
2525
return (
2626
<Dialog open={open} onOpenChange={setOpen}>
2727
<DialogTrigger asChild>
28-
<Button
29-
variant="ghost"
30-
size="sm"
31-
className="text-gray-500 max-sm:text-xs p-0"
32-
>
28+
<Button variant="ghost" size="sm" className="text-gray-500 text-xs p-0">
3329
Log Out
3430
</Button>
3531
</DialogTrigger>

packages/s3/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const {
99
SECRET_ACCESS_KEY,
1010
FORCE_PATH_STYLE,
1111
ACCESS_CONTROL_ALLOW_ORIGIN,
12-
PRE_SIGNED_URL_EXPIRE_IN, // in seconds
12+
PRE_SIGNED_URL_EXPIRE_IN,
13+
REDIS_URL, // in seconds
1314
} = Bun.env;
1415

1516
const requiredEnvVars = {
@@ -21,6 +22,7 @@ const requiredEnvVars = {
2122
FORCE_PATH_STYLE,
2223
ACCESS_CONTROL_ALLOW_ORIGIN,
2324
PRE_SIGNED_URL_EXPIRE_IN,
25+
REDIS_URL,
2426
};
2527

2628
for (const [key, value] of Object.entries(requiredEnvVars)) {
@@ -61,9 +63,9 @@ function createSTSClient(): STSClient {
6163

6264
export const accessControlAllowOrigin = ACCESS_CONTROL_ALLOW_ORIGIN as string;
6365
export const expiresIn = Number(PRE_SIGNED_URL_EXPIRE_IN);
64-
export const s3Bucket = S3_BUCKET as string
65-
export const s3Region = S3_REGION as string
66-
export const s3Endpoint = S3_ENDPOINT as string
66+
export const s3Bucket = S3_BUCKET as string;
67+
export const s3Region = S3_REGION as string;
68+
export const s3Endpoint = S3_ENDPOINT as string;
6769

6870
export const s3 = createS3Client();
6971
export const sts = createSTSClient();

packages/s3/src/worker-preview.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,18 @@ export type PreviewJob = {
7575
};
7676

7777
// Env
78-
const {
79-
REDIS_URL = "redis://127.0.0.1:6379",
80-
DATABASE_URL,
81-
S3_BUCKET,
82-
} = process.env as Record<string, string | undefined>;
78+
const { REDIS_URL, DATABASE_URL, S3_BUCKET } = process.env as Record<
79+
string,
80+
string | undefined
81+
>;
8382

8483
if (!DATABASE_URL) {
8584
throw new Error("DATABASE_URL is required for preview worker");
8685
}
8786

8887
// BullMQ workers use blocking Redis commands; ioredis must not retry requests.
8988
// See error: "BullMQ: Your redis options maxRetriesPerRequest must be null."
90-
const redis = new Redis(REDIS_URL, {
89+
const redis = new Redis(REDIS_URL!, {
9190
maxRetriesPerRequest: null,
9291
});
9392
export const PREVIEW_QUEUE_NAME = "preview.generate";

0 commit comments

Comments
 (0)