Browse Source

test

pull/2/head
Neel Coffin 6 years ago
parent
commit
ff5d8388ce
  1. 5
      .circleci/config.yml
  2. 14
      .editorconfig
  3. 486
      .gitignore
  4. 6
      .prettierrc
  5. 1
      README.md
  6. 8
      _templates/generator/help/index.ejs
  7. 36
      _templates/generator/new/hello.ejs
  8. 36
      _templates/generator/with-prompt/hello.ejs
  9. 28
      _templates/generator/with-prompt/prompt.ejs
  10. 34
      _templates/module/empty-module/module.ts.ejs
  11. 12
      _templates/module/help/index.ejs
  12. 6
      _templates/module/with-crud/constants.ts.ejs
  13. 6
      _templates/module/with-crud/controller.spec.ts.ejs
  14. 192
      _templates/module/with-crud/controller.ts.ejs
  15. 30
      _templates/module/with-crud/dto.ts.ejs
  16. 32
      _templates/module/with-crud/entity.ts.ejs
  17. 48
      _templates/module/with-crud/module.ts.ejs
  18. 38
      _templates/module/with-crud/repository.ts.ejs
  19. 24
      _templates/module/with-crud/routing-body.ts.ejs
  20. 18
      _templates/module/with-crud/routing-head.ts.ejs
  21. 6
      _templates/module/with-crud/service.spec.ts.ejs
  22. 124
      _templates/module/with-crud/service.ts.ejs
  23. 36
      _templates/module/with-routing/module.ts.ejs
  24. 24
      _templates/module/with-routing/routing-body.ts.ejs
  25. 18
      _templates/module/with-routing/routing-head.ts.ejs
  26. 28
      exemple.env
  27. 18936
      yarn.lock

5
.circleci/config.yml

@ -5,7 +5,6 @@ jobs:
- image: cimg/node:14.10.1 - image: cimg/node:14.10.1
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
name: restore yarn package cache name: restore yarn package cache
key: yarn-packages-v2{{ checksum "yarn.lock" }} key: yarn-packages-v2{{ checksum "yarn.lock" }}
@ -30,7 +29,7 @@ jobs:
key: yarn-packages-v2{{ checksum "yarn.lock" }} key: yarn-packages-v2{{ checksum "yarn.lock" }}
paths: paths:
- ./node_modules - ./node_modules
unit-test:
test:
docker: docker:
- image: cimg/node:14.10.1 - image: cimg/node:14.10.1
steps: steps:
@ -49,7 +48,7 @@ workflows:
build_and_test: build_and_test:
jobs: jobs:
- build - build
- unit-test:
- test:
requires: requires:
- build - build
- lint: - lint:

14
.editorconfig

@ -1,7 +1,7 @@
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2

486
.gitignore

@ -1,243 +1,243 @@
# Created by https://www.gitignore.io/api/code,node,linux,windows,intellij,sublimetext
### Code ###
# Visual Studio Code - https://code.visualstudio.com/
.settings/
.vscode/
jsconfig.json
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/sonarlint
.idea/
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless
### SublimeText ###
# Cache files for Sublime Text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
# Workspace files are user-specific
*.sublime-workspace
# Project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using Sublime Text
# *.sublime-project
# SFTP configuration file
sftp-config.json
# Package control specific files
Package Control.last-run
Package Control.ca-list
Package Control.ca-bundle
Package Control.system-ca-bundle
Package Control.cache/
Package Control.ca-certs/
Package Control.merged-ca-bundle
Package Control.user-ca-bundle
oscrypto-ca-bundle.crt
bh_unicode_properties.cache
# Sublime-github package stores a github token in this file
# https://packagecontrol.io/packages/sublime-github
GitHub.sublime-settings
### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.gitignore.io/api/code,node,linux,windows,intellij,sublimetext
.env
dist/
doc-server
# Created by https://www.gitignore.io/api/code,node,linux,windows,intellij,sublimetext
### Code ###
# Visual Studio Code - https://code.visualstudio.com/
.settings/
.vscode/
jsconfig.json
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/sonarlint
.idea/
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless
### SublimeText ###
# Cache files for Sublime Text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
# Workspace files are user-specific
*.sublime-workspace
# Project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using Sublime Text
# *.sublime-project
# SFTP configuration file
sftp-config.json
# Package control specific files
Package Control.last-run
Package Control.ca-list
Package Control.ca-bundle
Package Control.system-ca-bundle
Package Control.cache/
Package Control.ca-certs/
Package Control.merged-ca-bundle
Package Control.user-ca-bundle
oscrypto-ca-bundle.crt
bh_unicode_properties.cache
# Sublime-github package stores a github token in this file
# https://packagecontrol.io/packages/sublime-github
GitHub.sublime-settings
### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.gitignore.io/api/code,node,linux,windows,intellij,sublimetext
.env
dist/
doc-server

