You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is to track all plans this package has for the future.
Improved response components
Currently there is only one "response type" that is HtmlPage. It would be cool to have multiple other options:
JsonResponse - You can already think what it should do. It takes a JavaScript object and responses with the stringified version including correct headers.
constUsers: ElementGenerator=()=>{// do some calculationreturn<JsonResponsedata={result}/>;};constapi=express.Router();api.get("/users",createHandler(Users));
Static - The name says the thing. You specify the local path and it will respond with the correct data.
constLogo: ElementGenerator=()=>{// do some calculationreturn<Staticpath="./static/logo.png"/>;};app.get("/logo.png",createHandler(Logo));
Actual router creation
You should be able to make express routers using special components:
constNews: ElementGenerator=()=>{return<div></div>;};constRoutes: ElementGenerator=()=>{return<Router><Routepath="/">
For static content use children of route.
<imgsrc="logo.png"/></Route><Routepath="/logo.png"><Staticpath="./static/logo.png"/></Route><Routepath="/news"content={News}/></Router>;// and much more};app.use(createRouter(Routes));
Better request handling function
When using a HtmlPage with a response status without declaring a component it won't work. Look at this example:
app.all("*",(req,res)=>{// won't workres.send(render(<HtmlPagestatus={404}>
ERROR<br/>
This page doesn't exist.
</HtmlPage>));});
Instead there should be a handle function returned by the create function used like this:
app.all("*",(req,res)=>{// will workhandle(req,res,<HtmlPagestatus={404}>
ERROR<br/>
This page doesn't exist.
</HtmlPage>);});
IMPORTANT: HTML entities
Currently, when you set an attribute to a string that contains a quote, it will just output it like that and the HTML will be incorrect.
This issue is to track all plans this package has for the future.
Improved response components
Currently there is only one "response type" that is
HtmlPage
. It would be cool to have multiple other options:JsonResponse
- You can already think what it should do. It takes a JavaScript object and responses with the stringified version including correct headers.Static
- The name says the thing. You specify the local path and it will respond with the correct data.Actual router creation
You should be able to make express routers using special components:
Better request handling function
When using a
HtmlPage
with a response status without declaring a component it won't work. Look at this example:Instead there should be a
handle
function returned by thecreate
function used like this:IMPORTANT: HTML entities
Currently, when you set an attribute to a string that contains a quote, it will just output it like that and the HTML will be incorrect.
We should take care of that.
If you have any other idea just comment on this issue.
The text was updated successfully, but these errors were encountered: