@vori/nest-schematics
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -34,3 +34,3 @@ <% if (crud && type === 'rest') { %>import { Get, Post, Body, Patch, Param, Delete, Req } from '@nestjs/common'; | ||
const <%= singular(camelize(name)) %> = await this.<%= lowercased(name) %>Service.create(request.user, create<%= singular(classify(name)) %>Dto); | ||
return <%= singular(classify(name)) %>Dto.from(<%= singular(camelize(name)) %>); | ||
return new <%= singular(classify(name)) %>Dto(<%= singular(camelize(name)) %>); | ||
} | ||
@@ -43,3 +43,3 @@ | ||
const <%= camelize(name) %> = await this.<%= lowercased(name) %>Service.findAll(request.user); | ||
return <%= camelize(name) %>.map(<%= singular(classify(name)) %>Dto.from); | ||
return <%= camelize(name) %>.map(<%= singular(camelize(name)) %> => new <%= singular(classify(name)) %>Dto(<%= singular(camelize(name)) %>)); | ||
} | ||
@@ -53,3 +53,3 @@ | ||
const <%= singular(camelize(name)) %> = await this.<%= lowercased(name) %>Service.findOne(request.user, params.id); | ||
return <%= singular(classify(name)) %>Dto.from(<%= singular(camelize(name)) %>); | ||
return new <%= singular(classify(name)) %>Dto(<%= singular(camelize(name)) %>); | ||
} | ||
@@ -64,3 +64,3 @@ | ||
const <%= singular(camelize(name)) %> = await this.<%= lowercased(name) %>Service.update(request.user, params.id, update<%= singular(classify(name)) %>Dto); | ||
return <%= singular(classify(name)) %>Dto.from(<%= singular(camelize(name)) %>); | ||
return new <%= singular(classify(name)) %>Dto(<%= singular(camelize(name)) %>); | ||
} | ||
@@ -67,0 +67,0 @@ |
@@ -97,3 +97,3 @@ import { INestApplication } from '@nestjs/common'; | ||
expect(response.body).toEqual( | ||
instanceToPlain(<%= singular(classify(name)) %>Dto.from(<%= singular(camelize(name)) %>)) | ||
instanceToPlain(new <%= singular(classify(name)) %>Dto(<%= singular(camelize(name)) %>)) | ||
); | ||
@@ -132,3 +132,3 @@ }); | ||
orderBy(<%= camelize(name) %>, 'createdAt', 'desc').map( | ||
<%= singular(classify(name)) %>Dto.from | ||
<%= singular(camelize(name)) %> => new <%= singular(classify(name)) %>Dto(<%= singular(camelize(name)) %>) | ||
) | ||
@@ -165,3 +165,3 @@ ); | ||
expect(response.body).toEqual( | ||
instanceToPlain(<%= singular(classify(name)) %>Dto.from(<%= singular(camelize(name)) %>)) | ||
instanceToPlain(new <%= singular(classify(name)) %>Dto(<%= singular(camelize(name)) %>)) | ||
); | ||
@@ -218,3 +218,3 @@ }); | ||
instanceToPlain( | ||
<%= singular(classify(name)) %>Dto.from(reloaded<%= singular(classify(name)) %>) | ||
new <%= singular(classify(name)) %>Dto(reloaded<%= singular(classify(name)) %>) | ||
) | ||
@@ -221,0 +221,0 @@ ); |
import { faker } from '@faker-js/faker'; | ||
import { instanceToPlain } from 'class-transformer'; | ||
@@ -13,3 +14,3 @@ import { getDataSource } from '@vori/providers/database'; | ||
describe('from', () => { | ||
describe('constructor', () => { | ||
it('converts an entity to a DTO', () => { | ||
@@ -19,3 +20,3 @@ const <%= singular(camelize(name)) %> = make<%= singular(classify(name)) %>({ | ||
}); | ||
const dto = <%= singular(classify(name)) %>Dto.from(<%= singular(camelize(name)) %>); | ||
const dto = instanceToPlain(new <%= singular(classify(name)) %>Dto(<%= singular(camelize(name)) %>)); | ||
@@ -22,0 +23,0 @@ expect(dto).toMatchObject({ |
<% if (isSwaggerInstalled) { %>import { PartialType } from '@nestjs/swagger';<% } else { %>import { PartialType } from '@nestjs/mapped-types';<% } %> | ||
import { BaseEntityDto } from '@vori/nest/libs/dto'; | ||
import { BaseEntityDto } from '@vori/nest/libs/dto/base-entity.dto'; | ||
import { <%= classify(singular(name)) %> } from '../entities/<%= singular(name) %>.entity'; | ||
export class <%= singular(classify(name)) %>Dto extends BaseEntityDto { | ||
public static from(<%= singular(camelize(name)) %>: <%= singular(classify(name)) %>): <%= singular(classify(name)) %>Dto { | ||
return { | ||
...BaseEntityDto.from(<%= singular(camelize(name)) %>), | ||
}; | ||
public constructor(<%= singular(camelize(name)) %>: <%= singular(classify(name)) %>) { | ||
super(<%= singular(camelize(name)) %>); | ||
} | ||
@@ -11,0 +9,0 @@ } |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@schematics)", | ||
@@ -10,0 +10,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
203793
0
5029