6
.prettierrc

@ -1,4 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
{
"singleQuote": true,
"trailingComma": "all"
} }

1
README.md

@ -1,6 +1,5 @@
<h1 align="center">Welcome to TP on CI and CircleCI 👋</h1> <h1 align="center">Welcome to TP on CI and CircleCI 👋</h1>
You cand find the codelabs here on iCampus. You cand find the codelabs here on iCampus.
## Installation ## Installation

8
_templates/generator/help/index.ejs

@ -1,5 +1,5 @@
---
message: |
hygen {bold generator new} --name [NAME] --action [ACTION]
hygen {bold generator with-prompt} --name [NAME] --action [ACTION]
---
message: |
hygen {bold generator new} --name [NAME] --action [ACTION]
hygen {bold generator with-prompt} --name [NAME] --action [ACTION]
--- ---

36
_templates/generator/new/hello.ejs

@ -1,18 +1,18 @@
---
to: _templates/<%= name %>/<%= action || 'new' %>/hello.ejs
---
---
to: app/hello.js
---
const hello = ```
Hello!
This is your first hygen template.
Learn what it can do here:
https://github.com/jondot/hygen
```
console.log(hello)
---
to: _templates/<%= name %>/<%= action || 'new' %>/hello.ejs
---
---
to: app/hello.js
---
const hello = ```
Hello!
This is your first hygen template.
Learn what it can do here:
https://github.com/jondot/hygen
```
console.log(hello)

36
_templates/generator/with-prompt/hello.ejs

@ -1,18 +1,18 @@
---
to: _templates/<%= name %>/<%= action || 'new' %>/hello.ejs
---
---
to: app/hello.js
---
const hello = ```
Hello!
This is your first prompt based hygen template.
Learn what it can do here:
https://github.com/jondot/hygen
```
console.log(hello)
---
to: _templates/<%= name %>/<%= action || 'new' %>/hello.ejs
---
---
to: app/hello.js
---
const hello = ```
Hello!
This is your first prompt based hygen template.
Learn what it can do here:
https://github.com/jondot/hygen
```
console.log(hello)

28
_templates/generator/with-prompt/prompt.ejs

@ -1,14 +1,14 @@
---
to: _templates/<%= name %>/<%= action || 'new' %>/prompt.js
---
// see types of prompts:
// https://github.com/enquirer/enquirer/tree/master/examples
//
module.exports = [
{
type: 'input',
name: 'message',
message: "What's your message?"
}
]
---
to: _templates/<%= name %>/<%= action || 'new' %>/prompt.js
---
// see types of prompts:
// https://github.com/enquirer/enquirer/tree/master/examples
//
module.exports = [
{
type: 'input',
name: 'message',
message: "What's your message?"
}
]

34
_templates/module/empty-module/module.ts.ejs

@ -1,17 +1,17 @@
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.module.ts
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
%>import { Module } from '@nestjs/common';
@Module({
imports: [],
controllers: [],
providers: [],
exports: [],
})
export class <%=properName%>Module {}
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.module.ts
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
%>import { Module } from '@nestjs/common';
@Module({
imports: [],
controllers: [],
providers: [],
exports: [],
})
export class <%=properName%>Module {}

12
_templates/module/help/index.ejs

@ -1,6 +1,6 @@
---
message: |
hygen {bold module with-crud} --name [NAME]
hygen {bold module empty-module} --name [NAME]
hygen {bold module with-routing} --name [NAME]
---
---
message: |
hygen {bold module with-crud} --name [NAME]
hygen {bold module empty-module} --name [NAME]
hygen {bold module with-routing} --name [NAME]
---

6
_templates/module/with-crud/constants.ts.ejs

@ -1,3 +1,3 @@
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.constants.ts
---
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.constants.ts
---

6
_templates/module/with-crud/controller.spec.ts.ejs

