Created
December 31, 2020 08:20
-
-
Save thomascsd/19e1814f1b89c01588fa7f9f18540b20 to your computer and use it in GitHub Desktop.
routings-controller snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Create service with inject": { | |
"prefix": "csd-service", | |
"body": [ | |
"import { RestDbService } from './RestDbService';", | |
"import { Inject } from 'typedi';", | |
"import { ${1:Contact} } from '../../shared/models';", | |
"", | |
"@Inject()", | |
"export class ${1:Contact}Service {", | |
" constructor(private db: RestDbService) {}", | |
" async get${1:Contact}s(): Promise<${1:Contact}[]> {", | |
" }", | |
" async save${1:Contact}(${3:data}: ${1:Contact}) {", | |
" }", | |
"}" | |
], | |
"description": "Create service with inject" | |
}, | |
"Create controller with inject": { | |
"prefix": "csd-ctrl", | |
"body": [ | |
"import { JsonController, Get, Post, Body } from 'routing-controllers';", | |
"import { Inject } from 'typedi';", | |
"import { ${1:Contact} } from '../../shared/models';", | |
"", | |
"@Inject()", | |
"@JsonController()", | |
"export class ${1:Contact}Controller {", | |
" constructor() {}", | |
" @Get('${2:/list}')", | |
" get${1:Contact}s() {", | |
" }", | |
"", | |
" @Post('${3:/save}')", | |
" save${1:Contact}(@Body() ${4:Contact}: ${1:Contact}) {", | |
" }", | |
"}", | |
"" | |
], | |
"description": "Create controller with inject" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment