babakfp
babakfp
Explore posts from servers
DDeno
Created by babakfp on 6/8/2024 in #help
`deno run -A vite` doesn't work
Why do I need to use deno run -A npm:vite when I already have vite installed with deno add npm:vite? What is the point of deno add then?
3 replies
DDeno
Created by babakfp on 5/8/2024 in #help
How to delete all data of a `Deno.Kv` DB file?
Hi 👋 Is there a way to delete all content inside a db file in openKv? Doing this doesn't work:
const keys = kv.list({ prefix: [] })
for await (const entry of keys) {
await kv.delete(entry.key)
}
const keys = kv.list({ prefix: [] })
for await (const entry of keys) {
await kv.delete(entry.key)
}
After running that and kv.list({ prefix: [] }) the length of it would be 0 but there are like 300 lines of stuff inside the DB file.
4 replies
DDeno
Created by babakfp on 5/8/2024 in #help
How to prevent `deno add` from adding `^` to package version?
Hi 👋 Is there a one time option like PNPM? So I can set it once for all and not have to deal with it every time. I don't understand why every package manager adds that character. You may install a different version of a package without knowing it and introduce bugs into your project because some packages may have breaking changes in their minor version updates.
3 replies
DDeno
Created by babakfp on 4/12/2024 in #help
Looking for an alternative to x/deno_open
Hi 👋 I'm using the --unstable-hmr option with Deno and whenever I modify code and save, this library opens a new window! I'm looking for a library that checks if the basepath (http://localhost:3000) is already open, if it is open, it doesn't do anything, meaning if http://localhost:3000/something was open, it still won't do anything and only if http://localhost:3000 wasn't open it opens it in a new browser window. https://deno.land/x/[email protected]
4 replies
DDeno
Created by babakfp on 4/7/2024 in #help
Good Back-end Framework?
Hi 👋 I'm looking for a back-end framework to use in my Deno project. I have tested a few, like Oak, Abc, and Hono. This is what I'm looking for: - Good Documentation: - - Documentation that is written by people who know how to write good documentation. Just because you have written documentation, it doesn't mean you know how to write good documentation. - - A good documentation website. It looks good. Has Dark Mode (I know, I'm using Dark Reader). Has Seach functionality (which seems to be something rare for some reason!). - - Written in easy and simple language. - - Step-by-step guides. - - A lot of simple and advanced examples. - - Includes 100% coverage jsDoc/tsDoc comments. Comments that explain things, rather than pointing to a potato and saying it's a potato. - Batteries included. I don't want to google how to do some stupid simple thing, I want everything to be included and well-documented so I can build what I want to create rather than wasting time and losing my mind. - - When I submit a form, I want this framework to handle schema validation with something like Zod/Valibot. - - I need it to handle multipart/form-data form data. I want it to be validated. I also want it to return UTF-8 (just text lol) instead of other stupid things. - - I need to be able to send back form submission errors to the front-end. I got tired of writing. Just something good. Most of these things are very easy to do with SvelteKit. I don't want to use Tauri + SvelteKit because they add a lot of crap and I just want to keep things simple. But it seems like I can't find proper tools in the Deno ecosystem! I'm honestly going to switch to other tools if I don't get any results. I have it built already but it's missing simple things like form error validation, etc.
3 replies
DDeno
Created by babakfp on 4/5/2024 in #help
Deno Oak doesnt work when compiled to `.exe`
Hi 👋 I have this example from Deno site and when compile it to .exe and run it, I get the longs in the console of the .exe.
const port = 8080

const handler = (request: Request): Response => {
const body = `Your user-agent is:\n\n${
request.headers.get("user-agent") ?? "Unknown"
}`

return new Response(body, { status: 200 })
}

console.log(`HTTP server running. Access it at: http://localhost:8080/`)
Deno.serve({ port }, handler)
const port = 8080

const handler = (request: Request): Response => {
const body = `Your user-agent is:\n\n${
request.headers.get("user-agent") ?? "Unknown"
}`

return new Response(body, { status: 200 })
}

console.log(`HTTP server running. Access it at: http://localhost:8080/`)
Deno.serve({ port }, handler)
I have something similar with Oak:
import { Application, Router } from "oak"
import { operation } from "../utilities/operation.ts"
import { join } from "std/path/join.ts"

const PORT = 8000

const ROUTER = new Router()

ROUTER.get("/", (ctx) => {
ctx.response.type = "text/html"
ctx.response.body = Deno.readTextFileSync("./src/pages/index.html")
})

ROUTER.post("/", async (ctx) => {
const FORM_DATA = await ctx.request.body.formData()

try {
await operation({
"font-family": (FORM_DATA.get("font-family") ?? "") as string,
"css-content": (FORM_DATA.get("custom-css") ?? "") as string,
"restore-backup": FORM_DATA.has("restore-backup") as boolean,
})

ctx.response.redirect("/")
} catch (error: unknown) {
if (!(error instanceof Error)) throw error
ctx.response.body = error.message
}
})