@ -1,3 +1,3 @@
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.controller.spec.ts
---
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.controller.spec.ts
---

192
_templates/module/with-crud/controller.ts.ejs

@ -1,96 +1,96 @@
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.controller.ts
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
camelCase = h.changeCase.camel(name);
%>import {
Body,
Controller,
Delete,
Get,
NotFoundException,
Param,
ParseIntPipe,
Post,
Put,
Query,
} from '@nestjs/common';
import { <%= properName %> } from './<%= kebabName %>.entity';
import { <%= properName %>Service } from './<%= kebabName %>.service';
import {
ApiBearerAuth,
ApiImplicitParam,
ApiResponse,
ApiUseTags,
} from '@nestjs/swagger';
import { <%= properName %>Dto } from './<%= kebabName %>.dto';
@ApiUseTags('{{ sentenceCase name }}')
@Controller()
// @ApiBearerAuth()
export class <%= properName %>Controller {
constructor(private readonly <%= camelCase %>Service: <%= properName %>Service) {}
@Get()
@ApiResponse({
status: 200,
description: 'Get a list of all {{ sentenceCase name }}.',
type: <%= properName %>,
isArray: true,
})
getAll(): Promise<<%= properName %>[]> {
return this.<%= camelCase %>Service.getAll();
}
@Post()
@ApiResponse({
status: 201,
description: 'The {{ sentenceCase name }} has been created.',
type: <%= properName %>,
})
saveNew(@Body() <%= camelCase %>Dto: <%= properName %>Dto): Promise<<%= properName %>> {
return this.<%= camelCase %>Service.saveNew(<%= camelCase %>Dto);
}
@Get(':id')
@ApiResponse({
status: 200,
description: 'The {{ sentenceCase name }} with the matching id',
type: <%= properName %>,
})
@ApiResponse({ status: 404, description: 'Not found.' })
async findOne(
@Param('id', new ParseIntPipe()) id: number,
): Promise<<%= properName %>> {
return (await this.<%= camelCase %>Service.getOneById(id)).orElseThrow(
() => new NotFoundException(),
);
}
@Put(':id')
@ApiResponse({
status: 200,
description: 'The updated {{ sentenceCase name }} with the matching id',
type: <%= properName %>,
})
@ApiResponse({ status: 404, description: 'Not found.' })
async updateOne(
@Param('id', new ParseIntPipe()) id: number,
@Body() <%= camelCase %>Dto: <%= properName %>Dto,
): Promise<<%= properName %>> {
return this.<%= camelCase %>Service.update(id, <%= camelCase %>Dto);
}
@Delete(':id')
@ApiResponse({
status: 200,
description: 'The {{ sentenceCase name }} with the matching id was deleted',
})
@ApiResponse({ status: 404, description: 'Not found.' })
async deleteOne(@Param('id', new ParseIntPipe()) id: number): Promise<void> {
await this.<%= camelCase %>Service.deleteById(id);
}
}
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.controller.ts
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
camelCase = h.changeCase.camel(name);
%>import {
Body,
Controller,
Delete,
Get,
NotFoundException,
Param,
ParseIntPipe,
Post,
Put,
Query,
} from '@nestjs/common';
import { <%= properName %> } from './<%= kebabName %>.entity';
import { <%= properName %>Service } from './<%= kebabName %>.service';
import {
ApiBearerAuth,
ApiImplicitParam,
ApiResponse,
ApiUseTags,
} from '@nestjs/swagger';
import { <%= properName %>Dto } from './<%= kebabName %>.dto';
@ApiUseTags('{{ sentenceCase name }}')
@Controller()
// @ApiBearerAuth()
export class <%= properName %>Controller {
constructor(private readonly <%= camelCase %>Service: <%= properName %>Service) {}
@Get()
@ApiResponse({
status: 200,
description: 'Get a list of all {{ sentenceCase name }}.',
type: <%= properName %>,
isArray: true,
})
getAll(): Promise<<%= properName %>[]> {
return this.<%= camelCase %>Service.getAll();
}
@Post()
@ApiResponse({
status: 201,
description: 'The {{ sentenceCase name }} has been created.',
type: <%= properName %>,
})
saveNew(@Body() <%= camelCase %>Dto: <%= properName %>Dto): Promise<<%= properName %>> {
return this.<%= camelCase %>Service.saveNew(<%= camelCase %>Dto);
}
@Get(':id')
@ApiResponse({
status: 200,
description: 'The {{ sentenceCase name }} with the matching id',
type: <%= properName %>,
})
@ApiResponse({ status: 404, description: 'Not found.' })
async findOne(
@Param('id', new ParseIntPipe()) id: number,
): Promise<<%= properName %>> {
return (await this.<%= camelCase %>Service.getOneById(id)).orElseThrow(
() => new NotFoundException(),
);
}
@Put(':id')
@ApiResponse({
status: 200,
description: 'The updated {{ sentenceCase name }} with the matching id',
type: <%= properName %>,
})
@ApiResponse({ status: 404, description: 'Not found.' })
async updateOne(
@Param('id', new ParseIntPipe()) id: number,
@Body() <%= camelCase %>Dto: <%= properName %>Dto,
): Promise<<%= properName %>> {
return this.<%= camelCase %>Service.update(id, <%= camelCase %>Dto);
}
@Delete(':id')
@ApiResponse({
status: 200,
description: 'The {{ sentenceCase name }} with the matching id was deleted',
})
@ApiResponse({ status: 404, description: 'Not found.' })
async deleteOne(@Param('id', new ParseIntPipe()) id: number): Promise<void> {
await this.<%= camelCase %>Service.deleteById(id);
}
}

