alex-009
alex-009
DDeno
Created by alex-009 on 9/25/2024 in #help
Can I "execute" javascript in deno?
Let's say there is a line like this
<script nonce="73fa3ef1f4ac4682af1cfcb8b3563a89">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5B5TH8ZJ');</script>
<script nonce="73fa3ef1f4ac4682af1cfcb8b3563a89">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5B5TH8ZJ');</script>
and I'm able to get the innerText (...) can I execute the javascript in deno?
4 replies
DDeno
Created by alex-009 on 9/25/2024 in #help
Is there a function which can print a structure in deno/typscript similar to print_r in php ?
I would like to know which attributes and structure members a struct have and asked my self if there is something similar in deno/typscript to php https://www.php.net/manual/en/function.print-r.php I use deno 2.0.0-rc.5. Here the code which I use. The questioned line is this console.log(anchorTag.) //<= How to dump anchorTag?
import { DOMParser } from "jsr:@b-fuze/deno-dom";
const baseURL = "https://deno.com";

const client = Deno.createHttpClient({
poolIdleTimeout: 60,
poolMaxIdlePerHost: 8,
http1: true,
http2: true,
});

const response = await fetch(baseURL, {
client: client,
headers: {
"User-Agent": "My-UA",
},
});

console.log(response.status); // e.g. 200
console.log(response.statusText); // e.g. "OK"
const text = await response.text();
const doc = new DOMParser().parseFromString(text, "text/html");
console.log(doc.head);

const anchorTags = doc.querySelectorAll("script");
for (const anchorTag of anchorTags) {
if (anchorTag.getAttribute("src") == null) {
console.log(anchorTag.) //<= How to dump anchorTag?
continue;
}
if (anchorTag.getAttribute("src")?.startsWith("/")) {
console.log(baseURL + anchorTag.getAttribute("src"));
} else {
console.log(anchorTag.getAttribute("src"));
}
}
import { DOMParser } from "jsr:@b-fuze/deno-dom";
const baseURL = "https://deno.com";

const client = Deno.createHttpClient({
poolIdleTimeout: 60,
poolMaxIdlePerHost: 8,
http1: true,
http2: true,
});

const response = await fetch(baseURL, {
client: client,
headers: {
"User-Agent": "My-UA",
},
});

console.log(response.status); // e.g. 200
console.log(response.statusText); // e.g. "OK"
const text = await response.text();
const doc = new DOMParser().parseFromString(text, "text/html");
console.log(doc.head);

const anchorTags = doc.querySelectorAll("script");
for (const anchorTag of anchorTags) {
if (anchorTag.getAttribute("src") == null) {
console.log(anchorTag.) //<= How to dump anchorTag?
continue;
}
if (anchorTag.getAttribute("src")?.startsWith("/")) {
console.log(baseURL + anchorTag.getAttribute("src"));
} else {
console.log(anchorTag.getAttribute("src"));
}
}
2 replies
DDeno
Created by alex-009 on 11/21/2023 in #help
web based cms
Is there any web based cms system like word press based on deno or fresh?
4 replies
DDeno
Created by alex-009 on 11/6/2023 in #help
Is there a split_to_array function like join_to_string
I need to split a string with some delimiter =[, and ask my self if there is something in deno which i can use for this. https://deno.land/std@0.205.0/collections/join_to_string.ts
3 replies
DDeno
Created by alex-009 on 11/3/2023 in #help
how to set remoteAddr from http header Forwarded for or X-Forwarded for
In some environments are the TCP Client IP not the real Client IP. What's the best way to set https://deno.land/api@v1.38.0?s=Deno.ServeHandlerInfo#prop_remoteAddr from HTTP Header or Proxy protocol https://github.com/haproxy/haproxy/blob/master/doc/proxy-protocol.txt ?
3 replies
DDeno
Created by alex-009 on 10/30/2023 in #help
Best way for application config in deno/ts?
Hi. I'm alex and quite new to deno/typescript. Thank you for the quite big documenation it is a quite good starting point 🥰 I have created a upload module for caddy server ( https://github.com/git001/caddyv2-upload/ ) and try to "port/migrate/redevelop" this in typescript. Sorry for the long first post, but I'm not sure if this is the right forum, if not please redirect me to the right one 🙂 . As you may have seen I have a test upload question already asked on gh ( https://github.com/denoland/deno/discussions/20983 ) which was answerd and I was able to make a upload via curl. Now to start a more useable programm I have some newbie questions an hope to get here some answers or pointers from which I can start to learn. What's the best way to configure a Application, something similar to https://github.com/git001/caddyv2-upload/blob/main/docker-files/opt/webroot/config/Caddyfile which puts the data into this struct https://github.com/git001/caddyv2-upload/blob/main/upload.go#L29-L51 . What I have learned from ( https://www.typescriptlang.org/docs/handbook/ ) is that typescript is a typed js so maybe there is such something similar like the struct in go. Is there a "best practice" document for Projects which have some frontend/backend code? What I have in mind is such a directory structure ├── backend ├── common │ └── validators ├── frontend ├── static ├── tests Thank you that you have read until this line. 🙇
10 replies