Skip to content

Conversation

@Nesta1223
Copy link

Why did you create this PR

What did you do

Demo

https://dev.cugetreg.com

Checklist

  • Deploy a demo
  • Check browsers compatibility
  • Wrote coverage tests

@changeset-bot
Copy link

changeset-bot bot commented Jan 18, 2026

⚠️ No Changeset found

Latest commit: 30d820b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

,sortOrder,limit
} = c.req.valid("query");
const program = Effect.gen(function* (){
const userCourses = yield* Effect.tryPromise({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use PrismaService from Effect instead of manually handle the error

const program = Effect.gen(function* (){
const userCourses = yield* Effect.tryPromise({
try: ()=>
prisma.cart.findMany({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use "select" to select only necessary fields to reduce network latency between database and backend service, speed up database response, reduce backend service memory usage.

Comment on lines +15 to +18
const {studyProgram,academicYear,semester,
q,genEdType,faculty,day ,timeStart, timeEnd, noPrereq, fitCardId , assessment,sortBy
,sortOrder,limit
} = c.req.valid("query");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is not formatted. So, I assume that other places too. Please add format on save to this repository.

} : undefined,
take: limit ? Number(limit) : undefined, // Useful if you also want to apply the limit
}),
catch: (error) => new Error(`Prisma Error: ${error}`),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not write the code as "catch-all-error". Effect.ts will be useless. Try to utilize what Effect.ts introduce (Recommended to deeply read Effect.ts, especially, Error Handling https://effect.website/docs/error-management/expected-errors/)

q,genEdType,faculty,day ,timeStart, timeEnd, noPrereq, fitCardId , assessment,sortBy
,sortOrder,limit
} = c.req.valid("query");
const program = Effect.gen(function* (){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not call prisma on Controller.

Controller should responsible only for

  • Parse request input (e.g. query, body, form data)
  • Validate request (e.g. validate input, validate header, authenticate / authorized request)
  • Response the request (as text format, json, format, etc.)

For business logic like calculating something, call external data source (e.g. database), it should be from service or repository.

Related comment #843 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Encourage to add module name as a prefix for each Schema. This will help other find schemas easier.

imagine, if you need to import something in review module. You just need to write "Review" and editor will suggest the rest like.

ReviewCreateBodyRequestSchema
ReviewUpdateParamsRequestSchema
ReviewUpdateBodyRequestSchema
// ...

Comment on lines +19 to +20
created_at: z.string().datetime,
updated_at:z.string().datetime,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
created_at: z.string().datetime,
updated_at:z.string().datetime,
created_at: z.iso.datetime(),
updated_at:z.iso.datetime(),

id: z.string(),
email: z.string().email,
name: z.string(),
google_id: z.string(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inconsistant naming. Please change to PascalCase

semester: z.string(),
rating: z.number().int().min(1).max(5), // Assumes a 1-5 star scale
content: z.string(),
status: z.enum(["approved", "pending", "rejected"]), // Using enum for specific statuses
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inconsistent enum, please change to UPPERCASE

Comment on lines 25 to +26
"@hono/zod-openapi": "^1.2.0",
"@hono/zod-validator": "^0.7.6",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This 2 library is no need for modern Hono app. Please consider remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants