diff --git a/server/example/app.module.ts b/server/example/app.module.ts index 2523b5d..a1efefc 100644 --- a/server/example/app.module.ts +++ b/server/example/app.module.ts @@ -4,12 +4,10 @@ import { HttpModule } from '@server/http'; import { MiscModule, PostsModule } from './modules'; import { ServerPipe } from './pipes'; -import { ServicesModule } from './services'; @Module({ modules: [ HttpModule.create(ExpressAdapter), - ServicesModule, MiscModule, PostsModule, ], diff --git a/server/example/services/index.ts b/server/example/services/index.ts index 26b3015..9106b22 100644 --- a/server/example/services/index.ts +++ b/server/example/services/index.ts @@ -1,2 +1 @@ export { PostsService } from './posts.service'; -export { ServicesModule } from './services.module'; diff --git a/server/example/services/posts.service.ts b/server/example/services/posts.service.ts index 348c70f..41d381f 100644 --- a/server/example/services/posts.service.ts +++ b/server/example/services/posts.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@server'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class PostsService { getPosts() { return [ diff --git a/server/example/services/services.module.ts b/server/example/services/services.module.ts deleted file mode 100644 index 4ce55eb..0000000 --- a/server/example/services/services.module.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Module } from '@server'; - -import { PostsService } from './posts.service'; - -@Module({ - providers: [PostsService], -}) -export class ServicesModule { } diff --git a/server/package-lock.json b/server/package-lock.json index 4a29cb1..fbf7211 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -1,12 +1,12 @@ { "name": "@decorators/server", - "version": "1.0.0-beta.6", + "version": "1.0.0-beta.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@decorators/server", - "version": "1.0.0-beta.6", + "version": "1.0.0-beta.7", "license": "MIT", "devDependencies": { "@decorators/di": "../di", @@ -35,7 +35,7 @@ "typescript": "^5.0.3" }, "peerDependencies": { - "@decorators/di": "^3.0.1", + "@decorators/di": "^3.1.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", "reflect-metadata": "^0.1.13" diff --git a/server/package.json b/server/package.json index f6bd45b..f72e380 100644 --- a/server/package.json +++ b/server/package.json @@ -44,7 +44,7 @@ "license": "MIT", "name": "@decorators/server", "peerDependencies": { - "@decorators/di": "^3.0.1", + "@decorators/di": "^3.1.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", "reflect-metadata": "^0.1.13" @@ -69,5 +69,5 @@ ] } }, - "version": "1.0.0-beta.6" + "version": "1.0.0-beta.7" } diff --git a/server/src/core/application.ts b/server/src/core/application.ts index b74275e..0bad1d6 100644 --- a/server/src/core/application.ts +++ b/server/src/core/application.ts @@ -1,4 +1,4 @@ -import { InjectionToken } from '@decorators/di'; +import { InjectionToken, RootContainer } from '@decorators/di'; import { ContainerManager, ModuleResolver, ROOT_MODULE } from './helpers'; import { DEFAULT_PROVIDERS } from './providers'; @@ -9,6 +9,8 @@ export class Application { const containerManger = new ContainerManager(); const container = containerManger.create(Application); + container.setParent(RootContainer); + container.provide([ { provide: ContainerManager,