const APP = new Application()

APP.use(ROUTER.routes())

APP.use(async (ctx, next) => {
try {
await ctx.send({
root: join(Deno.cwd(), "/src/static"),
})
} catch {
next()
}
})

console.log("Open the URL in your browser:")
console.log(`http://localhost:${PORT}`)

await APP.listen({ port: PORT })
import { Application, Router } from "oak"
import { operation } from "../utilities/operation.ts"
import { join } from "std/path/join.ts"

const PORT = 8000

const ROUTER = new Router()

ROUTER.get("/", (ctx) => {
ctx.response.type = "text/html"
ctx.response.body = Deno.readTextFileSync("./src/pages/index.html")
})

ROUTER.post("/", async (ctx) => {
const FORM_DATA = await ctx.request.body.formData()

try {
await operation({
"font-family": (FORM_DATA.get("font-family") ?? "") as string,
"css-content": (FORM_DATA.get("custom-css") ?? "") as string,
"restore-backup": FORM_DATA.has("restore-backup") as boolean,
})

ctx.response.redirect("/")
} catch (error: unknown) {
if (!(error instanceof Error)) throw error
ctx.response.body = error.message
}
})

const APP = new Application()

APP.use(ROUTER.routes())

APP.use(async (ctx, next) => {
try {
await ctx.send({
root: join(Deno.cwd(), "/src/static"),
})
} catch {
next()
}
})

console.log("Open the URL in your browser:")
console.log(`http://localhost:${PORT}`)

await APP.listen({ port: PORT })
The problem is that I don't get the longs in the console of the .exe when I run it. I don't get any errors, it's just a blank terminal. Does Oak does something behind the seen that breaks this? I can't use other frameworks if they don't have the same issue.
8 replies
DDeno
Created by babakfp on 4/5/2024 in #help
Incorrect 404 error when importing an explicit version of a package
Hi 👋 I get this error: "Implicitly using latest version (v1.5.2) for https://deno.land/x/cheetah/mod.ts" So, I change the import URL to this: https://deno.land/x/[email protected]/mod.ts And now I get a 404 error package not found! Another thing about this package is that different repos are set to different versions! And the repo for the latest version is archived. https://deno.land/x/[email protected] https://deno.land/x/[email protected]
7 replies
DDeno
Created by babakfp on 3/7/2024 in #help
Import path autocomplete doesn't work
Hi 👋 It behaves like it's just a string and not an import path. I have the latest version of Deno and Extension installed.
3 replies
DDeno
Created by babakfp on 2/10/2024 in #help
What does this library "assert" does?
3 replies
DDeno
Created by babakfp on 2/10/2024 in #help
What does this library "assert" does?
3 replies
DDeno
Created by babakfp on 2/10/2024 in #help
Looking for an alternative to deno_dom
Hi I'm looking for an alternative library to https://deno.land/x/[email protected]/deno-dom-wasm.ts Problems with deno_demo: https://stackoverflow.com/a/76630979/10799492
4 replies
DDeno
Created by babakfp on 11/28/2023 in #help
How Can I Delete Deno???
7 replies
DDeno
Created by babakfp on 11/25/2023 in #help
`deno.disablePaths` doesn't work
No description
2 replies
DDeno
Created by babakfp on 11/16/2023 in #help
Trying to benchmark `Deno.remove` but it fails
deno bench --allow-write bench.ts
Check file:///C:/Users/babak/OneDrive/Desktop/deno-benchmark-345654/bench.ts
cpu: Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
runtime: deno 1.36.4 (x86_64-pc-windows-msvc)

file:///C:/Users/babak/OneDrive/Desktop/deno-benchmark-345654/bench.ts
Deno.remove error: NotFound: The system cannot find the file specified. (os error 2): remove './assets'
await Deno.remove("./assets", { recursive: true })
^
at async Object.remove (ext:deno_fs/30_fs.js:201:3)
at async file:///C:/Users/babak/OneDrive/Desktop/deno-benchmark-345654/bench.ts:2:5
error: Bench failed
deno bench --allow-write bench.ts
Check file:///C:/Users/babak/OneDrive/Desktop/deno-benchmark-345654/bench.ts
cpu: Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
runtime: deno 1.36.4 (x86_64-pc-windows-msvc)

file:///C:/Users/babak/OneDrive/Desktop/deno-benchmark-345654/bench.ts
Deno.remove error: NotFound: The system cannot find the file specified. (os error 2): remove './assets'
await Deno.remove("./assets", { recursive: true })
^
at async Object.remove (ext:deno_fs/30_fs.js:201:3)
at async file:///C:/Users/babak/OneDrive/Desktop/deno-benchmark-345654/bench.ts:2:5
error: Bench failed
9 replies
DDeno
Created by babakfp on 11/16/2023 in #help
How can I use "Logging with colors" with `"npm:log-update"`
Hi https://examples.deno.land/color-logging I don't want to use Chalk because it's not properly typed.
4 replies