Skip to content

Commit

Permalink
feat: cleanup cookie passing and rm debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
ndom91 committed Aug 11, 2024
1 parent 280ee0b commit 0a2e832
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 11 deletions.
4 changes: 0 additions & 4 deletions apps/backend/src/jobs/queue-worker/create-screenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export interface CreateScreenshot {
}

export const createScreenshot = async (data: CreateScreenshot) => {
console.log("CREATING SCREENSHOT")
if (
!process.env.BUCKET_PUBLIC_URL
|| !process.env.BUCKET_SECRET_KEY
Expand Down Expand Up @@ -83,10 +82,7 @@ const updateImageUrl = async ({
}

const screenshotUrl = async ({ url }: ScreenshotArgs) => {

console.log("SCREENSHOTURL")
const localChromiumPath = await getLocalChromiumPath()
console.log("SCREENSHOTURL.LOCALCHROMIUMPATH", localChromiumPath)
const browser = await chromium.launch({
executablePath:
process.env.NODE_ENV !== "development"
Expand Down
2 changes: 2 additions & 0 deletions apps/backend/src/lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export async function getUserId(c: Context) {
= process.env.NODE_ENV !== "production"
? "authjs.session-token"
: "__Secure-authjs.session-token"

const cookieValue = getCookie(c, cookieName)!

debug("Parsing cookies", { cookieName, cookieValue })

const session = await getSession(cookieValue)
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/routes/feed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { feedQueue } from "../../plugins/queue.js"

const api = new Hono()

api.get("/", async (c) => {
api.get("/", (c) => {
try {
const queueList = feedQueue.getQueue()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
const imageUrl = $derived.by(() => {
if (bookmark.image) {
return `${PUBLIC_WORKER_URL}/img/s_260x144/${bookmark.image}`
return `${PUBLIC_WORKER_URL}/img/s_260x144,pos_top/${bookmark.image}`
} else {
return `${PUBLIC_WORKER_URL}/img/_/https://picsum.photos/seed/${btoa(bookmark.url).substring(0, 16)}/256/144.webp`
}
Expand Down
5 changes: 1 addition & 4 deletions apps/web/src/routes/api/v1/bookmarks/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,16 @@ export const POST: RequestHandler = async (event) => {
skipDuplicates: true,
})

console.log("BACKEND.HEADERS", event.request.headers)
// Add bookmark to queue for fetching screenshot
if (PUBLIC_WORKER_URL) {
const res = await event.fetch(`${PUBLIC_WORKER_URL}/v1/bookmark`, {
await event.fetch(`${PUBLIC_WORKER_URL}/v1/bookmark`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"cookie": event.request.headers.get("cookie") ?? ""
},
body: JSON.stringify({ data: bookmarkData.filter((bookmark) => !bookmark.image) }),
})
const resText = await res.text()
console.log('POST TO BACKEND /BOOKMARKS.RESPONS', { res, resText })
}

return json({ data: upsertResponse, bookmarkData })
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/routes/settings/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ export const actions: Actions = {
return fail(400, { type: "error", message: "Feed URL Required" })
}

const feedRes = await fetch(`${PUBLIC_WORKER_URL}/v1/feed`, {
const feedRes = await event.fetch(`${PUBLIC_WORKER_URL}/v1/feed`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"cookie": event.request.headers.get("cookie") ?? ""
},
body: JSON.stringify({
feedUrl,
Expand Down

0 comments on commit 0a2e832

Please sign in to comment.