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/tidy server #1322

Merged
merged 17 commits into from
Jun 17, 2023
Merged

Conversation

alectrocute
Copy link
Contributor

@alectrocute alectrocute commented Jun 16, 2023

Hi Lemdevs!

I propose we:

  • Refactor our server/index.tsx to use a common Express.js pattern (handlers, middleware and utils)
  • Add Express types to handler/middleware export parameters
  • Make more human readable wherever possible
Screenshot 2023-06-16 at 10 47 26 AM

In future:

  • Rewrite/split out CatchAllHandler to be simpler if possible

Thanks so much!

out["x-real-ip"] = realIp as string;
}

const forwardedFor = headers["x-forwarded-for"];
Copy link
Contributor Author

@alectrocute alectrocute Jun 16, 2023

Choose a reason for hiding this comment

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

Possible bug here I found during this refactor. headers["x-forwarded-for"] can be either string or string[]. Just FYI. If you change the as to satisfies in this file, it becomes apparent.

Copy link
Member

Choose a reason for hiding this comment

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

Hrm... I know lemmy-js-client just takes in headers?: { [key: string]: string, so maybe any coercion isn't really necessary.

Copy link
Member

@dessalines dessalines left a comment

Choose a reason for hiding this comment

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

Thx for doing this, looks much cleaner.

@SleeplessOne1917 and I are getting fairly antsy to start yet another lemmy-ui in leptos-rs, with tailwind + DaisyUI , and that will avoid this entire inferno isomorphic mess, since it already has first-class isomorphic support. But that's for a later time.

out["x-real-ip"] = realIp as string;
}

const forwardedFor = headers["x-forwarded-for"];
Copy link
Member

Choose a reason for hiding this comment

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

Hrm... I know lemmy-js-client just takes in headers?: { [key: string]: string, so maybe any coercion isn't really necessary.

@alectrocute
Copy link
Contributor Author

@SleeplessOne1917 and I are getting fairly antsy to start yet another lemmy-ui in leptos-rs, with tailwind + DaisyUI , and that will avoid this entire inferno isomorphic mess, since it already has first-class isomorphic support. But that's for a later time.

I can't wait to get involved with that. That's an awesome stack.

@dessalines
Copy link
Member

I would 100% support people charging ahead on that without me. Right now I'm just a bit overwhelmed (800+ of the important notifications, many more unimportant), and am only responding to PRs and coding.

@SleeplessOne1917
Copy link
Member

I'll take a closer look at this later, but be aware that the changes in #1043 will likely affect this.

@alectrocute
Copy link
Contributor Author

alectrocute commented Jun 16, 2023

I'll take a closer look at this later, but be aware that the changes in #1043 will likely affect this.

That's totally fine, it'll be easy for me to resolve the conflicts. Thanks for the heads up!

@SleeplessOne1917
Copy link
Member

@dessalines Daisy UI may not even be necessary. We can define our own reusable classes using @apply. https://tailwindcss.com/docs/functions-and-directives#apply

@SleeplessOne1917
Copy link
Member

@alectrocute #1043 is merged now.

@alectrocute
Copy link
Contributor Author

@SleeplessOne1917 I think CI is stuck. :(

@dessalines
Copy link
Member

I moved our CI to a different server, hopefully that should be okay now.

@alectrocute
Copy link
Contributor Author

I fixed the merge conflicts introduced by #1043, this PR should be good to merge!

@alectrocute
Copy link
Contributor Author

I have no idea why CI is failing on the merged changes. I'm not seeing any type errors locally. Hmm.

@SleeplessOne1917
Copy link
Member

@alectrocute I'm not sure why CI isn't working unfortunately. It's complaining about code that doesn't exist anymore.

Copy link
Member

@SleeplessOne1917 SleeplessOne1917 left a comment

Choose a reason for hiding this comment

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

LGTM besides the mysterious CI error.

@SleeplessOne1917 SleeplessOne1917 merged commit b19df45 into LemmyNet:main Jun 17, 2023
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.

3 participants