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

refactor: code organization #149

Merged
merged 21 commits into from
Oct 10, 2022
Merged

refactor: code organization #149

merged 21 commits into from
Oct 10, 2022

Conversation

varunsrin
Copy link
Member

@varunsrin varunsrin commented Oct 9, 2022

Motivation

The Hub has become more complicated and harder to reason about as the size of the codebase as grown. A high level design that we all agree on will make it much easier to read and write code as we are getting ready for the first release.

Change Summary

The PR is very large, touches many files and squeezed in all the changes I could over a single weekend to reduce merge conflicts during the workweek. A series of smaller followup changes will be made over the next week to bring the rest in line. Comments and suggestions are welcome for other things that should be updated, or patterns that people disagree with.

The major changes are:

  • Added new README.md that describes the proposed architecture
  • Reorganized code under the high level folders network, storage, types, utils and urls
  • Refactored rpc into a module, which is a pattern we should replicate over the codebase to keep files small
  • Moved non-unit tests files and helpers into test folder
  • Added documentation to hubs.ts
  • Enforced stricter type checking rules to minimize type errors

Merge Checklist

  • The title of this PR adheres to the conventional commits standard
  • The PR has been tagged with the appropriate change type label(s) (i.e. documentation, feature, bugfix, or chore)
  • Changes to the protocol specification have been merged

Additional Context

If this is a relatively large or complex change, provide more details here that will help reviewers

@codecov
Copy link

codecov bot commented Oct 9, 2022

Codecov Report

Base: 90.82% // Head: 91.06% // Increases project coverage by +0.24% 🎉

Coverage data is based on head (688cd9d) compared to base (b445407).
Patch coverage: 85.05% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #149      +/-   ##
==========================================
+ Coverage   90.82%   91.06%   +0.24%     
==========================================
  Files          40       41       +1     
  Lines        2180     2172       -8     
  Branches      370      372       +2     
==========================================
- Hits         1980     1978       -2     
+ Misses        188      183       -5     
+ Partials       12       11       -1     
Impacted Files Coverage Δ
src/network/p2p/node.ts 87.91% <ø> (ø)
src/network/p2p/protocol.ts 93.75% <ø> (ø)
src/network/sync/syncId.ts 100.00% <ø> (ø)
src/storage/db/cast.ts 90.21% <ø> (ø)
src/storage/db/follow.ts 89.87% <ø> (ø)
src/storage/db/jestUtils.ts 100.00% <ø> (ø)
src/storage/db/message.ts 95.34% <ø> (ø)
src/storage/db/reaction.ts 89.87% <ø> (ø)
src/storage/db/rocksdb.ts 97.33% <ø> (ø)
src/storage/db/signer.ts 92.68% <ø> (ø)
... and 27 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@varunsrin varunsrin added the t-chore Miscellaneous improvements label Oct 10, 2022
@varunsrin varunsrin changed the title refactor(WIP) refactor: code organization Oct 10, 2022
@@ -12,7 +12,7 @@ module.exports = {
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'no-restricted-imports': ['error', { patterns: ['.*'] }],
'no-restricted-imports': ['error', { patterns: ['"*/lib/*"'] }],
Copy link
Member Author

Choose a reason for hiding this comment

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

note to self: should be build not lib

README.md Outdated Show resolved Hide resolved
src/hub.ts Outdated Show resolved Hide resolved
src/hub.ts Outdated Show resolved Hide resolved
src/network/rpc/utils.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t-chore Miscellaneous improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants