Skip to content

Code Review #1

Open
Open
@basal-sean

Description

On the whole, the template looks good. There are a couple of things I would change to better make use of the existing codebase:

  • createNodeblocksGuestOrderApp.ts and routes.ts should not exist in this repo, but instead use the functions from the order service package. The concept of this adapter is to demonstrate a custom adapter, not to make a full service from scratch, so we should only be replacing just the 'adapter' part.
    • The GuestOrderAdapter type should also be removed, and the adapter class should implement OrderAdapter imported from the order service package. Any routes not supported at this time can be set to the following, similar to how the messaging service handles unsupported routes:
{
      handler: adapter.notFoundHandler,
      validators: {},
};

Other things I noticed

  • It might be clearer to place adapter.ts inside of the adapter/guest-orders folder
  • The validator unit tests should be placed inside of a validators folder, similar to handlers
  • There should be authentication and authorization validation on get/list orders that limits them to admin users only.
  • prepareGuestOrderResponse and similar utils would be better off on the dataService class, as that way organizationAPI and customFields can be read from the class properties, making these functions take much fewer arguments
  • The paginated list handler and data service method can be simplified a lot by using the backend sdk's methods for pagination. Take a look at the catalog service list endpoints (e.g. listAttributes) for an example. It should be able to reduce the amount of lines needed by 2/3.

Activity

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

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions