D
Deno

help

Dependency injection deno deploy

Ffro.profesional1/31/2024
Does anyone know a Decency Injection library or container that works on deno deploy?
DAHDeno AI Helper1/31/2024
I'm sorry, but the documentation does not provide a clear answer to your question about a Dependency Injection library or container that works on Deno Deploy. It might be best to explore Deno's third-party module registry or ask in the Deno community for recommendations. 🦕
ASAntonio Sampaio1/31/2024
what have you tried? i like the inversify lib and have used it on some deno projects (not deno deploy) and it just works
Ffro.profesional1/31/2024
It fails to deploy, using tsyringe
import "npm:reflect-metadata";
import { injectable, container } from "npm:tsyringe";

class Some {
constructor() { }

some() {
return "some"
}
}

@injectable()
class Foo {
constructor(private some: Some) { }
callSome() {
return this.some.some();
}
}

const foo = container.resolve(Foo);

Deno.serve(() => {
return new Response(foo.callSome())
})
import "npm:reflect-metadata";
import { injectable, container } from "npm:tsyringe";

class Some {
constructor() { }

some() {
return "some"
}
}

@injectable()
class Foo {
constructor(private some: Some) { }
callSome() {
return this.some.some();
}
}

const foo = container.resolve(Foo);

Deno.serve(() => {
return new Response(foo.callSome())
})
Error
Task deploy deployctl deploy --project=hard-clam-29 main.ts
Using config file '/Users/franciscoramos/Documents/clau/code/clau/test/deno.json'
No entrypoint provided with either the --entrypoint arg or a config file. I've guessed 'main.ts' for you.
ℹ Is this wrong? Please let us know in https://github.com/denoland/deployctl/issues/new
✔ Deploying to project hard-clam-29.
✔ Entrypoint: /Users/franciscoramos/Documents/clau/code/clau/test/main.ts
ℹ Uploading all files from the current dir (/Users/franciscoramos/Documents/clau/code/clau/test)
✔ Found 3 assets.
✔ Uploaded 1 new asset.
✖ Deployment failed.
error: The deployment failed: UNCAUGHT_EXCEPTION

Error: TypeInfo not known for "Foo"
at file:///node_modules/.deno/tsyringe@4.8.0/node_modules/tsyringe/dist/cjs/dependency-container.js:292:27
at InternalDependencyContainer.construct (file:///node_modules/.deno/tsyringe@4.8.0/node_modules/tsyringe/dist/cjs/dependency-container.js:297:11)
at InternalDependencyContainer.resolve (file:///node_modules/.deno/tsyringe@4.8.0/node_modules/tsyringe/dist/cjs/dependency-container.js:114:33)
at file:///src/main.ts:20:23
error: Uncaught (in promise) Error: Exited with code: 1
throw new Error(`Exited with code: ${code}`);
^
at CommandChild.pipedStdoutBuffer (https://deno.land/x/dax@0.37.1/src/command.ts:710:19)
at eventLoopTick (ext:core/01_core.js:63:7)
Task deploy deployctl deploy --project=hard-clam-29 main.ts
Using config file '/Users/franciscoramos/Documents/clau/code/clau/test/deno.json'
No entrypoint provided with either the --entrypoint arg or a config file. I've guessed 'main.ts' for you.
ℹ Is this wrong? Please let us know in https://github.com/denoland/deployctl/issues/new
✔ Deploying to project hard-clam-29.
✔ Entrypoint: /Users/franciscoramos/Documents/clau/code/clau/test/main.ts
ℹ Uploading all files from the current dir (/Users/franciscoramos/Documents/clau/code/clau/test)
✔ Found 3 assets.
✔ Uploaded 1 new asset.
✖ Deployment failed.
error: The deployment failed: UNCAUGHT_EXCEPTION

Error: TypeInfo not known for "Foo"
at file:///node_modules/.deno/tsyringe@4.8.0/node_modules/tsyringe/dist/cjs/dependency-container.js:292:27
at InternalDependencyContainer.construct (file:///node_modules/.deno/tsyringe@4.8.0/node_modules/tsyringe/dist/cjs/dependency-container.js:297:11)
at InternalDependencyContainer.resolve (file:///node_modules/.deno/tsyringe@4.8.0/node_modules/tsyringe/dist/cjs/dependency-container.js:114:33)
at file:///src/main.ts:20:23
error: Uncaught (in promise) Error: Exited with code: 1
throw new Error(`Exited with code: ${code}`);
^
at CommandChild.pipedStdoutBuffer (https://deno.land/x/dax@0.37.1/src/command.ts:710:19)
at eventLoopTick (ext:core/01_core.js:63:7)
ASAntonio Sampaio1/31/2024
have you configured experimentalDecorators and emitDecoratorMetadata?
Ffro.profesional1/31/2024
Yes, inside deno.json It works locally
LLeokuma1/31/2024
if it doesn't work locally in an older version of Deno (like 1.39), then the error in Deploy is probably because they haven't updated Deno to the latest version on Deploy yet. In that case you just have to wait
Ffro.profesional1/31/2024
As far as I know is been working for a while locally, but not on deno deploy

Looking for more? Join the community!

Recommended Posts
Fetch request from own server```js try { const response = await fetch('.../ping', { Service keep restartingTwo GitHub projects, prod and customer are created using Deno for data syncing. Both projects are hRun `nvm` using Deno.CommandHello, I am trying to run `nvm` from a Deno script using Deno.Command. ```ts new Deno.Command('nvmCreating custom GitHub Action using DenoHey, I am currently trying to develop my first own custom GitHub Action. I have some trouble settinghow to avoid deprecation warnings in compiled binaries```sh $ pkgx --version warning: Use of deprecated "Deno.stderr.rid" API. This API will be removed inDeno compile with "--no-terminal" don't workI'm trying to compile a very simple file named main.ts ```ts await Deno.writeTextFile('test.txt', 'Hdeno task start not runnning in Powershell.This is the link of the tutorial I am following https://github.com/googleanalytics/ga4-tutorials?tabDeployment ID not available after API deploymentHi - i'm calling the /deployments endpoint after creating a new project: ${API}/projects/${project.`Request` body reading functions: possible error types[This](https://docs.deno.com/runtime/manual/runtime/http_server_apis#inspecting-the-incoming-requestHow to call a JS function from Rust?Hi, I'd like to call a JS function from Rust but I can't seem to find an example that does so. I goView code in Subhosting projectHi there - i'm using the API to create a new project and deployment with Subhosting. Just wondering Stop deno deploy instanceHi everyone, I just deployed my first test deno project on deno deploy. Now I'm wondering how to stoHow can I flush a stream to a response?I'm trying to stream a response but it appears that data is only sent after either a newline is writHoping for a clean way to get an array of filenames in directoryTrying to do something like this: ```typescript const files = Deno.readDirSync(Deno.cwd()).map(x => Support for auto-accessorsI'm playing around with Decorators, it seems like with `"experimentalDecorators": false`, there's a Rust sdk register_actity_typeHey, I am using the core_sdk in rust. I registered an activity, which should be able to consume follIs there a feature allowing custom "Allow?" CLI inputs?For example, if you `deno run` some program that reads from the file system, you're prompted `Deno r"deno compile --no-terminal" is not workingI'm trying to compile a very simple file named main.ts ```ts await Deno.writeTextFile('test.txt', 'HUsing fresh inside an existing deno folderI have an existing deno project with deno.jsonc at the root and would like to add a web app as a subRemove Dependencies from `deno.lock` fileHello, Somewhere in the code, I did `import postgres from npm:postgres`. This import is the written