codemonument / deno_audio_logbook

A deno fresh server, with a telegram bot to receive audio messages and a website to show all messages of a user in a calendar
2 stars 0 forks source link

15 theme switcher with cookie #33

Closed bjesuiter closed 1 year ago

bjesuiter commented 1 year ago

closes #15 fixes and closes #32

bjesuiter commented 1 year ago

AFAIK both middleware's should be called , since they are chainable. More complicated is the typing for this context, especially bc fresh is not smart enough to figure out the types as we go and add things to this context, so we have to manually type this out every time.

But, I also don't like the integration of the theme extraction in every file, so I also prefer a top-level middleware.

Maybe we can do the following: Add a top-level middleware with typing including only the theme variable.

Then we define the user area context to extend the top level context and add the user field there together with the other fields of this context.

Only thing then: All Usersrea routes must import the UserareaContext and all outside files must import the ToplevelContext, to have the correct types.

bjesuiter commented 1 year ago

@Bloodiko I replaced all occurrences of getThemeOnServer with access to the context, either ToplevelContext or UserareaContext.

Anything under /userarea has the UserareaContext (includes the user) and anything above has the ToplevelContext.

I think, it's not the most elegant design, but the most practicable in the current state of the fresh framework. Please take a look again, whether you think it looks good.

bjesuiter commented 1 year ago

@Bloodiko Bump 😀

Request for 2nd Review on this repo after integrating a new middleware structure for the theme variable