sejori / peko Goto Github PK
View Code? Open in Web Editor NEWFeatherweight apps on the edge, built with Web Standards ๐ฃโก
Home Page: https://peko.deno.dev/
License: GNU General Public License v3.0
Featherweight apps on the edge, built with Web Standards ๐ฃโก
Home Page: https://peko.deno.dev/
License: GNU General Public License v3.0
Remove all references to the global Deno object everywhere in source code except tests.
This is so the library can be used in an engine-agnostic fashion.
The server created in the code below listens on http://0.0.0.0:7777
when it should listen on http://debug:7777
.
const server = new Server({ hostname: 'debug' });
The parameter passed to the constructor is properly set on the class instance.
https://github.com/sebringrose/peko/blob/ff9f475f9c3101e8b21848899082c94a624236f7/server.ts#L31-L34
https://github.com/sebringrose/peko/blob/ff9f475f9c3101e8b21848899082c94a624236f7/server.ts#L39
However, this.hostname
is not used when the stdServer
is created.
https://github.com/sebringrose/peko/blob/ff9f475f9c3101e8b21848899082c94a624236f7/server.ts#L72-L76
The Vue example fails with the following error:
Error: On-the-fly template compilation is not supported in the ESM build of @vue/server-renderer. All templates must be pre-compiled into render functions.
Pretty self-explantory. Should add comments to types etc in order to have these auto-generated.
As well as using the SSR handler for complete HTML page rendering it could also be used to serve chunks of HTML that can be loaded into a variety of web applications. Therefore it makes sense to restructure some of the code so that this usecase is more intuitive and we don't have to hack it into the existing system.
Renaming the "addPageRoute" function to "addHTMLRoute" and redefining the "PekoPageRouteData" type to be more general-purpose seem like the right course of action to me.
Is there a plan to support https://deno.com/deploy?
Once the arguments of the HTML templating function have been agreed to remain fixed (at least mostly). We could use .html files with Angular-like {{value}}
templating instead of describing html inside of a string in .js files.
The main benefit of this is that developers can have proper syntax highlighting of their HTML templates.
Extend addRoute functions to check supplied function bodies for security traps (e.g. header/script injection vulnerabilities)
This can be added as a route in dev env to broadcast file changes to client. The intention is that the client can then either simply refresh or reload the module that changed. However, the latter get's complicated when we consider that modules might be bundled before being sent to client so knowing which modules appear in a bundle to trigger a reload would be a challenge.
Expand Peko Route
type to include middleware function and rewrite serve
logic in mod.ts
to pass request through provided middleware before handler.
{
route: "/api/parrotFcn",
method: "POST",
middleware: (request: Request) => auth(request),
handler: async (request: Request) => await new Response(`Parrot sqwarks: ${JSON.stringify(request.body)}`)
}
auth()
would likely be coming from Helper library or is defined by developer.
The cacher()
middleware uses the same headers for both the preflight (OPTIONS
) and main (GET
) requests when the route
is the same.
I think adding ctx.request.method
to the key would fix the issue.
This may not be needed as some of the deno/std library may work in other JS/TS engines such as bun. Some testing needs to be done by first trying to run Peko in bun after #177 is completed.
The cascade order is broken when calling next without awaiting it. It's very hard ot figure out exactly what's going wrong here but I've narrowed it down to the calling of next without await in a middleware.
You can see the response from a middleware/handler is lost and the cascade continues beyond what it should.
Should be a simple fix with eta config or plugin.
If anyone has any thoughts on this issue they would be so appreciated. To reproduce simply run the default template with $ docker-compose up
and navigate to the about page. You should see this appear as an error in the browser console or in the Deno process logs in terminal. I've tried using many different version of Preact and they all seem to have this issue.
Potential fix would be to try and swap out the Deno bundler for a custom bundler like Bundler or Denopack.
Related to: preactjs/preact#2690
Watch provided SSR module and it's local dependencies for changes then omit server-side event that triggers client to refresh/reload html.
Clients will need to utilise some JavaScript to subscribe to the Hot-Reload event. Simple and effective implementation would be to dynamically reimport modules and rerun hydration script. This can be made into an example.
now that params can be passed into render function caching on route string alone won't do as same route could return different content based on params from middleware
I believe it makes sense to include a lightweight datastore/database wrapper in Peko. By default data would be stored in-memory but database-service connection functions can be provided to change this.
It would also be cool to make data updates trigger ServerEvents so that new data could be emitted to client apps in real-time applications.
When starting a server with a separate router module it makes sense to use server.addRoutes(router.routes)
but this means subsequent additions to the router's routes won't be seen by the server. Using server.routes = router.routes
is a workaround but that ties all server routes to the router routes and will undo any previous server.addRoute()
calls.
i clone you example , but i get error
i use deno latest : Deno 1.24.3
d:\1. BELAJAR HTML\denoPRO\MAINAN\peko> deno run --allow-net --allow-env --allow-read --watch examples/preact/app.ts
and get error for Example preact folder
error message:
error: Uncaught (in promise) Error: The filename, directory name, or volume label syntax is incorrect. (os error 123), readdir '/D:/1.%20BELAJAR%20HTML/denoPRO/MAINAN/peko/examples/preact/src' for await (const dirEntry of Deno.readDir(path)) {
The onError
callback is documented but not actually present in the listen
function's parameters.
https://github.com/sebringrose/peko/blob/2fde0a154474dd909b05e90a9dff181f1370b575/server.ts#L63-L65
How do i set it?
Move preact example code ("example.js" file and "exampleSrc" dir) into a new "examples" directory so that future examples can be housed alongside. These files should be put within "examples/preact" and maybe renamed for clarity.
It would also be good to have a preact TypeScript example file as well as the existing JavaScript one to demonstrate using Peko and Preact with TypeScript.
It has been suggested that relying solely on prefetching source modules in browser will lead to worse performance than bundling. I can see this being the case in larger projects with lots of separate module code to pull into the browser.
It may be appropriate to add an optional bundling parameter to the SSR handler in Peko so that a page's source module can bundled and stored within a bundles directory (e.g. stdout). This would then be referenced in the client hydration script instead of the source module.
We need to do a bit of research on how worthwhile this is in terms of performance. Thoughts?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.