Skip to content

Commit 71d4969

Browse files
fix: remove elysia-rate-limit, update dependencies and scripts
- Added "cross-env" as a dev dependency in the root package.json. - Removed "elysia-rate-limit" from dependencies in the root package.json. because it somehow made better-auth unable to access db (doesn't affect other func) - Updated scripts in packages/s3/package.json to use the correct commands for building and running the worker preview.
1 parent d019e75 commit 71d4969

5 files changed

Lines changed: 22 additions & 102 deletions

File tree

apps/api/src/index.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,18 @@ import cron from "@elysiajs/cron";
1414
import { createDb } from "./drizzle/client.js";
1515
import {sql} from 'drizzle-orm'
1616
import { uploadRouter } from "./modules/image/upload-multipart.js";
17-
import { rateLimit } from "elysia-rate-limit";
1817

1918
const db = createDb({ databaseUrl: process.env.DATABASE_URL });
2019

2120
const app = new Elysia()
22-
.use(rateLimit({duration: 60000, max: 500, scoping: 'global'}))
23-
.use(betterAuthMiddleware)
24-
.use(cron({
25-
name: 'alphaRecalcQueueDelete',
26-
pattern: '0 */4 * * *',
27-
async run() {
28-
await db.execute(sql`DELETE FROM item_effective_recalc_queue WHERE enqueued_at < now() - interval '2 days';`)
29-
}
30-
}))
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+
}))
3129
.use(
3230
cors({
3331
origin: [

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const auth = betterAuth({
5151
advanced: {
5252
defaultCookieAttributes: {
5353
sameSite: "lax",
54-
secure: false, // TODO Set to true in production with HTTPS
54+
secure: true, // TODO Set to true in production with HTTPS
5555
},
5656
database: {
5757
generateId: (options: {}) => {
@@ -118,7 +118,8 @@ export const betterAuthMiddleware = new Elysia({ name: "better-auth" })
118118
.all("/api/auth/*", async (context: Context) => {
119119
if (["POST", "GET"].includes(context.request.method)) {
120120
const response = await auth.handler(context.request);
121-
121+
122+
console.log(response);
122123
// If it's a redirect response, make sure to return it properly
123124
if (response && response.status >= 300 && response.status < 400) {
124125
const location = response.headers.get("Location");
@@ -139,7 +140,6 @@ export const betterAuthMiddleware = new Elysia({ name: "better-auth" })
139140

140141
context.status(405);
141142
})
142-
.mount(auth.handler)
143143
.macro({
144144
// Boolean or object config; context always includes user/session (nullable when unauthenticated)
145145
auth: (config: { allowPublic: boolean }) => ({

0 commit comments

Comments
 (0)