Skip to content

Conversation

@mostafakamar2308
Copy link
Member

Quality Checklist

  • I took the time to compare my implementation with the design.
  • I ensured that the this pull request satisfies all the requirements in the associated task.
  • I performed a self-review.

Links

@mostafakamar2308 mostafakamar2308 self-assigned this Jun 24, 2025
@neuodev
Copy link
Member

neuodev commented Jun 24, 2025

Warnings
⚠️ No clickup task found in this pull request

Generated by 🚫 dangerJS against f548691

@neuodev
Copy link
Member

neuodev commented Jun 24, 2025

🚀 WEB
🚀 UI
🚀 LANDING
🚀 DASHBOARD

Copy link
Collaborator

@mmoehabb mmoehabb left a comment

Choose a reason for hiding this comment

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

You have really done a great job thinking of and designing this solution. Kudos to you 😄

| "notifications"
| "topics";

export const ApiRouteBaseRoute = "/api/v1";
Copy link
Collaborator

Choose a reason for hiding this comment

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

The naming here is quiet repetitive. We may call it ApiRouteMainBase.

Comment on lines +80 to +107
apiRoutes.generateUrl({
route: {
base: "auth",
},
type: "base",
}),
routes.auth
);

app.use(
apiRoutes.generateUrl({
route: {
base: "contactRequest",
},
type: "base",
}),
routes.contactRequest
);

app.use(
apiRoutes.generateUrl({
route: {
base: "user",
},
type: "base",
}),
routes.user(context)
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a pattern here:
For any string x:

app.use(
   apiRoutes.generateUrl(
      route: {
         base: x,
      },
      type: "base"
   )
)

So it can be re-written as follow:
For any string x:

app.use(getBaseOf(x), ...)

import { ApiRoutes } from "@litespace/utils/routes";

const router = Router();
const sampleRouts = ApiRoutes.sample.routes;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't it ApiRoutes.asset.routes?

Comment on lines +7 to +10
const availabilitySlotRoutes = ApiRoutes.availabilitySlot.routes;

router.get(availabilitySlotRoutes.find, availabilitySlot.find);
router.post(availabilitySlotRoutes.set, availabilitySlot.set);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's not be verbose... calling it just routes here should be enough. and maybe calling the other one handlers instead of availabilitySlot too.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's write this as a convention. WDYT?

Comment on lines +76 to +79
type ApiRoutesType = Record<
string,
{ base: ApiRouteBase; routes: Record<string, string> }
>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's call this ApiRoutesMap. WDYT?

Comment on lines +6 to +7
BASE extends ApiBase,
SUB extends keyof (typeof ApiRoutes)[BASE]["routes"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think TS convention involves writing generics all in capitals letters.

});
}

generateUrl<
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not a full URL... let call it generatePath, or generateRoutePath.

I love abbreviations like gen instead of generate 😄. However, that's not how we name things in this project.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I propose exporting all these types and constant in one scope, say ApiRoute. And then renaming each of them accordingly.

ApiRoutesType -> ApiRoutesMap -> ApiRoute.Map
ApiRouteBaseRoute -> ApiRoute.BaseRoute
ApiRoutes -> ApiRoute.Routes

| "/confirmation-code"
| "/report";

export const ApiRoutes: ApiRoutesType = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use Object.freeze.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants