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

Avoid global namespace pollution #2

Open
fef1312 opened this issue Apr 1, 2020 · 1 comment
Open

Avoid global namespace pollution #2

fef1312 opened this issue Apr 1, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@fef1312
Copy link
Member

fef1312 commented Apr 1, 2020

Right now, anything that is required in multiple places is either stored in the global.videu object (for configuration data) or the module exporting it is just imported wherever needed (e.g. the repositories).

This scheme kind of works, but making mistakes is quite easy and it gets more and more difficult to maintain as the codebase grows. Especially stuff like modifying types from external packages (express in this case) is probably a time bomb. We should migrate to a more sophisticated, object-oriented design. This not only provides better ways of abstraction, it also enables us to use TypeScript's type system to its full extent (I'm thinking of stuff like the request body from express, which has no central validation system right now and has an any type).

@fef1312 fef1312 added the enhancement New feature or request label Apr 1, 2020
@fef1312 fef1312 self-assigned this Apr 1, 2020
@fef1312
Copy link
Member Author

fef1312 commented Apr 2, 2020

What I completely forgot to mention is testability, which requires stub classes to isolate individual components. And good luck writing stub classes when there are no classes to begin with.

fef1312 added a commit that referenced this issue Apr 2, 2020
This is part of a series on #2
fef1312 added a commit that referenced this issue Apr 4, 2020
Part of a series on #2.  I am more or less just trying out random stuff
right now and see how things work out.  Rationale: Your plan can't fail
if there is no plan to begin with.
fef1312 added a commit that referenced this issue Apr 4, 2020
Part of a series on #2.
The next step is to transform all routes to a subsystem as well, and
make that subsys depend on the mongo and http ones.  Let's see how
that is going to turn out...
fef1312 added a commit that referenced this issue Apr 4, 2020
Part of a series on #2.
I originally planned to use one general interface for both MongoDB and
cache data access classes, and just treat both the same in every way.
This, however, turned out to be quite complicated because the
repositories would not know when a document is _really_ created.
This new approach splits data sources into two categories: authoritative
and cache.  That way, a repository can always first insert new documents
into the authoritative (MongoDB) data source, and then populate the
cache.  Let's see how many refactors are left to get to version 1.0...
fef1312 added a commit that referenced this issue Apr 6, 2020
Part of a series on #2.
This version includes a kind of nasty hack to provide backwards
compatibility with the old JWT wrapper in src/util/jwt.ts (by far not as
nasty as the original JWT utils, though).  That will get removed once I
finally replace the routing stuff with an own subsystem, which turns
out to be more difficult than expected.
fef1312 added a commit that referenced this issue Apr 7, 2020
Part of a series on #2.
There are still some old things in place, but that's mainly because I am
too afraid to cause some random error by deleting them.  It will get
removed completely once all route handlers are rewritten.
fef1312 added a commit that referenced this issue Apr 9, 2020
Part of a series on #2.
This should be one of the last commits to fix this issue; that took me
long enough.  The next step is to get rid of all those legacy code
snippets to remain compatible with the old architecture, which will
probably take the rest of the day.  Really looking forward to that.
fef1312 added a commit that referenced this issue Apr 14, 2020
Part of a series on #2 (we're almost there!).
Maybe it's a good idea to just get rid of Express all together, I mean
I'm using only like 20% of its features and implementing an own routing
framework might even be faster.  But that of course is no priority right
now, maybe just before the 1.0 release in like, 5 years from now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant