You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lib/src/cli/templates/unit.ts

37 lines
821 B

import {Template} from '../Template'
/**
* Template that generates a new application unit class in app/units.
*/
const templateUnit: Template = {
name: 'unit',
fileSuffix: '.ts',
description: 'Create a service unit that will start and stop with your application.',
baseAppPath: ['units'],
render(name: string) {
return `import {Singleton, Inject, Unit, Logging} from '@extollo/lib'
/**
* ${name} Unit
* ---------------------------------------
* Put some description here.
*/
@Singleton()
export class ${name} extends Unit {
@Inject()
protected readonly logging!: Logging
public async up() {
this.logging.info('${name} has started!')
}
public async down() {
this.logging.info('${name} has stopped!')
}
}
`
},
}
export { templateUnit }