mostprodev
mostprodev
DDeno
Created by mostprodev on 9/2/2023 in #help
run code at the start of every hour
I would like the most performant code pls.
6 replies
DDeno
Created by mostprodev on 8/25/2023 in #help
Deno KV Type Error
When I run await (await kv.get<typeThing>(["example"])).id (the value is an object), it returns a type error because it is a maybe type thing.
16 replies
DDeno
Created by mostprodev on 8/17/2023 in #help
Deno Types
What is the Deno.ServeHandler type?
No overload matches this call.
Overload 1 of 3, '(handler: ServeHandler): Server', gave the following error.
Argument of type '(request: Request) => Promise<Response | undefined>' is not assignable to parameter of type 'ServeHandler'.
Type 'Promise<Response | undefined>' is not assignable to type 'Response | Promise<Response>'.
Type 'Promise<Response | undefined>' is not assignable to type 'Promise<Response>'.
Type 'Response | undefined' is not assignable to type 'Response'.
Type 'undefined' is not assignable to type 'Response'. Overload 2 of 3, '(options: ServeInit & (ServeOptions | ServeTlsOptions)): Server', gave the following error.
No overload matches this call.
Overload 1 of 3, '(handler: ServeHandler): Server', gave the following error.
Argument of type '(request: Request) => Promise<Response | undefined>' is not assignable to parameter of type 'ServeHandler'.
Type 'Promise<Response | undefined>' is not assignable to type 'Response | Promise<Response>'.
Type 'Promise<Response | undefined>' is not assignable to type 'Promise<Response>'.
Type 'Response | undefined' is not assignable to type 'Response'.
Type 'undefined' is not assignable to type 'Response'. Overload 2 of 3, '(options: ServeInit & (ServeOptions | ServeTlsOptions)): Server', gave the following error.
Does it not support async?
12 replies
DDeno
Created by mostprodev on 8/16/2023 in #help
Problems with Deno KV
import InputLoop from "https://deno.land/x/input@2.0.3/index.ts";

const kv = await Deno.openKv();
const input = new InputLoop();
let name;
let age;
let profession;
let id;

while (true) {
console.log("");
console.log("DENO KV DEMO");
console.log("> 0: Read Database");
console.log("> 1: Create/Edit User");
console.log("> 2: Delete User");
console.log("> 3: Exit");
const choice = await input.question("Input: ", false);
switch (choice) {
case "0":
for (const i in kv.list({ prefix: ["users"] })) {
console.log(i);
}
break;
case "1":
name = await input.question("Name: ", false);
if (!name) {
console.log("Invalid Input!");
break;
}
age = await input.question("Age: ", false);
profession = await input.question("Profession: ", false);
id = await input.question("Id: ", false);
await kv.set(["users", name], { age, profession, id });
break;
case "2":
name = await input.question("Name: ", false);
if (!name) {
console.log("Invalid Input!");
break;
}
kv.delete(["users", name]);
break;
case "3":
Deno.exit();
break;
default:
console.log("Invalid Input!");
}
}
import InputLoop from "https://deno.land/x/input@2.0.3/index.ts";

const kv = await Deno.openKv();
const input = new InputLoop();
let name;
let age;
let profession;
let id;

while (true) {
console.log("");
console.log("DENO KV DEMO");
console.log("> 0: Read Database");
console.log("> 1: Create/Edit User");
console.log("> 2: Delete User");
console.log("> 3: Exit");
const choice = await input.question("Input: ", false);
switch (choice) {
case "0":
for (const i in kv.list({ prefix: ["users"] })) {
console.log(i);
}
break;
case "1":
name = await input.question("Name: ", false);
if (!name) {
console.log("Invalid Input!");
break;
}
age = await input.question("Age: ", false);
profession = await input.question("Profession: ", false);
id = await input.question("Id: ", false);
await kv.set(["users", name], { age, profession, id });
break;
case "2":
name = await input.question("Name: ", false);
if (!name) {
console.log("Invalid Input!");
break;
}
kv.delete(["users", name]);
break;
case "3":
Deno.exit();
break;
default:
console.log("Invalid Input!");
}
}
This is just some code I made to test KV. However, it does seem to save anything.
6 replies