30
_templates/module/with-crud/dto.ts.ejs

@ -1,15 +1,15 @@
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.dto.ts
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
camelCase = h.changeCase.camel(name);
%>import { IsArray, IsOptional, IsString, Min, MinLength } from 'class-validator';
import { Type } from 'class-transformer';
import { ApiModelProperty } from '@nestjs/swagger';
export class <%= properName %>Dto {
}
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.dto.ts
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
camelCase = h.changeCase.camel(name);
%>import { IsArray, IsOptional, IsString, Min, MinLength } from 'class-validator';
import { Type } from 'class-transformer';
import { ApiModelProperty } from '@nestjs/swagger';
export class <%= properName %>Dto {
}

32
_templates/module/with-crud/entity.ts.ejs

@ -1,16 +1,16 @@
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.entity.ts
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
camelCase = h.changeCase.camel(name);
%>import { DbAuditModel } from '../../utils/dbmodel.model';
import { Column, Entity, ManyToOne, OneToMany } from 'typeorm';
import { ApiModelProperty } from '@nestjs/swagger';
@Entity()
export class <%= properName %> extends DbAuditModel {
}
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.entity.ts
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
camelCase = h.changeCase.camel(name);
%>import { DbAuditModel } from '../../utils/dbmodel.model';
import { Column, Entity, ManyToOne, OneToMany } from 'typeorm';
import { ApiModelProperty } from '@nestjs/swagger';
@Entity()
export class <%= properName %> extends DbAuditModel {
}

48
_templates/module/with-crud/module.ts.ejs

@ -1,24 +1,24 @@
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.module.ts
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
%>import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { <%=properName%>Controller } from './<%=kebabName%>.controller';
import { <%=properName%>Service } from './<%=kebabName%>.service';
import { <%=properName%> } from './<%=kebabName%>.entity';
import { <%=properName%>Repository } from './<%=kebabName%>.repository';
@Module({
imports: [
TypeOrmModule.forFeature([<%=properName%>, <%=properName%>Repository]),
],
controllers: [<%=properName%>Controller],
providers: [<%=properName%>Service],
exports: [<%=properName%>Service],
})
export class <%=properName%>Module {}
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.module.ts
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
%>import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { <%=properName%>Controller } from './<%=kebabName%>.controller';
import { <%=properName%>Service } from './<%=kebabName%>.service';
import { <%=properName%> } from './<%=kebabName%>.entity';
import { <%=properName%>Repository } from './<%=kebabName%>.repository';
@Module({
imports: [
TypeOrmModule.forFeature([<%=properName%>, <%=properName%>Repository]),
],
controllers: [<%=properName%>Controller],
providers: [<%=properName%>Service],
exports: [<%=properName%>Service],
})
export class <%=properName%>Module {}

38
_templates/module/with-crud/repository.ts.ejs

