Closed shah closed 2 years ago
This is an example of how to create /sse
endpoint with Oak:
import { Application, Router } from "https://deno.land/x/oak/mod.ts";
const app = new Application();
const router = new Router();
router.get('/', ctx => {
ctx.response.body = `
<!DOCTYPE html>
<html>
<head>
<title>Server Send Events</title>
<meta charset="utf-8">
<script>
const sse = new EventSource('/server-sent-events');
sse.onerror = () => document.body.innerHTML = 'Connection Error';
sse.onmessage = ({ data }) => document.body.innerHTML = data;
</script>
</head>
<body></body>
</html>
`;
})
router.get("/server-sent-events", (ctx) => {
const target = ctx.sendEvents();
const sendDate = () => target.dispatchMessage(`${new Date()}`);
sendDate();
const interval = setInterval(sendDate, 1000);
});
app.use(router.routes());
await app.listen({ port: 8080 });
Everything useful in this ticket has been completed, the rest of the incomplete tasks are not going to be implemented.
Use a web sockets based live diagnostics page called "Console" to send access logs, error messages, etc. from the experimental (development) server. This will allow the CLI console to only have important status messages while all other logs are sent to the browser Console.
Phoenix Live View Dashboard inspired requirements
RF Console as a browser extension elaboration
Basically the Resource Factory Console could be a pane/plugin in Chrome / Edge Chromium developer tools for inspecting internals.
Turborepo has the "profiles" feature which they describe as "Profile in your browser: Generate build profiles and import them in Chrome or Edge to understand which tasks are taking the longest." We should do the same.
An interesting approach would be to not create a generic RF devtools extension but, instead, generate a custom devtools extension as an output of the site's build process. Basically, all diagnostics wrapped into an extension specific to that site?
For additional debugging assistance supply some devtool code snippets.