Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for edge runtime #1209

Merged
merged 12 commits into from
Apr 5, 2024
Merged

feat: support for edge runtime #1209

merged 12 commits into from
Apr 5, 2024

Conversation

ymc9
Copy link
Member

@ymc9 ymc9 commented Apr 2, 2024

Summary by CodeRabbit

  • Refactor
    • Improved password hashing mechanism for enhanced security.
    • Enhanced logging capabilities for better debugging and monitoring.
    • Optimized object formatting for improved performance and readability.

Copy link
Contributor

coderabbitai bot commented Apr 2, 2024

Walkthrough

Walkthrough

The recent updates involve enhancing the system's password handling, logging, and object formatting functionalities. Specifically, password hashing now utilizes a synchronous approach for improved consistency. Logging enhancements include replacing direct console warnings with a more structured Logger system, ensuring better traceability and control over log messages. Additionally, object formatting has shifted from a custom method to leveraging JSON.stringify, standardizing the output for easier readability and debugging.

Changes

Files Change Summary
.../src/enhancements/password.ts Replaced hash with hashSync from bcryptjs for synchronous password hashing.
.../src/enhancements/create-enhancement.ts
.../src/enhancements/delegate.ts
Added Logger import; replaced console.warn with Logger.warn for logging warnings.
Added conditional logging for Prisma queries.
.../src/enhancements/utils.ts Changed formatObject functionality to use JSON.stringify for object pretty printing.
.../src/enhancements/policy/handler.ts
.../src/enhancements/policy/policy-utils.ts
Updated logging condition to check shouldLogQuery property for logging.
Replaced formatObject with JSON.stringify for consistent object formatting.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