@ -1,19 +1,19 @@
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.repository.ts
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
camelCase = h.changeCase.camel(name);
%>import { EntityRepository, Repository } from 'typeorm';
import { <%= properName %> } from './<%= kebabName %>.entity';
import { Optional } from 'typescript-optional';
@EntityRepository(<%= properName %>)
export class <%= properName %>Repository extends Repository<<%= properName %>> {
async findOneById(id: number): Promise<Optional<<%= properName %>>> {
return Optional.ofNullable(
await this.findOne(id, {}),
);
}
}
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.repository.ts
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
camelCase = h.changeCase.camel(name);
%>import { EntityRepository, Repository } from 'typeorm';
import { <%= properName %> } from './<%= kebabName %>.entity';
import { Optional } from 'typescript-optional';
@EntityRepository(<%= properName %>)
export class <%= properName %>Repository extends Repository<<%= properName %>> {
async findOneById(id: number): Promise<Optional<<%= properName %>>> {
return Optional.ofNullable(
await this.findOne(id, {}),
);
}
}

24
_templates/module/with-crud/routing-body.ts.ejs

@ -1,13 +1,13 @@
---
to: src/app.routes.ts
after: export const appRoutes.*
inject: true
skip_if: /<%= h.changeCase.param(name) %>
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
%> {
path: '/<%= kebabName %>s',
module: <%= properName %>Module,
---
to: src/app.routes.ts
after: export const appRoutes.*
inject: true
skip_if: /<%= h.changeCase.param(name) %>
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
%> {
path: '/<%= kebabName %>s',
module: <%= properName %>Module,
}, },

18
_templates/module/with-crud/routing-head.ts.ejs

@ -1,10 +1,10 @@
---
to: src/app.routes.ts
after: import { Routes } from 'nest-router';
inject: true
skip_if: modules/<%= h.changeCase.param(name) %>
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
---
to: src/app.routes.ts
after: import { Routes } from 'nest-router';
inject: true
skip_if: modules/<%= h.changeCase.param(name) %>
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
%>import { <%= properName %>Module } from './modules/<%= kebabName %>/<%= kebabName %>.module'; %>import { <%= properName %>Module } from './modules/<%= kebabName %>/<%= kebabName %>.module';

6
_templates/module/with-crud/service.spec.ts.ejs

@ -1,3 +1,3 @@
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.service.spec.ts
---
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.service.spec.ts
---

124
_templates/module/with-crud/service.ts.ejs

@ -1,62 +1,62 @@
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.service.ts
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
camelCase = h.changeCase.camel(name);
%>import { <%= properName %> } from './<%= kebabName %>.entity';
import { Inject, Injectable, NotFoundException } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { <%= properName %>Repository } from './<%= kebabName %>.repository';
// import { } from './<%= kebabName %>.constants';
import { <%= properName %>Dto } from './<%= kebabName %>.dto';
import { Optional } from 'typescript-optional';
@Injectable()
export class <%= properName %>Service {
constructor(
@InjectRepository(<%= properName %>Repository)
private readonly <%= camelCase %>Repository: <%= properName %>Repository,
) { }
async getAll(): Promise<<%= properName %>[]> {
return this.<%= camelCase %>Repository.find({});
}
async getOneById(id: number): Promise<Optional<<%= properName %>>> {
return this.<%= camelCase %>Repository.findOneById(id);
}
async saveNew(body: <%= properName %>Dto): Promise<<%= properName %>> {
let <%= camelCase %>New = new <%= properName %>();
// Complete with the mappings
<%= camelCase %>New = await this.<%= camelCase %>Repository.save(<%= camelCase %>New);
return <%= camelCase %>New;
}
async update(id: number, body: <%= properName %>Dto): Promise<<%= properName %>> {
let <%= camelCase %>Found = (await this.<%= camelCase %>Repository.findOneById(id)).orElseThrow(
() => new NotFoundException(),
);
// Complete with the mappings
<%= camelCase %>Found = await this.<%= camelCase %>Repository.save(<%= camelCase %>Found);
return <%= camelCase %>Found;
}
async deleteById(id: number): Promise<void> {
const <%= camelCase %>Found = (await this.<%= camelCase %>Repository.findOneById(
id,
)).orElseThrow(() => new NotFoundException());
await this.<%= camelCase %>Repository.remove(<%= camelCase %>Found);
}
}
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.service.ts
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
camelCase = h.changeCase.camel(name);
%>import { <%= properName %> } from './<%= kebabName %>.entity';
import { Inject, Injectable, NotFoundException } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { <%= properName %>Repository } from './<%= kebabName %>.repository';
// import { } from './<%= kebabName %>.constants';
import { <%= properName %>Dto } from './<%= kebabName %>.dto';
import { Optional } from 'typescript-optional';
@Injectable()
export class <%= properName %>Service {
constructor(
@InjectRepository(<%= properName %>Repository)
private readonly <%= camelCase %>Repository: <%= properName %>Repository,
) { }
async getAll(): Promise<<%= properName %>[]> {
return this.<%= camelCase %>Repository.find({});
}
async getOneById(id: number): Promise<Optional<<%= properName %>>> {
return this.<%= camelCase %>Repository.findOneById(id);
}
async saveNew(body: <%= properName %>Dto): Promise<<%= properName %>> {
let <%= camelCase %>New = new <%= properName %>();
// Complete with the mappings
<%= camelCase %>New = await this.<%= camelCase %>Repository.save(<%= camelCase %>New);
return <%= camelCase %>New;
}
async update(id: number, body: <%= properName %>Dto): Promise<<%= properName %>> {
let <%= camelCase %>Found = (await this.<%= camelCase %>Repository.findOneById(id)).orElseThrow(
() => new NotFoundException(),
);
// Complete with the mappings
<%= camelCase %>Found = await this.<%= camelCase %>Repository.save(<%= camelCase %>Found);
return <%= camelCase %>Found;
}
async deleteById(id: number): Promise<void> {
const <%= camelCase %>Found = (await this.<%= camelCase %>Repository.findOneById(
id,
)).orElseThrow(() => new NotFoundException());
await this.<%= camelCase %>Repository.remove(<%= camelCase %>Found);
}
}

