Skip to content
Open
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
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ prog
let outPathModel = outPath;
if (o.modelDir) {
outPathModel += '/' + o.modelDir;
o.modelDir = _ensureTrailingSlash(o.modelClass);
o.modelDir = _ensureTrailingSlash(o.modelDir);
} else {
o.modelDir = '';
}
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Your custom auth guard class name and location can be defined with `--auth-guard
"authGuardClass": "PrincipalGuard",
"authGuardDir": "modules/auth/lib",
"modelBaseClass": "EntityBase",
"modelBaseDIr": "modules/auth/lib"
"modelBaseDir": "modules/auth/lib"
}
}

Expand Down
4 changes: 2 additions & 2 deletions templates/controller.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Controller, Request, Param, Body, Get, Post, Put, Delete, ParseUUIDPipe
<% if (repository) { %>import { <%=: name | capitalize %>Repository } from './<%= repositoryFileName %>';
<% } else if (crud) { %>import { Repository } from 'typeorm'; <% } -%>
<% } -%>
<% if (model || repository || crud) { %>import { <%= modelClass %> } from './<%= modelFileName %>';<% } %>
<% if (model || repository || crud) { %>import { <%= modelClass %> } from './<%= modelDir %><%= modelFileName %>';<% } %>
<% if (auth) { %>import { <%= authGuardClass %> } from '<%= authGuardDir %>';<% } %>

@Controller('/<%= name %>')
Expand Down Expand Up @@ -95,4 +95,4 @@ public async search(@Request() req): Promise<Array<<%= modelClass %>>> {
}
<% } -%>

}
}
5 changes: 3 additions & 2 deletions templates/model.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import { Entity<% if (modelProps) { %>, Column, PrimaryGeneratedColumn<% } %> }

@Entity('<%= modelClassLower %>')
export class <%= modelClass %> <% if (modelBaseClass) { %>extends <%= modelBaseClass %> <% } %>{

<% if (modelBaseClass) { %>
constructor() {
super();
}
<% } %>
<% if (modelProps) { -%>
<% Object.keys(modelProps).forEach(function(prop) { %>
@Column()
<%= prop %>: <%= modelProps[prop] %>;
<% }) %>
<% } -%>
}
}
4 changes: 2 additions & 2 deletions templates/module.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TypeOrmModule } from '@nestjs/typeorm';
<% if (service) { %>import { <%=: name | capitalize %>Service } from './<%= serviceFileName %>';<% } %>
<% if (repository) { %>import { <%=: name | capitalize %>Repository } from './<%= repositoryFileName %>';
<% } else if (false && crud) { %>import { Repository } from 'typeorm'; <% } -%>
<% if (model || repository || crud) { %>import { <%= modelClass %> } from './<%= modelFileName %>';<% } %>
<% if (model || repository || crud) { %>import { <%= modelClass %> } from './<%= modelDir %><%= modelFileName %>';<% } %>

@Module({
<% if (model || repository || crud) { %>imports: [TypeOrmModule.forFeature([<%= modelClass %>])]<% if (controller || service || repository || crud) { %>,<% } %><% } %>
Expand All @@ -16,4 +16,4 @@ import { TypeOrmModule } from '@nestjs/typeorm';
<% } -%>
exports: []
})
export class <%=: name | capitalize %>Module {}
export class <%=: name | capitalize %>Module {}
4 changes: 2 additions & 2 deletions templates/service.ejs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable, UnauthorizedException, Request } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
<% if (repository) { %>import { <%=: name | capitalize %>Repository } from './<%= repositoryFileName %>';<% } %>
<% if (model || repository || crud) { %>import { <%= modelClass %> } from './<%= modelFileName %>';<% } %>
<% if (model || repository || crud) { %>import { <%= modelClass %> } from './<%= modelDir %><%= modelFileName %>';<% } %>

@Injectable()
export class <%=: name | capitalize %>Service {
Expand Down Expand Up @@ -47,4 +47,4 @@ export class <%=: name | capitalize %>Service {
<% } %>
}
<% } %>
}
}