-
-
Notifications
You must be signed in to change notification settings - Fork 286
Home
Romain Lenzotti edited this page Jun 25, 2020
·
46 revisions
- Fork the project + yarn install
- Create a new directory named
my-package
inpackages
directory. - Copy package.json from typeorm and change the
name
field by@tsed/my-package
change also the description, keywords, etc... Add contributors field with your name - Add your required dependencies in the new package and run yarn install on root
- Copy tsconfig.compile.json from typeorm
- Copy Readme and change usage and installation description
- Add src directory
- In src add
index.ts
and create a module file. Example: for typeorm, it'sTypeORMModule.ts
- Export all required class, decorators, service, etc... in the index.js
Note: Decorators can be generated with the cli. Just run the cli inside your packages/my-package.
import {PlatformApplication, OnDestroy, OnInit} from "@tsed/common";
import {Module, Inject, Constant} from "@tsed/di";
import {MyService} from "./services/MyService";
@Module({
imports: [MyService] // prebuild MyService. Use this field to build services before the module.
})
export class MyModule implements OnInit, OnDestroy {
@Inject()
app: PlatformApplication;
@Constant("myConfig", {})
settings: any;
@Inject()
myService: MyService;
async $onInit(): Promise<any> {
console.log("Init")
}
$onDestroy(): Promise<any> | void {
console.log("Destroy");
}
}