Installation
Create a new project
shell
pnpm initshell
npm initOr use an existing project
Install package
shell
pnpm add reflect-metadata @silvertree/coreshell
npm install reflect-metadata @silvertree/coreCreate basic structure with http server
ts
import 'reflect-metadata'
import {Container} from '@silvertree/core'
import {AppModule} from './app-module'
import {AppService} from './app-service'
async function start() {
const c = await Container.make().registerBatch([
AppModule,
])
// get the service
const svc = await c.provideAsync(AppService)
// call secrive's function
await svc.start()
}
start()ts
import {Module} from '@silvertree/core'
import {AppService} from './app-service'
export class AppModule extends Module {
async setup() {
this.bind.singletonClass(AppService)
.export({global: true})
}
}ts
export class AppService {
async index() {
console.log('Hello world!')
}
}INFO
Other examples can be found in the examples