Skip to content

Commit

Permalink
fix: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ndom91 committed May 18, 2024
1 parent 3d5708d commit d905485
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 29 deletions.
2 changes: 1 addition & 1 deletion apps/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import feed from "./routes/feed/index.js"
import root from "./routes/root.js"

const app = new Hono<{ Bindings: HttpBindings }>({ strict: false }).basePath(
"/api/v0",
"/worker/v1",
)
app.use(logger())
app.use(prettyJSON())
Expand Down
1 change: 1 addition & 0 deletions apps/backend/src/plugins/storage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Buffer } from "node:buffer"
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3"

interface UploadImageArgs {
Expand Down
16 changes: 1 addition & 15 deletions apps/backend/src/routes/bookmark/schema.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import { z } from "zod"
import { zValidator } from "@hono/zod-validator"

const MAX_FILE_SIZE = 5 * 1024 * 1024 // 5MB
const ACCEPTED_IMAGE_TYPES = [
"image/jpeg",
"image/jpg",
"image/png",
"image/webp",
]

const bookmarkImageSchema = z.object({
data: z.array(
z
Expand All @@ -18,13 +10,6 @@ const bookmarkImageSchema = z.object({
required_error: "URL is required.",
})
.url(),
// image: z
// .any()
// .optional()
// .refine((file) => file?.size <= MAX_FILE_SIZE, { message: `Max file size is 5MB.` })
// .refine((file) => ACCEPTED_IMAGE_TYPES.includes(file?.type), {
// message: ".jpg, .jpeg, .png and .webp files are accepted.",
// }),
})
.passthrough(),
),
Expand All @@ -45,6 +30,7 @@ export const bookmarkImageCookieValidator = zValidator(
"cookie",
bookmarkCookieSchema,
)

export const bookmarkImageBodyValidator = zValidator(
"json",
bookmarkImageSchema,
Expand Down
6 changes: 3 additions & 3 deletions apps/backend/src/routes/feed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ api.get("/", async (c) => {
const queueList = feedQueue.getQueue()

return c.json({ queueList })
} catch (e) {
return c.json({ error: e }, 500)
} catch (error) {
return c.json({ error }, 500)
}
})

Expand All @@ -38,7 +38,7 @@ api.post("/", feedBodySchema, async (c) => {
return c.text("ok")
} catch (error) {
console.error(error)
return c.json(error)
return c.json({ error }, 500)
}
})

Expand Down
14 changes: 6 additions & 8 deletions apps/backend/src/routes/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ import type { HttpBindings } from "@hono/node-server"

const api = new Hono<{ Bindings: HttpBindings }>()

api.get("/", (c) => {
return c.text("Hello Hono!")
})

api.get("/remote", (c) => {
return c.json({
remoteAddress: c.env.incoming.socket.remoteAddress,
if (process.env.NODE_ENV !== "production") {
api.get("/remote", (c) => {
return c.json({
remoteAddress: c.env.incoming.socket.remoteAddress,
})
})
})
}

export default api
2 changes: 1 addition & 1 deletion apps/web/.env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NODE_ENV=development

# Backend Container - External URL to API
WORKER_URL=http://app.company.com/api/v0
WORKER_URL=http://app.company.com/worker/v1

# Prisma - Default docker-compose.storage
DATABASE_URL=postgres://postgres:postgres@database:5432/briefkasten
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/routes/(dashboard)/bookmarks/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ export const actions: Actions = {
export const load: PageServerLoad = async (event) => {
event.depends("app:bookmarks")
const session = await event.locals?.auth()
console.log("bookmark.load.session", { session })

if (!session && event.url.pathname !== "/login") {
const fromUrl = event.url.pathname + event.url.search
Expand Down

0 comments on commit d905485

Please sign in to comment.