Skip to content

Commit 9f02ae9

Browse files
feat: change stub of controller and service
1 parent f1108f2 commit 9f02ae9

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

libs/stubs/modules/http/controllers/controller.stub

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class $$CLASS$$Controller extends BaseController {
1717
description: 'Get list $$PROPERTY$$'
1818
})
1919
async index(@Pagination() page: PaginationParams) {
20-
return await this.$$PROPERTY$$Service.list(page);
20+
return this.$$PROPERTY$$Service.list(page);
2121
}
2222

2323
@Get(':id')
@@ -30,7 +30,7 @@ export class $$CLASS$$Controller extends BaseController {
3030
description: 'Get detail of $$PROPERTY$$'
3131
})
3232
async show(@Id() id: string) {
33-
return await this.$$PROPERTY$$Service.findById(id);
33+
return this.$$PROPERTY$$Service.findById(id);
3434
}
3535

3636
@Post()
@@ -39,7 +39,7 @@ export class $$CLASS$$Controller extends BaseController {
3939
})
4040
@HttpCode(HttpStatus.CREATED)
4141
async create(@Body() dto: Create$$CLASS$$Dto) {
42-
return await this.$$PROPERTY$$Service.create(dto);
42+
return this.$$PROPERTY$$Service.create(dto);
4343
}
4444

4545
@Put(':id')
@@ -53,7 +53,7 @@ export class $$CLASS$$Controller extends BaseController {
5353
})
5454
@HttpCode(HttpStatus.NO_CONTENT)
5555
async update(@Body() dto: Create$$CLASS$$Dto, @Id() id: string) {
56-
return await this.$$PROPERTY$$Service.update(id, dto);
56+
return this.$$PROPERTY$$Service.update(id, dto);
5757
}
5858

5959
@Delete(':id')
@@ -67,6 +67,6 @@ export class $$CLASS$$Controller extends BaseController {
6767
})
6868
@HttpCode(HttpStatus.NO_CONTENT)
6969
async destroy(@Id() id: string) {
70-
return await this.$$PROPERTY$$Service.destroy(id);
70+
return this.$$PROPERTY$$Service.destroy(id);
7171
}
7272
}

libs/stubs/modules/services/service.stub

+11-14
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,25 @@ import { $$CLASS$$Repository } from '../repositories/$$FILENAME$$.repository';
44

55
@Injectable()
66
export class $$CLASS$$Service {
7-
public constructor(
8-
@InjectRepository($$CLASS$$Repository)
9-
private $$PROPERTY$$Repo: $$CLASS$$Repository
10-
) {}
7+
public constructor(private $$PROPERTY$$Repo: $$CLASS$$Repository) {}
118

12-
async findById(id: string) {
13-
return await this.$$PROPERTY$$Repo.findById(id);
9+
async findById(id: string): Promise<$$CLASS$$Entity> {
10+
return this.$$PROPERTY$$Repo.findById(id);
1411
}
1512

16-
async list(page) {
17-
return await this.$$PROPERTY$$Repo.pagination({}, page);
13+
async list(page): Promise<$$CLASS$$Entity[]> {
14+
return this.$$PROPERTY$$Repo.pagination({}, page);
1815
}
1916

20-
async create(data) {
21-
return await this.$$PROPERTY$$Repo.createOne(data);
17+
async create(data): Promise<$$CLASS$$Entity> {
18+
return this.$$PROPERTY$$Repo.createOne(data);
2219
}
2320

24-
async update(id, data) {
25-
return await this.$$PROPERTY$$Repo.update(id, data);
21+
async update(id, data): Promise<void> {
22+
await this.$$PROPERTY$$Repo.update(id, data);
2623
}
2724

28-
async destroy(id) {
29-
return await this.$$PROPERTY$$Repo.delete(id);
25+
async destroy(id): Promise<void> {
26+
await this.$$PROPERTY$$Repo.delete(id);
3027
}
3128
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hodfords/nestjs-command",
3-
"version": "10.0.0",
3+
"version": "10.0.1",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)