Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions app/templates/nestjsMongoose/Dtos/__name__Dto.ts.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import * as Joi from 'joi'
// import { ApiProperty } from '@nestjs/swagger'
import { <%= namePascal %>Validator } from 'app/Validators/<%= namePascal %>Validator'

export class Create<%= namePascal %>Dto {
// Schema validation
static schema = Joi.object({
// Props in here
})
static type = 'createSchema'
static validator = <%= namePascal %>Validator

// @ApiProperty()
// <%= namePascal %> Props in here
}

export class Update<%= namePascal %>Dto {
// Schema validation
static schema = Joi.object({
// Props in here
})
static type = 'updateSchema'
static validator = <%= namePascal %>Validator

// @ApiProperty()
// <%= namePascal %> Props in here
Expand Down
12 changes: 9 additions & 3 deletions app/templates/nestjsMongoose/E2E/__name__/store.spec.ts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('\n[E2E] <%= namePascal %> 🧱', () => {
expect(body.data.name).toBe(payload.name)
})

// Implement all properties in app/Contracts/Dtos/<%= namePascal %>Dto.ts
// Implement all properties in app/Validators/<%= namePascal %>Validator.ts
// And create tests to validate if the schema validator are working well.

// it('should throw validation errors when trying to create a <%= nameCamel %> with validation errors', async () => {
Expand All @@ -38,9 +38,15 @@ describe('\n[E2E] <%= namePascal %> 🧱', () => {
//
// expect(body.status).toBe(status)
// expect(body.error.message).toStrictEqual({
// name: 'Validation Error',
// name: 'Unprocessable Entity Error',
// statusCode: status,
// validations: ['"name" is required'],
// message: [
// {
// field: 'name',
// message: 'required validation failed on name',
// validation: 'required',
// },
// ],
// })
// })
})
Expand Down
12 changes: 9 additions & 3 deletions app/templates/nestjsMongoose/E2E/__name__/update.spec.ts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('\n[E2E] <%= namePascal %> 🛠', () => {
})
})

// Implement all properties in app/Contracts/Dtos/<%= namePascal %>Dto.ts
// Implement all properties in app/Validators/<%= namePascal %>Validator.ts
// And create tests to validate if the schema validator are working well.

// it('should throw validation errors when trying to update a <%= nameCamel %> with validation errors', async () => {
Expand All @@ -65,9 +65,15 @@ describe('\n[E2E] <%= namePascal %> 🛠', () => {
//
// expect(body.status).toBe(status)
// expect(body.error.message).toStrictEqual({
// name: 'Validation Error',
// name: 'Unprocessable Entity Error',
// statusCode: status,
// validations: ['"name" must be a string'],
// message: [
// {
// field: 'name',
// message: 'string validation failed on name',
// validation: 'string',
// },
// ],
// })
// })
})
Expand Down
17 changes: 17 additions & 0 deletions app/templates/nestjsMongoose/__name__Validator.ts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Injectable } from '@nestjs/common'
import { Validator } from '@secjs/validator'

@Injectable()
export class <%= namePascal %>Validator extends Validator {
createSchema = () => {
return {
name: 'string|required',
}
}

updateSchema = () => {
return {
name: 'string',
}
}
}
14 changes: 5 additions & 9 deletions app/templates/nestjsPrismaOrm/Dtos/__name__Dto.ts.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import * as Joi from 'joi'
// import { ApiProperty } from '@nestjs/swagger'
import { <%= namePascal %>Validator } from 'app/Validators/<%= namePascal %>Validator'

export class Create<%= namePascal %>Dto {
// Schema validation
static schema = Joi.object({
// Props in here
})
static type = 'createSchema'
static validator = <%= namePascal %>Validator

// @ApiProperty()
// <%= namePascal %> Props in here
}

export class Update<%= namePascal %>Dto {
// Schema validation
static schema = Joi.object({
// Props in here
})
static type = 'updateSchema'
static validator = <%= namePascal %>Validator

// @ApiProperty()
// <%= namePascal %> Props in here
Expand Down
10 changes: 8 additions & 2 deletions app/templates/nestjsPrismaOrm/E2E/__name__/store.spec.ts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,15 @@ describe('\n[E2E] <%= namePascal %> 🧱', () => {
//
// expect(body.status).toBe(status)
// expect(body.error.message).toStrictEqual({
// name: 'Validation Error',
// name: 'Unprocessable Entity Error',
// statusCode: status,
// validations: ['"name" is required'],
// message: [
// {
// field: 'name',
// message: 'required validation failed on name',
// validation: 'required',
// },
// ],
// })
// })
})
Expand Down
12 changes: 9 additions & 3 deletions app/templates/nestjsPrismaOrm/E2E/__name__/update.spec.ts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('\n[E2E] <%= namePascal %> 🛠', () => {
})
})

// Implement all properties in app/Contracts/Dtos/<%= namePascal %>Dto.ts
// Implement all properties in app/Validators/<%= namePascal %>Validator.ts
// And create tests to validate if the schema validator are working well.

