D
Deno

help

How to use private remote modules hosted on GitHub on Deno Deploy?

Nnickchen1202352/23/2024
According to Private Modules and Repositories, I can access a private GitHub repo using the DENO_AUTH_TOKENS environment variable. How do I achieve this on Deno Deploy? I've tried setting DENO_AUTH_TOKEN on my project's settings page but it suggests that DENO_ is a reserved prefix.
No description
DAHDeno AI Helper2/23/2024
To use private GitHub repositories as dependencies in Deno Deploy, you'll need to authenticate access to these private modules using the DENO_AUTH_TOKENS environment variable. However, since Deno Deploy reserves environment variables starting with DENO_, you cannot directly set DENO_AUTH_TOKENS in the Deno Deploy dashboard. Here's a workaround you can use: 1. Create an environment variable in the Deno Deploy dashboard with a different name, such as GH_AUTH_TOKENS. 2. In your code, before you import any private modules, set the DENO_AUTH_TOKENS environment variable using the value from GH_AUTH_TOKENS. You can do this by accessing the environment variables using Deno.env.get("GH_AUTH_TOKENS") and then setting DENO_AUTH_TOKENS accordingly. Here's a small code snippet to illustrate this (please note that this is general advice and not a direct code example from the documentation):
const ghAuthToken = Deno.env.get("GH_AUTH_TOKENS");
if (ghAuthToken) {
Deno.env.set("DENO_AUTH_TOKENS", ghAuthToken);
}

// Now you can import your private modules as usual
import { myPrivateDinoModule } from "https://raw.githubusercontent.com/user/repo/branch/mod.ts";
const ghAuthToken = Deno.env.get("GH_AUTH_TOKENS");
if (ghAuthToken) {
Deno.env.set("DENO_AUTH_TOKENS", ghAuthToken);
}

// Now you can import your private modules as usual
import { myPrivateDinoModule } from "https://raw.githubusercontent.com/user/repo/branch/mod.ts";
Make sure to replace the placeholders with your actual GitHub token, user, repository, branch, and module path. Remember, this is a general approach and you should ensure that your token is kept secure and not exposed in your code. 🦕
Nnickchen1202353/5/2024
No description
Nnickchen1202353/5/2024
I think it fails during caching when deploying? This is how I import my module in my code
import { load } from 'dotenv'

await load({ export: true })
const GH_AUTH_TOKEN = Deno.env.get('GH_AUTH_TOKEN')
if (GH_AUTH_TOKEN)
Deno.env.set('DENO_AUTH_TOKENS', GH_AUTH_TOKEN)

export {
MyClass1
} from 'https://raw.githubusercontent.com/path/to/module.ts'
import { load } from 'dotenv'

await load({ export: true })
const GH_AUTH_TOKEN = Deno.env.get('GH_AUTH_TOKEN')
if (GH_AUTH_TOKEN)
Deno.env.set('DENO_AUTH_TOKENS', GH_AUTH_TOKEN)

export {
MyClass1
} from 'https://raw.githubusercontent.com/path/to/module.ts'
Can confirm caching does not work if the environment variable is not set
$ deno cache --reload ./utils/module.ts
error: Module not found "https://raw.githubusercontent.com/path/to/module.ts".
at file:///home/me/my-project/utils/module.ts:23:8
$ deno cache --reload ./utils/module.ts
error: Module not found "https://raw.githubusercontent.com/path/to/module.ts".
at file:///home/me/my-project/utils/module.ts:23:8

Looking for more? Join the community!

Recommended Posts
Encryption using Deno KV and OAuth?I'm creating a note-taking app using most of Deno's tools. I was thinking about encrypting user noteDeno is not seeing a projectIt seems deno is not seeing a project i am using. Project link: https://github.com/Swifter1243/ReMa`arch` and `platform` are empty strings in `node:process`👋 hello! I'm trying to use a node project that uses `arch` and `platform` inside `node:process`, whNPM imports fail on JSON requireWhen importing modules via `npm:` protocol, the embedded esbuild will throw the following error if tuse-case: web component development in denoMy use-case is quite simple, really. But I have a hard time finding the tooling to work with it. - Starting project errorsI have error in url of DenoConditional callback with deno_kv_oauthHello I am using deno_kv_oauth for my application and am trying to do the following: I want users tClear deno kv dbHow can I clear out the database? using `list` requires the keys to be known, but I just want to clehow to break console.log maximum characters limithi, im using usual `deno run file.ts` command and realized that there is a limit to number characternpm import : class is not found but it is well declared in node_moduleI try to use Tatum SDK in deno (https://github.com/tatumio/tatum-js). I pick up the easiest code exaInteractive Jupyter notebookHas anyone figured out how to do interactivity in a Jupyter notebook with Deno kernel in VSCode? LiRun all pending ticks synchronouslyCurrently it seems like `run_event_loop` is the only way to run all the pending ops that are schedul