Note: Auto-reply has been disabled for this repository by the repository owner. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ef4d5e1 and 672e406.
Files ignored due to path filters (9)
  • packages/plugins/trpc/tests/projects/t3-trpc-v10/package.json is excluded by !**/*.json
  • packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/client/next.ts is excluded by !**/generated/**
  • packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/client/utils.ts is excluded by !**/generated/**
  • packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/helper.ts is excluded by !**/generated/**
  • packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/Post.router.ts is excluded by !**/generated/**
  • packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/User.router.ts is excluded by !**/generated/**
  • packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/index.ts is excluded by !**/generated/**
  • packages/runtime/package.json is excluded by !**/*.json
  • pnpm-lock.yaml is excluded by !pnpm-lock.yaml, !**/*.yaml
Files selected for processing (16)
  • packages/runtime/res/model-meta.d.ts (1 hunks)
  • packages/runtime/res/model-meta.js (1 hunks)
  • packages/runtime/src/enhancements/create-enhancement.ts (2 hunks)
  • packages/runtime/src/enhancements/logger.ts (1 hunks)
  • packages/runtime/src/enhancements/password.ts (2 hunks)
  • packages/schema/src/plugins/plugin-utils.ts (2 hunks)
  • packages/server/src/api/base.ts (1 hunks)
  • packages/server/src/shared.ts (2 hunks)
  • packages/server/src/types.ts (2 hunks)
  • packages/server/tests/adapter/express.test.ts (3 hunks)
  • packages/server/tests/adapter/fastify.test.ts (2 hunks)
  • packages/server/tests/adapter/next.test.ts (2 hunks)
  • packages/server/tests/adapter/sveltekit.test.ts (2 hunks)
  • tests/integration/tests/cli/generate.test.ts (4 hunks)
  • tests/integration/tests/enhancements/with-omit/with-omit.test.ts (1 hunks)
  • tests/integration/tests/enhancements/with-policy/options.test.ts (1 hunks)
Additional Context Used
Additional comments not posted (22)
packages/server/src/shared.ts (3)

1-17: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [2-20]

The updates to the loadAssets function, including the use of default values and error handling for Zod schemas, are well-implemented.


29-37: The implementation of getDefaultModelMeta with direct module requiring and clear error handling is appropriate.


26-49: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [43-51]

While gracefully handling the absence of Zod schemas by returning undefined, consider logging the error or providing a more informative message to the user in case of failure to load the schemas.

packages/server/src/types.ts (1)

36-44: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [39-57]

The updates to the AdapterBaseOptions interface, including clearer comments and the removal of the loadPath option, are well-considered and improve the interface's usability.

packages/server/src/api/base.ts (1)

62-62: The simplification in the APIHandlerBase constructor by directly calling getDefaultModelMeta() without unnecessary arguments improves code readability.

tests/integration/tests/enhancements/with-policy/options.test.ts (1)

19-19: The simplification of the test setup by removing the loadPath option from the enhance function call aligns well with the broader changes in the PR.

packages/runtime/src/enhancements/logger.ts (1)

16-24: The updates to the Logger class, including the logic to handle different runtime environments, are well-implemented and ensure compatibility across platforms.

packages/runtime/src/enhancements/password.ts (1)

56-56: The switch to hashSync for password hashing in the PasswordHandler class is a positive change, ensuring synchronous operations and simplifying control flow.

packages/schema/src/plugins/plugin-utils.ts (2)

31-34: Consider using fs-extra for operations like removing directories, as it provides a more powerful and user-friendly API than the native fs module. This can simplify the code and improve readability.


71-74: Creating empty index.js files in the specified subfolders is a good practice for maintaining the structure of the output directory. However, ensure that these files are indeed necessary for your project's functionality or build process.

tests/integration/tests/enhancements/with-omit/with-omit.test.ts (1)

86-86: Removing the loadPath parameter simplifies the enhance function call. Ensure that this change aligns with the updated project structure and functionalities, and that all necessary configurations are still correctly applied.

packages/runtime/src/enhancements/create-enhancement.ts (2)

7-7: The addition of the Logger import is a good practice for consistent logging across the application. Ensure that the Logger class is implemented with appropriate log levels and output destinations to suit the application's needs.


154-156: Replacing console.warn with Logger.warn enhances the logging mechanism by providing more control over log output. This change aligns with best practices for application logging.

tests/integration/tests/cli/generate.test.ts (1)

149-150: The new assertion to check for the presence of a specific module after generating files is a good practice. It ensures that the generation process completes successfully and the expected output is produced.

packages/server/tests/adapter/sveltekit.test.ts (2)

6-6: Adding the path import is necessary for file path operations, especially when dealing with dynamic paths. This is a good practice for ensuring portability and correctness of file paths across different operating systems.


85-91: The modifications in the custom load path test to include projectDir and update the SvelteKitHandler call with new properties like modelMeta and zodSchemas are crucial for ensuring the test reflects the updated project structure and functionalities.

packages/server/tests/adapter/fastify.test.ts (2)

7-7: The use of path for file path operations is a good practice, ensuring the correct handling of file paths across different environments.


118-125: The modifications to include projectDir in the loadSchema call and update the arguments passed to ZenStackFastifyPlugin are important for ensuring the tests accurately reflect the updated project structure and functionalities.

packages/server/tests/adapter/express.test.ts (2)

12-12: The addition of the path import is necessary for handling file paths, especially when dealing with dynamic paths in tests. This ensures compatibility across different operating systems.


91-102: The modifications in the custom load path test to include projectDir and update the ZenStackMiddleware parameters are crucial for ensuring the test reflects the updated project structure and functionalities.

packages/server/tests/adapter/next.test.ts (2)

6-6: The addition of the path import is a good practice for handling file paths, ensuring compatibility and correctness across different environments.


175-181: The modifications to include projectDir in the loadSchema call and update the arguments passed to makeTestClient are important for ensuring the tests accurately reflect the updated project structure and functionalities.

packages/runtime/res/model-meta.d.ts Outdated Show resolved Hide resolved
packages/runtime/res/model-meta.js Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 672e406 and 55c8df1.
Files selected for processing (1)
  • packages/runtime/res/model-meta.d.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/runtime/res/model-meta.d.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 55c8df1 and 905ece1.
Files selected for processing (1)
  • packages/runtime/src/enhancements/logger.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/runtime/src/enhancements/logger.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 905ece1 and ed8dcd3.
Files selected for processing (1)
  • packages/runtime/src/enhancements/password.ts (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/runtime/src/enhancements/password.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ed8dcd3 and 0aba697.
Files selected for processing (1)
  • packages/runtime/src/enhancements/password.ts (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/runtime/src/enhancements/password.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0aba697 and 046a57d.
Files selected for processing (2)
  • packages/runtime/src/enhancements/create-enhancement.ts (3 hunks)
  • packages/runtime/src/enhancements/utils.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/runtime/src/enhancements/create-enhancement.ts

packages/runtime/src/enhancements/utils.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 046a57d and e3cb83e.
Files selected for processing (3)
  • packages/runtime/src/enhancements/delegate.ts (1 hunks)
  • packages/runtime/src/enhancements/policy/handler.ts (1 hunks)
  • packages/runtime/src/enhancements/policy/policy-utils.ts (3 hunks)
Additional comments not posted (3)
packages/runtime/src/enhancements/delegate.ts (1)

660-664: Consider adding documentation or comments explaining the logPrismaQuery option.
This will help developers understand its purpose and how to use it effectively.

packages/runtime/src/enhancements/policy/handler.ts (2)

715-715: Ensure that the shouldLogQuery property is correctly implemented and used consistently throughout the class for logging conditions.


712-718: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-715]

Review the entire PolicyProxyHandler class for potential improvements in error handling, code duplication, performance considerations, and adherence to best practices. Given the complexity, ensure that the class is well-documented, especially for public methods and complex logic.

packages/runtime/src/enhancements/policy/policy-utils.ts Outdated Show resolved Hide resolved
packages/runtime/src/enhancements/policy/policy-utils.ts Outdated Show resolved Hide resolved
packages/runtime/src/enhancements/policy/policy-utils.ts Outdated Show resolved Hide resolved
@ymc9 ymc9 merged commit c3e2db1 into v2 Apr 5, 2024
7 checks passed
@ymc9 ymc9 deleted the feat/edge-runtime branch April 5, 2024 21:39
@ymc9
Copy link
Member Author

ymc9 commented Apr 5, 2024

Fixes #785

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e3cb83e and 0841d86.
Files ignored due to path filters (2)
  • packages/runtime/package.json is excluded by !**/*.json
  • pnpm-lock.yaml is excluded by !pnpm-lock.yaml, !**/*.yaml
Files selected for processing (4)
  • packages/runtime/src/enhancements/password.ts (3 hunks)
  • packages/runtime/src/enhancements/policy/policy-utils.ts (4 hunks)
  • packages/runtime/src/enhancements/utils.ts (1 hunks)
  • packages/schema/src/plugins/plugin-utils.ts (2 hunks)
Files skipped from review as they are similar to previous changes (4)
  • packages/runtime/src/enhancements/password.ts
  • packages/runtime/src/enhancements/policy/policy-utils.ts
  • packages/runtime/src/enhancements/utils.ts
  • packages/schema/src/plugins/plugin-utils.ts

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.

1 participant