[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
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

Simplify Fresh Server #1487

Closed
marvinhagemeister opened this issue Jul 19, 2023 · 3 comments
Closed

Simplify Fresh Server #1487

marvinhagemeister opened this issue Jul 19, 2023 · 3 comments
Milestone

Comments

@marvinhagemeister
Copy link
Collaborator
marvinhagemeister commented Jul 19, 2023

Right now Fresh relies mostly on a specific folder structure to function. It uses these to resolve routes, find islands etc. The question that came up in a call with @lucacasonato a while back is: Is it necessary to tie it to the file system? What would it take to create a Fresh app in one single file? Benefit would be that you could instantiate a Fresh app in our playground which currently doesn't support multiple files.

After a bit of discussion we came up with this idea:

const app = createApp({});

// Top level middleware
app.use(req => ....)

// Adding a route
app.use({
  route: "/foo/:id",
  async POST(req, ctx) => {},

  Component({ children }) {
    return <h1>Hello I'm a route</h1>
  },
});

Naming of these functions or methods are still to be discussed, but in general I think the direction is sound. The file system logic we have now would use this internally.

@marvinhagemeister
Copy link
Collaborator Author

To expand on this more: File system routing would work the same way as today, just the implementation details change under the hood.

This proposal also makes middlewares and handlers the same thing. Once we add layouts the distinction between middleware and handler becomes even less necessary.

The one thing we haven't figured out is how to get islands to work with that model. Maybe there is a clever way to work with virtual entry points.

@mcgear
Copy link
Contributor
mcgear commented Aug 2, 2023

I recently was wondering how it would be possible to register Islands outside the concept of the Islands folder. In our case, we have a shared Atomic library that implements both server and client components. Right now to get them working, we create simple passthrough wrappers in our islands folders (https://github.com/o-biotech/biotech-manager-web/blob/integration/islands/molecules/InteractiveResponsiveSet.tsx). it would be nice that if somewhere in our startup logic (main.ts?) we could register components from other frameworks as islands.

It feels like where this is going could unlock that feature as well.

@marvinhagemeister
Copy link
Collaborator Author

Closing as this has been achieved as part of Fresh 2

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

No branches or pull requests

2 participants