// it('should throw validation errors when trying to update a <%= nameCamel %> with validation errors', async () => {
Expand All @@ -65,9 +65,15 @@ describe('\n[E2E] <%= namePascal %> 🛠', () => {
//
// expect(body.status).toBe(status)
// expect(body.error.message).toStrictEqual({
// name: 'Validation Error',
// name: 'Unprocessable Entity Error',
// statusCode: status,
// validations: ['"name" must be a string'],
// message: [
// {
// field: 'name',
// message: 'string validation failed on name',
// validation: 'string',
// },
// ],
// })
// })
})
Expand Down
17 changes: 17 additions & 0 deletions app/templates/nestjsPrismaOrm/__name__Validator.ts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Injectable } from '@nestjs/common'
import { Validator } from '@secjs/validator'

@Injectable()
export class <%= namePascal %>Validator extends Validator {
createSchema = () => {
return {
name: 'string|required',
}
}

updateSchema = () => {
return {
name: 'string',
}
}
}
14 changes: 5 additions & 9 deletions app/templates/nestjsTypeOrm/Dtos/__name__Dto.ts.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import * as Joi from 'joi'
// import { ApiProperty } from '@nestjs/swagger'
import { <%= namePascal %>Validator } from 'app/Validators/<%= namePascal %>Validator'

export class Create<%= namePascal %>Dto {
// Schema validation
static schema = Joi.object({
// Props in here
})
static type = 'createSchema'
static validator = <%= namePascal %>Validator

// @ApiProperty()
// <%= namePascal %> Props in here
}

export class Update<%= namePascal %>Dto {
// Schema validation
static schema = Joi.object({
// Props in here
})
static type = 'updateSchema'
static validator = <%= namePascal %>Validator

// @ApiProperty()
// <%= namePascal %> Props in here
Expand Down
12 changes: 9 additions & 3 deletions app/templates/nestjsTypeOrm/E2E/__name__/store.spec.ts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('\n[E2E] <%= namePascal %> 🧱', () => {
expect(body.data.name).toBe(payload.name)
})

// Implement all properties in app/Contracts/Dtos/<%= namePascal %>Dto.ts
// Implement all properties in app/Validators/<%= namePascal %>Validator.ts
// And create tests to validate if the schema validator are working well.

// it('should throw validation errors when trying to create a <%= nameCamel %> with validation errors', async () => {
Expand All @@ -38,9 +38,15 @@ describe('\n[E2E] <%= namePascal %> 🧱', () => {
//
// expect(body.status).toBe(status)
// expect(body.error.message).toStrictEqual({
// name: 'Validation Error',
// name: 'Unprocessable Entity Error',
// statusCode: status,
// validations: ['"name" is required'],
// message: [
// {
// field: 'name',
// message: 'required validation failed on name',
// validation: 'required',
// },
// ],
// })
// })
})
Expand Down
12 changes: 9 additions & 3 deletions app/templates/nestjsTypeOrm/E2E/__name__/update.spec.ts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('\n[E2E] <%= namePascal %> 🛠', () => {
})
})

// Implement all properties in app/Contracts/Dtos/<%= namePascal %>Dto.ts
// Implement all properties in app/Validators/<%= namePascal %>Validator.ts
// And create tests to validate if the schema validator are working well.

// it('should throw validation errors when trying to update a <%= nameCamel %> with validation errors', async () => {
Expand All @@ -65,9 +65,15 @@ describe('\n[E2E] <%= namePascal %> 🛠', () => {
//
// expect(body.status).toBe(status)
// expect(body.error.message).toStrictEqual({
// name: 'Validation Error',
// name: 'Unprocessable Entity Error',
// statusCode: status,
// validations: ['"name" must be a string'],
// message: [
// {
// field: 'name',
// message: 'string validation failed on name',
// validation: 'string',
// },
// ],
// })
// })
})
Expand Down
17 changes: 17 additions & 0 deletions app/templates/nestjsTypeOrm/__name__Validator.ts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Injectable } from '@nestjs/common'
import { Validator } from '@secjs/validator'

@Injectable()
export class <%= namePascal %>Validator extends Validator {
createSchema = () => {
return {
name: 'string|required',
}
}

updateSchema = () => {
return {
name: 'string',
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generator-secjs",
"version": "1.2.3",
"version": "1.2.4",
"description": "🧬 Generator for any NodeJS Project or Framework",
"main": "app/index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions tests/nestjsMongoose.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('\n NestJS Mongoose 😸', () => {
'./Foo/BarFactory.ts',
'./Foo/Dtos/BarDto.ts',
'./Foo/BarResource.ts',
'./Foo/BarValidator.ts',
'./Foo/BarRepository.ts',
'./Foo/BarController.ts',
'./Foo/E2E/Bar/delete.spec.ts',
Expand Down
1 change: 1 addition & 0 deletions tests/nestjsPrismaOrm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('\n NestJS PrismaORM 😸', () => {
'./Foo/BarFactory.ts',
'./Foo/Dtos/BarDto.ts',
'./Foo/BarResource.ts',
'./Foo/BarValidator.ts',
'./Foo/BarController.ts',
'./Foo/BarRepository.ts',
'./Foo/E2E/Bar/delete.spec.ts',
Expand Down
1 change: 1 addition & 0 deletions tests/nestjsTypeOrm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('\n NestJS TypeORM 😸', () => {
'./Foo/BarFactory.ts',
'./Foo/Dtos/BarDto.ts',
'./Foo/BarResource.ts',
'./Foo/BarValidator.ts',
'./Foo/BarController.ts',
'./Foo/BarRepository.ts',
'./Foo/E2E/Bar/delete.spec.ts',
Expand Down