Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

Build out full server (not just functions) #20

Open
kaleidawave opened this issue Oct 21, 2020 · 0 comments
Open

Build out full server (not just functions) #20

kaleidawave opened this issue Oct 21, 2020 · 0 comments
Labels
enhancement New feature or request ideas wanted Needs imaginative ideas to make work server-side-rendering Server based render methods

Comments

@kaleidawave
Copy link
Owner

Currently Prism only outputs functions. And they can be imported so they can be used with a express or any other backend js framework to render body. e.g:

import {renderMainPage} from "../somePrismOutput/main-page.prism"

const app = express()

app.get("/", (req, res) => {
    res.send(renderMainPage(yourData))
});

This is great, you get the benefits of prism automating of synchronisation of client side render functions and server side render functions.

But Prism can do a little more here. It already knows what url routes to which pages. And its a compiler so its really good at generating code. So Prism could generate a whole express or oak application.

This could be implemented through a setting:

generateServer: "express" | "oak" | null

and the server runtime settings (port, hostname, ...) would be pulled in at runtime through process.env (or Deno.env.get(*)) or do defaults. It would compile in load callbacks of page components.

This would make it really simple to spin up a isomorphic project with Prism really quickly.

There is a bunch of things that would not be implemented. Things such as cookies, headers, separate server specific load functions and others. ands that's fine as this feature is not for building complex sites. It is just for getting a Prism app working on the server without having to manually build an express app to do so.

@kaleidawave kaleidawave added enhancement New feature or request server-side-rendering Server based render methods ideas wanted Needs imaginative ideas to make work labels Oct 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request ideas wanted Needs imaginative ideas to make work server-side-rendering Server based render methods
Projects
None yet
Development

No branches or pull requests

1 participant