deno
esm.sh
Our great sponsors
deno | esm.sh | |
---|---|---|
446 | 56 | |
92,681 | 2,770 | |
0.7% | 2.9% | |
9.9 | 9.8 | |
1 day ago | 10 days ago | |
Rust | Go | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
deno
-
I have created a small anti-depression script
Install Node.js (or Bun, or Deno, or whatever JS runtime you prefer) if it's not there
-
Unison Cloud
So as an end user it's kind of like https://deno.com/ where you buy into a runtime + comes prepacked with DBs (k/v stores), scheduling, and deploy stuff?
> by storing Unison code in a database, keyed by the hash of that code, we gain a perfect incremental compilation cache which is shared among all developers of a project. This is an absolutely WILD feature, but it's fantastic and hard to go back once you've experienced it. I am basically never waiting around for my code to compile - once code has been parsed and typechecked once, by anyone, it's not touched again until it's changed.
Interesting. Whats it like upgrading and managing dependencies in that code? I'd assume it gets more complex when it's not just the Union system but 3rd party plugins (stuff interacting with the OS or other libs).
-
Deno in 2023
~90MB+ at this stage and do now allow compression without erroring out. Deploying ala Golang is not feasible at that level but could well be down the line if this dev branch is picked up again!
The exe output grew from from ~50MB to plus ~90MB from 2021 to 2024: https://github.com/denoland/deno/discussions/9811 which mean Deno is worse than Node.js's pkg solution by a decent margin.
-
Mini site for recommending songs using Svelte & Deno
Behind the scenes is a simple Sveltekit-powered server function to fetch a Spotify client token then find a user's recommendation playlist and its track information. A Deno edge function to performs this data fetch and renders server-side Svelte.
-
Supercharge your app with user extensions using Deno JavaScript runtime
If your application is written in JavaScript, integrating it with JavaScript extensions is a no-brainer. However, Secutils.dev is entirely written in Rust. How would I even begin? Fortunately, I recently came across an excellent blog post series explaining how to implement your JavaScript runtime in a Rust application with Deno:
Protecting against memory-hungry scripts in Deno is more challenging. I won't go into details about how it works and instead direct you to the issue in the Deno repository with all the details. In short, you need to create a JavaScript runtime with a specific heap limit and add a callback that's invoked when the memory limits are approached. This gives you a chance to terminate the execution before Deno/V8 crashes the entire process.
- Oxlint – written in Rust – 50-100 Times Faster than ESLint
-
Deno Cron
I found the code for that here: https://github.com/denoland/deno/tree/v1.38.3/ext/cron
Thank you for the detailed feedback. Deno 1.38.4 was just released with a partial fix for the VSCode issue you mentioned. We're fixing the twisted issue too.
This is being worked on: https://github.com/denoland/deno/issues/21122. Should be available with the next Deno release.
esm.sh
-
Show HN: Comma Separated Values (CSV) to Unicode Separated Values (USV)
const extism = await import("https://esm.sh/@extism/extism");
-
JSR: The JavaScript Registry
Unpkg just serves the raw files, which may contain require() calls or import from other npm packages. That won’t work.
The closest service is https://esm.sh, but you can’t download from it.
Unpkg serves whatever is published to NPM, and if it's a library intended for the browser, that often includes minified versions ready for use in script tags, for example, https://unpkg.com/[email protected]/mithril.min.js. Sometimes the default export is CJS (which has require() calls), in which case, you can usually use the browse url that I mentioned to see if there's another export you can use.
https://esm.sh/ is definitely a good option too if you're OK with modules.
-
Deno Cron
* Change my NPM imports to something that would work with Deno. The most straightforward thing to do was just change `import "foo"` to `import "npm:foo"`, but this felt hacky so eventually I used https://esm.sh, which worked for some packages but not others.
-
Let's optimize dependency management with URL Imports
Easily serve libraries from local server/private VPS: You can try to serve and cache libraries by running esm.sh to improve loading times on your server side. Or to keep things simple, just upload a code to pastebin or similar services and directly use it here!
-
Building a Slack Bot for AI-Powered Conversations with Supabase
import { serve } from 'https://deno.land/[email protected]/http/server.ts'; import { WebClient } from 'https://deno.land/x/[email protected]/mod.js'; import { SupabaseClient } from 'https://esm.sh/@supabase/supabase-js@2'; const slack_bot_token = Deno.env.get("SLACK_TOKEN") ?? ""; const bot_client = new WebClient(slack_bot_token); const supabase_url = Deno.env.get("SUPABASE_URL") ?? ""; const service_role = Deno.env.get("SUPABASE_SERVICE_ROLE_KEY"); const supabase = new SupabaseClient(supabase_url, service_role); console.log(`Slack URL verification function up and running!`); serve(async (req) => { try { const req_body = await req.json(); console.log(JSON.stringify(req_body, null, 2)); const { token, challenge, type, event } = req_body; if (type == 'url_verification') { return new Response(JSON.stringify({ challenge }), { headers: { 'Content-Type': 'application/json' }, status: 200, }); } else if (event.type == 'app_mention') { const { user, text, channel, ts } = event; const url_path = text.toLowerCase() .includes('code') ? '/code' : '/general'; const { error } = await supabase.from('job_queue').insert({ http_verb: 'POST', payload: { user, text, channel, ts }, url_path: url_path }); if (error) { console.error(error); return new Response(JSON.stringify({ error: error.message }), { headers: { 'Content-Type': 'application/json' }, status: 400, }); } await post(channel, ts, `Taking a look and will get back to you shortly!`); return new Response('', { status: 200 }); } } catch (error) { return new Response(JSON.stringify({ error: error.message }), { headers: { 'Content-Type': 'application/json' }, status: 400, }); } }); async function post(channel: string, thread_ts: string, message: string): Promise { try { const result = await bot_client.chat.postMessage({ channel: channel, thread_ts: thread_ts, text: message, }); console.info(result); } catch (e) { console.error(`Error posting message: ${e}`); } }
-
What is Embedding? Generating Embedding using Supabase
import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; export const supabaseClient = await createClient( Deno.env.get("SUPABASE_URL") ?? "", Deno.env.get("SUPABASE_ANON_KEY") ?? "" );
-
Deno Fresh SVG Sprites: Optimized Icons
{ "lock": false, "tasks": { "start": "deno run -A --watch=static/,routes/ dev.ts", "update": "deno run -A -r https://fresh.deno.dev/update .", "minify": "deno run --allow-env=DENO_ENV --allow-read --allow-run --allow-write minify-svg-sprite.ts" }, "imports": { "@/": "./", "$fresh/": "https://deno.land/x/[email protected]/", "preact": "https://esm.sh/[email protected]", "preact/": "https://esm.sh/[email protected]/", "preact-render-to-string": "https://esm.sh/*[email protected]", "@preact/signals": "https://esm.sh/*@preact/[email protected]", "@preact/signals-core": "https://esm.sh/*@preact/[email protected]", "$std/": "https://deno.land/[email protected]/", "svgo": "https://esm.sh/[email protected]/" }, "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "preact" } }
-
Testing Supabase Edge Functions with Deno Test
// deno-test.ts // Import necessary libraries and modules import { assert, assertExists, assertEquals, } from "https://deno.land/[email protected]/testing/asserts.ts"; import { createClient, SupabaseClient, } from "https://esm.sh/@supabase/[email protected]"; import { delay } from 'https://deno.land/x/[email protected]/mod.ts'; // Setup the Supabase client configuration const supabaseUrl = Deno.env.get("SUPABASE_URL") ?? ""; const supabaseKey = Deno.env.get("SUPABASE_ANON_KEY") ?? ""; const options = { auth: { autoRefreshToken: false, persistSession: false, detectSessionInUrl: false } }; // Test the creation and functionality of the Supabase client const testClientCreation = async () => { var client: SupabaseClient = createClient(supabaseUrl, supabaseKey, options); // Check if the Supabase URL and key are provided if (!supabaseUrl) throw new Error('supabaseUrl is required.') if (!supabaseKey) throw new Error('supabaseKey is required.') // Test a simple query to the database const { data: table_data, error: table_error } = await client.from('my_table').select('*').limit(1); if (table_error) { throw new Error('Invalid Supabase client: ' + table_error.message); } assert(table_data, "Data should be returned from the query."); }; // Test the 'hello-world' function const testHelloWorld = async () => { var client: SupabaseClient = createClient(supabaseUrl, supabaseKey, options); // Invoke the 'hello-world' function with a parameter const { data: func_data, error: func_error } = await client.functions.invoke('hello-world', { body: { name: 'bar' } }); // Check for errors from the function invocation if (func_error) { throw new Error('Invalid response: ' + func_error.message); } // Log the response from the function console.log(JSON.stringify(func_data, null, 2)); // Assert that the function returned the expected result assertEquals(func_data.message, 'Hello bar!'); }; // Register and run the tests Deno.test("Client Creation Test", testClientCreation); Deno.test("Hello-world Function Test", testHelloWorld);
-
Secure Password Verification and Update with Supabase and PostgreSQL
import { serve } from "https://deno.land/[email protected]/http/server.ts"; import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; const corsHeaders = { "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Headers": "authorization, x-client-info, apikey, content-type", }; serve(async (req) => { // Create a Supabase client with the necessary credentials if (req.method === 'OPTIONS') { return new Response('ok', { headers: corsHeaders }) } // Create a Supabase client with the necessary credentials const supabaseClient = createClient( Deno.env.get("SUPABASE_URL") ?? "", Deno.env.get("SUPABASE_ANON_KEY") ?? "", { global: { headers: { Authorization: req.headers.get("Authorization")! } }, auth: { autoRefreshToken: false, persistSession: false, detectSessionInUrl: false } } ); console.log("Supabase client created"); // Fetch the logged-in user from Supabase const { data: { user }, error: userError } = await supabaseClient.auth .getUser(); console.log("User fetched", user); if (userError) { console.error("User error", userError); return new Response(JSON.stringify({ error: userError.message }), { headers: { ...corsHeaders, "Content-Type": "application/json" }, status: 400, }); } // Extract the old and new passwords from the request const { oldPassword, newPassword } = await req.json(); console.log("Received old and new passwords", oldPassword, newPassword); // Verify the old password using the `verify_user_password` function const { data: isValidOldPassword, error: passwordError } = await supabaseClient.rpc("verify_user_password", { password: oldPassword }); console.log("Old password verified", isValidOldPassword); if (passwordError || !isValidOldPassword) { console.error("Invalid old password", passwordError); return new Response(JSON.stringify({ error: "Invalid old password" }), { headers: { ...corsHeaders, "Content-Type": "application/json" }, status: 400, }); } try { // Fetch the user's profile data const { data: profiles, error: profileError } = await supabaseClient.from( "profiles", ).select("id, avatar_url"); console.log("Profile data fetched", profiles); if (profileError) throw profileError; const user_id = profiles[0].id; console.log("User id", user_id); // Update the user's password using the Supabase Admin API const supabaseAdmin = createClient( Deno.env.get("SUPABASE_URL") ?? "", Deno.env.get("SUPABASE_SERVICE_ROLE_KEY") ?? "", { auth: { autoRefreshToken: false, persistSession: false, detectSessionInUrl: false } } ); console.log("Admin client created"); // Return a success response to the client const { error: updateError } = await supabaseAdmin .auth.admin.updateUserById( user_id, { password: newPassword }, ); console.log("Password updated"); if (updateError) { console.error("Update error", updateError); return new Response(JSON.stringify({ error: updateError.message }), { status: 400, }); } } catch (error) { console.error("Caught error", error); return new Response(JSON.stringify({ error: error }), { headers: { ...corsHeaders, "Content-Type": "application/json" }, status: 400, }); } console.log("Password update successful"); // Return a success response to the client return new Response( JSON.stringify({ message: "Password updated successfully" }), { headers: { ...corsHeaders, "Content-Type": "application/json" }, status: 200, }, ); });
What are some alternatives?
ASP.NET Core - ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
typescript-language-server - TypeScript & JavaScript Language Server
pnpm - Fast, disk space efficient package manager
esbuild - An extremely fast bundler for the web
bun - Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
Koa - Expressive middleware for node.js using ES2017 async functions
import-maps - How to control the behavior of JavaScript imports
warp-reverse-proxy - Fully composable warp filter that can be used as a reverse proxy.
jsdelivr - A free, fast, and reliable Open Source CDN for npm, GitHub, Javascript, and ESM
zx - A tool for writing better scripts
nvim-lspconfig - Quickstart configs for Nvim LSP
swc - Rust-based platform for the Web