36
_templates/module/with-routing/module.ts.ejs

@ -1,18 +1,18 @@
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.module.ts
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
%>import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
@Module({
imports: [],
controllers: [],
providers: [],
exports: [],
})
export class <%=properName%>Module {}
---
to: src/modules/<%=h.changeCase.param(name)%>/<%=h.changeCase.param(name)%>.module.ts
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
%>import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
@Module({
imports: [],
controllers: [],
providers: [],
exports: [],
})
export class <%=properName%>Module {}

24
_templates/module/with-routing/routing-body.ts.ejs

@ -1,13 +1,13 @@
---
to: src/app.routes.ts
after: export const appRoutes.*
inject: true
skip_if: /<%= h.changeCase.param(name) %>
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
%> {
path: '/<%= kebabName %>s',
module: <%= properName %>Module,
---
to: src/app.routes.ts
after: export const appRoutes.*
inject: true
skip_if: /<%= h.changeCase.param(name) %>
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
%> {
path: '/<%= kebabName %>s',
module: <%= properName %>Module,
}, },

18
_templates/module/with-routing/routing-head.ts.ejs

@ -1,10 +1,10 @@
---
to: src/app.routes.ts
after: import { Routes } from 'nest-router';
inject: true
skip_if: modules/<%= h.changeCase.param(name) %>
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
---
to: src/app.routes.ts
after: import { Routes } from 'nest-router';
inject: true
skip_if: modules/<%= h.changeCase.param(name) %>
---
<%
properName = h.changeCase.pascal(name);
kebabName = h.changeCase.param(name);
%>import { <%= properName %>Module } from './modules/<%= kebabName %>/<%= kebabName %>.module'; %>import { <%= properName %>Module } from './modules/<%= kebabName %>/<%= kebabName %>.module';

28
exemple.env

@ -1,14 +1,14 @@
## API
API_PORT=3000
API_HOST=localhost
API_PROTOCOL=http
## LOGGER
LOG_LEVEL=debug
LOG_SQL_REQUEST=true
## DB [TypeORM]
DATABASE_URL=postgres://tpCi:someNotSecurePassword@localhost:5432/tpCi
## AUTHENTICATION [JWT]
JWT_SECRET=bananana
## API
API_PORT=3000
API_HOST=localhost
API_PROTOCOL=http
## LOGGER
LOG_LEVEL=debug
LOG_SQL_REQUEST=true
## DB [TypeORM]
DATABASE_URL=postgres://tpCi:someNotSecurePassword@localhost:5432/tpCi
## AUTHENTICATION [JWT]
JWT_SECRET=bananana

18936
yarn.lock
File diff suppressed because it is too large
View File

Loading…
Cancel
Save