fro.profesional
fro.profesionalā€¢9mo ago

Dependency injection deno deploy

Does anyone know a Decency Injection library or container that works on deno deploy?
7 Replies
Deno AI Helper
Deno AI Helperā€¢9mo ago
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. šŸ¦•
Antonio Sampaio
Antonio Sampaioā€¢9mo ago
what have you tried? i like the inversify lib and have used it on some deno projects (not deno deploy) and it just works
fro.profesional
fro.profesionalā€¢9mo ago
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)
Antonio Sampaio
Antonio Sampaioā€¢9mo ago
have you configured experimentalDecorators and emitDecoratorMetadata?
fro.profesional
fro.profesionalā€¢9mo ago
Yes, inside deno.json It works locally
Leokuma
Leokumaā€¢9mo ago
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
fro.profesional
fro.profesionalā€¢9mo ago
As far as I know is been working for a while locally, but not on deno deploy