Skip to content

Commit

Permalink
fix: export injectAsync and AsyncFactoryProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkluijk committed Sep 17, 2024
1 parent b840820 commit 02d5fb0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dirkluijk/needle-di",
"version": "0.0.1",
"version": "0.0.2",
"description": "A simple TypeScript library for dependency injection",
"keywords": ["dependency injection", "di", "dependency", "injection", "typescript", "type-safe"],
"homepage": "https://github.com/dirkluijk/needle-di",
Expand Down
30 changes: 13 additions & 17 deletions src/examples.test.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
import { bootstrap, Container, inject, injectable } from './index.js';
import { describe, expect, it } from 'vitest';
import { bootstrap, Container, inject, injectable } from "./index.js";
import { describe, expect, it } from "vitest";

@injectable()
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
class FooService {
}
class FooService {}

@injectable()
class BarService {
constructor(
private fooService: FooService = inject(FooService),
) {
}
constructor(private fooService: FooService = inject(FooService)) {}
}

describe('Examples', () => {
it('Bootstrap', () => {
// to create the DI container:
const container = new Container();
const barService = container.get(BarService);
describe("Examples", () => {
it("Bootstrap", () => {
// to create the DI container:
const container = new Container();
const barService = container.get(BarService);

expect(barService).toBeInstanceOf(BarService);
expect(bootstrap(BarService)).toBeInstanceOf(BarService);
});
});
expect(barService).toBeInstanceOf(BarService);
expect(bootstrap(BarService)).toBeInstanceOf(BarService);
});
});
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { inject, Container, bootstrap } from "./container.js";
export { inject, Container, bootstrap, injectAsync } from "./container.js";
export { injectable } from "./decorators.js";
export type {
FactoryProvider,
Expand All @@ -7,6 +7,7 @@ export type {
ConstructorProvider,
ClassProvider,
ValueProvider,
AsyncFactoryProvider,
} from "./providers.js";
export { InjectionToken } from "./tokens.js";
export type { Token } from "./tokens.js";

0 comments on commit 02d5fb0

Please sign in to comment.