@nathapp/na-cli 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/dist/templates/db-schema/.gitlab-ci.yml +139 -0
  2. package/dist/templates/db-schema/Makefile +885 -0
  3. package/dist/templates/k8s-deployment/.gitlab-ci.yml +158 -0
  4. package/dist/templates/k8s-deployment/Makefile +233 -0
  5. package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/script/Makefile +12 -0
  6. package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/script/Makefile +8 -0
  7. package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/script/Makefile +56 -0
  8. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/Makefile +9 -0
  9. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/script/Makefile +14 -0
  10. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/_t-0100-readiness-liveness.ts +84 -0
  11. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/hub.ts +372 -0
  12. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-contact.ts +158 -0
  13. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-contract.ts +328 -0
  14. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-kyc.ts +304 -0
  15. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-onboard-app.ts +823 -0
  16. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-onboard-web.ts +493 -0
  17. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-profile.ts +277 -0
  18. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-whitelist.ts +133 -0
  19. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/t-0200-start.ts +172 -0
  20. package/dist/templates/nestjs-api/.dockerignore +9 -0
  21. package/dist/templates/nestjs-api/.env +31 -0
  22. package/dist/templates/nestjs-api/.gitlab-ci.yml +180 -0
  23. package/dist/templates/nestjs-api/.nvmrc +1 -0
  24. package/dist/templates/nestjs-api/.prettierrc +4 -0
  25. package/dist/templates/nestjs-api/Makefile +95 -0
  26. package/dist/templates/nestjs-api/nest-cli.json +10 -0
  27. package/dist/templates/nestjs-api/ormconfig.ts +18 -0
  28. package/dist/templates/nestjs-api/src/app.controller.spec.ts +24 -0
  29. package/dist/templates/nestjs-api/src/app.controller.ts +27 -0
  30. package/dist/templates/nestjs-api/src/app.module.ts +31 -0
  31. package/dist/templates/nestjs-api/src/app.service.ts +27 -0
  32. package/dist/templates/nestjs-api/src/main.ts +31 -0
  33. package/dist/templates/nestjs-api/test/app.e2e-spec.ts +47 -0
  34. package/dist/templates/nestjs-api/tsconfig.build.json +5 -0
  35. package/dist/templates/nestjs-api/tsconfig.json +28 -0
  36. package/dist/templates/nestjs-api/tsconfig.spec.json +9 -0
  37. package/dist/templates/nestjs-library/.gitlab-ci.yml +134 -0
  38. package/dist/templates/nestjs-library/.nvmrc +1 -0
  39. package/dist/templates/nestjs-library/.prettierrc +6 -0
  40. package/dist/templates/nestjs-library/Makefile +60 -0
  41. package/dist/templates/nestjs-library/lib/index.ts +2 -0
  42. package/dist/templates/nestjs-library/test/app/controller/hello.controller.spec.ts +20 -0
  43. package/dist/templates/nestjs-library/test/app/controller/hello.controller.ts +7 -0
  44. package/dist/templates/nestjs-library/tsconfig.build.json +8 -0
  45. package/dist/templates/nestjs-library/tsconfig.json +21 -0
  46. package/dist/templates/nestjs-library/tsconfig.spec.json +9 -0
  47. package/dist/templates/ts-library/.dockerignore +2 -0
  48. package/dist/templates/ts-library/.eslintrc.js +24 -0
  49. package/dist/templates/ts-library/.gitlab-ci.yml +136 -0
  50. package/dist/templates/ts-library/.prettierrc +6 -0
  51. package/dist/templates/ts-library/Makefile +58 -0
  52. package/dist/templates/ts-library/index.ts +1 -0
  53. package/dist/templates/ts-library/lib/index.ts +1 -0
  54. package/dist/templates/ts-library/lib/samples/index.ts +5 -0
  55. package/dist/templates/ts-library/lib/samples/samples-function.ts +3 -0
  56. package/dist/templates/ts-library/test/sample.e2e-spec.ts +10 -0
  57. package/dist/templates/ts-library/tsconfig.build.json +4 -0
  58. package/dist/templates/ts-library/tsconfig.json +18 -0
  59. package/dist/templates/turbo-nestjs-vuexy/.dockerignore +2 -0
  60. package/dist/templates/turbo-nestjs-vuexy/.gitignore-rename +40 -0
  61. package/dist/templates/turbo-nestjs-vuexy/.npmrc-rename +0 -0
  62. package/dist/templates/turbo-nestjs-vuexy/Makefile +48 -0
  63. package/dist/templates/vuexy-portal/.dockerignore +2 -0
  64. package/dist/templates/vuexy-portal/.env +1 -0
  65. package/dist/templates/vuexy-portal/.gitlab-ci.yml +233 -0
  66. package/dist/templates/vuexy-portal/.npmrc-rename +2 -0
  67. package/dist/templates/vuexy-portal/.nvmrc +1 -0
  68. package/dist/templates/vuexy-portal/Makefile +55 -0
  69. package/dist/templates/vuexy-portal/src/@core/composable/createUrl.ts +20 -0
  70. package/dist/templates/vuexy-portal/src/@core/composable/useCookie.ts +43 -0
  71. package/dist/templates/vuexy-portal/src/@core/composable/useGenerateImageVariant.ts +25 -0
  72. package/dist/templates/vuexy-portal/src/@core/composable/useResponsiveSidebar.ts +29 -0
  73. package/dist/templates/vuexy-portal/src/@core/composable/useSkins.ts +42 -0
  74. package/dist/templates/vuexy-portal/src/@core/enums.ts +21 -0
  75. package/dist/templates/vuexy-portal/src/@core/index.ts +43 -0
  76. package/dist/templates/vuexy-portal/src/@core/initCore.ts +93 -0
  77. package/dist/templates/vuexy-portal/src/@core/libs/apex-chart/apexCharConfig.ts +701 -0
  78. package/dist/templates/vuexy-portal/src/@core/libs/chartjs/chartjsConfig.ts +372 -0
  79. package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/BarChart.ts +58 -0
  80. package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/BubbleChart.ts +58 -0
  81. package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/DoughnutChart.ts +58 -0
  82. package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/LineChart.ts +58 -0
  83. package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/PolarAreaChart.ts +58 -0
  84. package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/RadarChart.ts +58 -0
  85. package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/ScatterChart.ts +58 -0
  86. package/dist/templates/vuexy-portal/src/@core/stores/config.ts +80 -0
  87. package/dist/templates/vuexy-portal/src/@core/types.ts +49 -0
  88. package/dist/templates/vuexy-portal/src/@core/utils/formatters.ts +48 -0
  89. package/dist/templates/vuexy-portal/src/@core/utils/helpers.ts +32 -0
  90. package/dist/templates/vuexy-portal/src/@core/utils/plugins.ts +53 -0
  91. package/dist/templates/vuexy-portal/src/@core/utils/validators.ts +105 -0
  92. package/dist/templates/vuexy-portal/src/@core/utils/vuetify.ts +13 -0
  93. package/dist/templates/vuexy-portal/src/@custom/composables/toasts.ts +45 -0
  94. package/dist/templates/vuexy-portal/src/@custom/composables/validator.ts +160 -0
  95. package/dist/templates/vuexy-portal/src/@custom/enums/index.ts +0 -0
  96. package/dist/templates/vuexy-portal/src/@custom/types/common.ts +17 -0
  97. package/dist/templates/vuexy-portal/src/@custom/types/index.ts +0 -0
  98. package/dist/templates/vuexy-portal/src/@custom/types/pagination.ts +19 -0
  99. package/dist/templates/vuexy-portal/src/@custom/types/user.ts +5 -0
  100. package/dist/templates/vuexy-portal/src/@custom/utils/formatters.ts +83 -0
  101. package/dist/templates/vuexy-portal/src/@custom/utils/index.ts +0 -0
  102. package/dist/templates/vuexy-portal/src/@custom/utils/validators.ts +51 -0
  103. package/dist/templates/vuexy-portal/src/@layouts/components.ts +11 -0
  104. package/dist/templates/vuexy-portal/src/@layouts/config.ts +43 -0
  105. package/dist/templates/vuexy-portal/src/@layouts/enums.ts +27 -0
  106. package/dist/templates/vuexy-portal/src/@layouts/index.ts +49 -0
  107. package/dist/templates/vuexy-portal/src/@layouts/plugins/casl.ts +48 -0
  108. package/dist/templates/vuexy-portal/src/@layouts/stores/config.ts +115 -0
  109. package/dist/templates/vuexy-portal/src/@layouts/symbols.ts +1 -0
  110. package/dist/templates/vuexy-portal/src/@layouts/types.ts +126 -0
  111. package/dist/templates/vuexy-portal/src/@layouts/utils.ts +180 -0
  112. package/dist/templates/vuexy-portal/src/api/api.ts +1 -0
  113. package/dist/templates/vuexy-portal/src/api/commonApi.ts +25 -0
  114. package/dist/templates/vuexy-portal/src/api/index.ts +58 -0
  115. package/dist/templates/vuexy-portal/src/api/requestInterceptor.ts +21 -0
  116. package/dist/templates/vuexy-portal/src/api/responseInterceptor.ts +52 -0
  117. package/dist/templates/vuexy-portal/src/api/types.ts +14 -0
  118. package/dist/templates/vuexy-portal/src/api/useApi.ts +68 -0
  119. package/dist/templates/vuexy-portal/src/api/useFetchApi.ts +41 -0
  120. package/dist/templates/vuexy-portal/src/api/userApi.ts +11 -0
  121. package/dist/templates/vuexy-portal/src/composables/useApiFetch.ts +48 -0
  122. package/dist/templates/vuexy-portal/src/composables/useJwt.ts +108 -0
  123. package/dist/templates/vuexy-portal/src/main.ts +17 -0
  124. package/dist/templates/vuexy-portal/src/navigation/horizontal/index.ts +5 -0
  125. package/dist/templates/vuexy-portal/src/navigation/index.ts +7 -0
  126. package/dist/templates/vuexy-portal/src/navigation/vertical/index.ts +5 -0
  127. package/dist/templates/vuexy-portal/src/plugins/1.router/additional-routes.ts +23 -0
  128. package/dist/templates/vuexy-portal/src/plugins/1.router/guards.ts +50 -0
  129. package/dist/templates/vuexy-portal/src/plugins/1.router/index.ts +45 -0
  130. package/dist/templates/vuexy-portal/src/plugins/2.pinia.ts +8 -0
  131. package/dist/templates/vuexy-portal/src/plugins/casl/ability.ts +10 -0
  132. package/dist/templates/vuexy-portal/src/plugins/casl/composables/useAbility.ts +4 -0
  133. package/dist/templates/vuexy-portal/src/plugins/casl/index.ts +14 -0
  134. package/dist/templates/vuexy-portal/src/plugins/i18n/index.ts +29 -0
  135. package/dist/templates/vuexy-portal/src/plugins/iconify/build-icons.ts +299 -0
  136. package/dist/templates/vuexy-portal/src/plugins/iconify/index.ts +5 -0
  137. package/dist/templates/vuexy-portal/src/plugins/layouts.ts +13 -0
  138. package/dist/templates/vuexy-portal/src/plugins/toast/index.ts +9 -0
  139. package/dist/templates/vuexy-portal/src/plugins/vuetify/defaults.ts +192 -0
  140. package/dist/templates/vuexy-portal/src/plugins/vuetify/icons.ts +84 -0
  141. package/dist/templates/vuexy-portal/src/plugins/vuetify/index.ts +47 -0
  142. package/dist/templates/vuexy-portal/src/plugins/vuetify/theme.ts +155 -0
  143. package/dist/templates/vuexy-portal/src/plugins/webfontloader.ts +19 -0
  144. package/dist/templates/vuexy-portal/src/stores/auth.ts +22 -0
  145. package/dist/templates/vuexy-portal/src/stores/common.ts +41 -0
  146. package/dist/templates/vuexy-portal/src/stores/index.ts +0 -0
  147. package/dist/templates/vuexy-portal/src/utils/constants.ts +3 -0
  148. package/dist/templates/vuexy-portal/src/utils/paginationMeta.ts +10 -0
  149. package/dist/templates/vuexy-portal/themeConfig.ts +66 -0
  150. package/dist/templates/vuexy-portal/tsconfig.json +86 -0
  151. package/dist/templates/vuexy-portal/vite.config.ts +111 -0
  152. package/dist/utils/template.js +2 -0
  153. package/dist/utils/template.js.map +1 -1
  154. package/package.json +4 -1
  155. package/alias-script.sh +0 -30
  156. package/bunfig.toml +0 -3
  157. package/nax/config.json +0 -23
  158. package/nax/features/enhancements/prd.json +0 -61
@@ -0,0 +1,180 @@
1
+ # Project must implement Makefile for commands (test, version-prerelease, version-patch, name, version, image)
2
+ # command:
3
+ # - test: run project test cases
4
+ # - version-prerelease: bump prerelease version
5
+ # - version-patch: bump release version
6
+ # - name: display project name
7
+ # - version: display project version
8
+ # - image: display project name and version (e.g. hello-world:1.0.0)
9
+ #
10
+ stages:
11
+ # run test cases
12
+ - test
13
+ # build container image and push to registry
14
+ - prepare
15
+ - build-init
16
+ - build
17
+ - build-commit
18
+ # mark release commit as verified
19
+ - release
20
+ - notify
21
+
22
+ run-test:
23
+ stage: test
24
+ image: nathapp/node-bun:24.22.0-1.4.3-alpine-ci
25
+ script:
26
+ - make test
27
+ rules:
28
+ # NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT tag was created
29
+ - if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_COMMIT_TAG != null'
30
+ when: never
31
+ # Merge request
32
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
33
+ # Commit to protected branch or commit branch is default branch (master)
34
+ - if: '$CI_COMMIT_REF_PROTECTED == "true" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
35
+ # Commit message contains `run-test` keyword
36
+ - if: '$CI_COMMIT_MESSAGE =~ /run-test/'
37
+ # Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
38
+ - if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
39
+
40
+ run-pre-prepare:
41
+ stage: prepare
42
+ image: nathapp/node-bun:24.22.0-1.4.3-alpine-ci
43
+ artifacts:
44
+ paths:
45
+ - package.json
46
+ - image-tag.txt
47
+ - postman-collection.json
48
+ script:
49
+ - make spec
50
+ - make version-prerelease
51
+ - make image | awk '{ printf("%s/%s/%s", ENVIRON["CONTAINER_REGISTRY_URL"], ENVIRON["CONTAINER_REGISTRY_NAMESPACE"], $0)}' > image-tag.txt
52
+ rules:
53
+ # NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
54
+ - if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
55
+ when: never
56
+ # Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
57
+ - if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
58
+
59
+ run-prepare:
60
+ stage: prepare
61
+ image: nathapp/node-bun:24.22.0-1.4.3-alpine-ci
62
+ artifacts:
63
+ paths:
64
+ - package.json
65
+ - image-tag.txt
66
+ - postman-collection.json
67
+ script:
68
+ - make spec
69
+ - make version-patch
70
+ - make image | awk '{ printf("%s/%s/%s", ENVIRON["CONTAINER_REGISTRY_URL"], ENVIRON["CONTAINER_REGISTRY_NAMESPACE"], $0)}' > image-tag.txt
71
+ rules:
72
+ # NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
73
+ - if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
74
+ when: never
75
+ # Commit into default branch (master)
76
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
77
+
78
+ run-build-warmer:
79
+ stage: build-init
80
+ image:
81
+ name: registry-intl.cn-hongkong.aliyuncs.com/gkci/kaniko-warmer:debug
82
+ entrypoint: [""]
83
+ before_script:
84
+ - echo "$DOCKER_AUTH_CONFIG" > /kaniko/.docker/config.json
85
+ script:
86
+ - warmer `cat $CI_PROJECT_DIR/Dockerfile | grep FROM | awk -F" " '{ printf("--image=%s ", $2) }'`
87
+ rules:
88
+ # NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
89
+ - if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
90
+ when: never
91
+ # Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
92
+ - if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
93
+ # Commit into default branch (master)
94
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
95
+
96
+ run-build:
97
+ stage: build
98
+ image:
99
+ name: gcr.io/kaniko-project/executor:v1.23.2-debug
100
+ entrypoint: [""]
101
+ artifacts:
102
+ paths:
103
+ - image-digest.txt
104
+ before_script:
105
+ - echo "$DOCKER_AUTH_CONFIG" > /kaniko/.docker/config.json
106
+ variables:
107
+ GIT_SUBMODULE_FORCE_HTTPS: "true"
108
+ GIT_SUBMODULE_STRATEGY: recursive
109
+ GIT_DEPTH: 1
110
+ GIT_STRATEGY: clone
111
+ script:
112
+ - echo "BUILDING... `cat $CI_PROJECT_DIR/image-tag.txt`"
113
+ - if [ -f $CI_PROJECT_DIR/dependency.txt ] && ! [ -z "`cat $CI_PROJECT_DIR/dependency.txt`" ]; then cat $CI_PROJECT_DIR/dependency.txt | awk '{$1=$1;print;exit}' > $CI_PROJECT_DIR/dep.txt; else echo > $CI_PROJECT_DIR/dep.txt; fi
114
+ - echo -n 'LABEL DEPENDENCY='; cat $CI_PROJECT_DIR/dep.txt
115
+ - |
116
+ if [[ -n "$CONTAINER_CACHE_REPO" ]]; then
117
+ executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --digest-file $CI_PROJECT_DIR/image-digest.txt --destination "`cat $CI_PROJECT_DIR/image-tag.txt`" --label "dependency=`cat $CI_PROJECT_DIR/dep.txt`" --cache=true --cache-repo=$CONTAINER_CACHE_REPO --cache-ttl=24h
118
+ else
119
+ executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --digest-file $CI_PROJECT_DIR/image-digest.txt --destination "`cat $CI_PROJECT_DIR/image-tag.txt`" --label "dependency=`cat $CI_PROJECT_DIR/dep.txt`"
120
+ fi
121
+ - echo "PUSHED `cat $CI_PROJECT_DIR/image-tag.txt` (`cat $CI_PROJECT_DIR/image-digest.txt`)"
122
+ rules:
123
+ # NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
124
+ - if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
125
+ when: never
126
+ # Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
127
+ - if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
128
+ # Commit into default branch (master)
129
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
130
+
131
+ run-build-commit:
132
+ stage: build-commit
133
+ image: nathapp/node-bun:24.22.0-1.4.3-alpine-ci
134
+ before_script:
135
+ - git config --global user.name "$GITLAB_USER_NAME"
136
+ - git config --global user.email "$GITLAB_USER_EMAIL"
137
+ script:
138
+ - git add -A
139
+ - git commit -m "$(make version)" -m "== release-by-bot ($CI_COMMIT_SHA) =="
140
+ - git tag -a "$(make version)" -m "$(cat image-tag.txt) ($(cat image-digest.txt))"
141
+ - git push "https://${GITLAB_USER_NAME}:${CI_GIT_TOKEN}@${CI_REPOSITORY_URL#*@}" "HEAD:${CI_COMMIT_BRANCH}"
142
+ - git push "https://${GITLAB_USER_NAME}:${CI_GIT_TOKEN}@${CI_REPOSITORY_URL#*@}" --tags
143
+ rules:
144
+ # NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
145
+ - if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
146
+ when: never
147
+ # Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
148
+ - if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
149
+ # Commit into default branch (master)
150
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
151
+
152
+ run-release:
153
+ stage: release
154
+ image: nathapp/node-bun:24.22.0-1.4.3-alpine-ci
155
+ script:
156
+ - echo "Bumped version $(make version)"
157
+ rules:
158
+ # NOT commit message contains `run-without-release` keyword and NOT merge request
159
+ - if: '$CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event"'
160
+ when: never
161
+ # Tag was created
162
+ - if: '$CI_COMMIT_TAG != null'
163
+
164
+ run-notify:
165
+ stage: notify
166
+ image: nathapp/node-bun:24.22.0-1.4.3-alpine-ci
167
+ before_script:
168
+ - apk --no-cache add curl
169
+ script:
170
+ - 'curl -X POST -H "Content-Type: application/json" -d "{\"chat_id\": \"$TELEGRAM_CHAT_ID\", \"text\": \"CI: $CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME version:$(make version) has been released \"}" https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage'
171
+ rules:
172
+ # NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
173
+ - if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
174
+ when: never
175
+ - if: '$TELEGRAM_BOT_TOKEN == null || $TELEGRAM_BOT_TOKEN == "" || $TELEGRAM_CHAT_ID == null || $TELEGRAM_CHAT_ID == ""'
176
+ when: never
177
+ # Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
178
+ - if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
179
+ # Commit into default branch (master)
180
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
@@ -0,0 +1 @@
1
+ v22.22.2
@@ -0,0 +1,4 @@
1
+ {
2
+ "singleQuote": true,
3
+ "trailingComma": "all"
4
+ }
@@ -0,0 +1,95 @@
1
+ MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
2
+ ROOT_PATH := $(shell pwd)
3
+ SERVICE_NAME := <%= projectName %>
4
+
5
+ .PHONY: version name image test spec spec-file
6
+
7
+ version-major: version-sync
8
+ @npm -s version major --no-git-tag-version
9
+
10
+ version-minor: version-sync
11
+ @npm -s version minor --no-git-tag-version
12
+
13
+ version-patch: version-sync
14
+ @npm -s version patch --no-git-tag-version
15
+
16
+ version-prerelease: version-sync
17
+ @npm -s version prerelease --preid=rc --no-git-tag-version
18
+
19
+ version-latest:
20
+ @(git tag --sort=-creatordate || echo) | awk 'NR==1 { \
21
+ split($$0, n, "-"); \
22
+ if (n[1] != "") { \
23
+ split(n[1], v, "."); \
24
+ if (v[1] ~ /^[0-9]+$$/ && v[2] ~ /^[0-9]+$$/ && v[3] ~ /^[0-9]+$$/) { \
25
+ print $$0; \
26
+ exit 0; \
27
+ } \
28
+ } \
29
+ print "1.0.0-rc.0"; \
30
+ } \
31
+ END { \
32
+ if (NR == 0) { \
33
+ print "1.0.0-rc.0"; \
34
+ } \
35
+ }'
36
+
37
+ version-sync:
38
+ @git checkout $(CI_COMMIT_BRANCH)
39
+ @git pull --tags 2&>/dev/null || true
40
+ @git tag --sort=-creatordate | head -10
41
+ @cat package.json | jq -r --arg PKG_VERSION `make --no-print-directory -f$(MAKEFILE) version-latest` '.version=$$PKG_VERSION' > package.json;
42
+ @echo -n "Current Git tag: "; cat package.json | jq -r '.version'
43
+
44
+ version:
45
+ @echo $(shell node -p "require('$(ROOT_PATH)/package.json').version")
46
+
47
+ name:
48
+ @echo $(SERVICE_NAME)
49
+
50
+ image:
51
+ @echo $(SERVICE_NAME):$(shell node -p "require('$(ROOT_PATH)/package.json').version")
52
+
53
+ test:
54
+ @bun install --frozen-lockfile
55
+ @bun run test
56
+
57
+ spec:
58
+ @set -e -o pipefail; \
59
+ if [ -f "$(ROOT_PATH)/spec.yaml" ]; then \
60
+ make --no-print-directory -f$(MAKEFILE) spec-file > $(ROOT_PATH)/all-spec.yaml; \
61
+ openapi2postmanv2 -s $(ROOT_PATH)/all-spec.yaml -o postman-collection.json | \
62
+ awk ' \
63
+ BEGIN{ result = 0; error = "" } \
64
+ { \
65
+ if (0 < index($$0, "Conversion successful, collection written to file")) { \
66
+ result = 1; \
67
+ } \
68
+ error = error $$0; \
69
+ } \
70
+ END{ \
71
+ if (result != 1) { \
72
+ print error; \
73
+ exit(-1); \
74
+ } \
75
+ }'; \
76
+ rm -f $(ROOT_PATH)/all-spec.yaml; \
77
+ fi;
78
+
79
+ spec-file:
80
+ @cat $(ROOT_PATH)/spec.yaml;
81
+ @for file in `find $(ROOT_PATH)/src -iname "*-spec.yaml"`; do \
82
+ echo ""; \
83
+ cat $$file; \
84
+ done;
85
+
86
+
87
+ gen-keypair:
88
+ @openssl genrsa -out private.pem 2048
89
+ @openssl rsa -in private.pem -pubout -out public.pem
90
+
91
+ view-privatekey:
92
+ @awk '{printf "%s\\n", $$0}' private.pem
93
+
94
+ view-publickey:
95
+ @awk '{printf "%s\\n", $$0}' public.pem
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/nest-cli",
3
+ "collection": "@nestjs/schematics",
4
+ "sourceRoot": "src",
5
+ "compilerOptions": {
6
+ "deleteOutDir": true,
7
+ "plugins": ["@nestjs/swagger"],
8
+ "assets": ["i18n/**/*"]
9
+ }
10
+ }
@@ -0,0 +1,18 @@
1
+ import { DataSource, DataSourceOptions } from 'typeorm';
2
+
3
+ const config = {
4
+ name: 'default',
5
+ type: 'mysql',
6
+ host: 'localhost',
7
+ port: 3306,
8
+ username: 'typeorm',
9
+ password: 'password',
10
+ database: 'database-test',
11
+ entities: ['./src/auth-module/**/*.entity{.ts,.js}'],
12
+ synchronize: false,
13
+ migrations: ['./src/migrations/*{.ts,.js}'],
14
+ // migrationsTableName: 'migrations_typeorm',
15
+ migrationsRun: true,
16
+ };
17
+
18
+ export const connectionSource = new DataSource(config as DataSourceOptions);
@@ -0,0 +1,24 @@
1
+ import { Test, TestingModule } from '@nestjs/testing';
2
+ import { AppController } from './app.controller';
3
+ import { AppService } from '@/app.service';
4
+
5
+ describe('AppController', () => {
6
+ let appController: AppController;
7
+ let appService: AppService;
8
+
9
+ beforeEach(async () => {
10
+ const app: TestingModule = await Test.createTestingModule({
11
+ controllers: [AppController],
12
+ providers: [AppService],
13
+ }).compile();
14
+
15
+ appController = app.get<AppController>(AppController);
16
+ appService = app.get(AppService);
17
+ });
18
+
19
+ describe('root', () => {
20
+ it('should return "App Version"', () => {
21
+ expect(appController.get()).toEqual(appService.displayVersion());
22
+ });
23
+ });
24
+ });
@@ -0,0 +1,27 @@
1
+ import { JsonResponse } from '@nathapp/common';
2
+ import { Public } from '@nathapp/nestjs-auth';
3
+ import { Controller, Get } from '@nestjs/common';
4
+ import { AppService } from './app.service';
5
+
6
+ @Controller()
7
+ export class AppController {
8
+ constructor(private readonly appService: AppService) { }
9
+
10
+ @Get('/')
11
+ @Public()
12
+ get() {
13
+ return this.appService.displayVersion();
14
+ }
15
+
16
+ @Get('/liveness')
17
+ @Public()
18
+ liveness() {
19
+ return JsonResponse.Ok({});
20
+ }
21
+
22
+ @Get('/readiness')
23
+ @Public()
24
+ readiness() {
25
+ return JsonResponse.Ok({});
26
+ }
27
+ }
@@ -0,0 +1,31 @@
1
+ import {
2
+ DefaultJwtModuleOptionsFactory,
3
+ JwtModule,
4
+ JwtStrategy,
5
+ } from '@nathapp/nestjs-auth';
6
+ import { I18nCoreModule, ServerSecurityConfig } from '@nathapp/nestjs-common';
7
+ import { LoggingModule } from '@nathapp/nestjs-logging';
8
+ import { Module } from '@nestjs/common';
9
+ import { ConfigModule } from '@nestjs/config';
10
+ import { AppController } from './app.controller';
11
+ import { AppService } from './app.service';
12
+
13
+ @Module({
14
+ imports: [
15
+ ConfigModule.forRoot({
16
+ isGlobal: true,
17
+ load: [ServerSecurityConfig],
18
+ }),
19
+ JwtModule.forRootAsync({
20
+ imports: [ConfigModule],
21
+ useClass: DefaultJwtModuleOptionsFactory,
22
+ }),
23
+ I18nCoreModule.forRoot(),
24
+ // Request context + auto request logging; `/`, `/liveness`, `/readiness`
25
+ // and `/favicon.ico` are excluded by default.
26
+ LoggingModule.register({ type: 'default' }),
27
+ ],
28
+ controllers: [AppController],
29
+ providers: [AppService, JwtStrategy],
30
+ })
31
+ export class AppModule {}
@@ -0,0 +1,27 @@
1
+ import { JsonResponse } from '@nathapp/common';
2
+ import { Injectable } from '@nestjs/common';
3
+
4
+ @Injectable()
5
+ export class AppService {
6
+ displayVersion(): any {
7
+ return JsonResponse.Ok({
8
+ version: `${process.env.npm_package_name} ${process.env.npm_package_version}`,
9
+ });
10
+ }
11
+
12
+ appVersion(): string {
13
+ return process.env.npm_package_version || '1.0.0-rc.0';
14
+ }
15
+
16
+ appName(): string {
17
+ return process.env.npm_package_name || 'noname-app';
18
+ }
19
+
20
+ getAppInfo(): any {
21
+ return {
22
+ name: this.appName(),
23
+ version: this.appVersion(),
24
+ description: '',
25
+ };
26
+ }
27
+ }
@@ -0,0 +1,31 @@
1
+ import { AppFactory } from '@nathapp/nestjs-app';
2
+ import { Logger } from '@nathapp/nestjs-logging';
3
+ import { AppModule } from './app.module';
4
+ import { AppService } from './app.service';
5
+
6
+ async function bootstrap() {
7
+ <% if (isFastify) { -%>
8
+ const app = await AppFactory.createFastifyApp(AppModule, {
9
+ bufferLogs: true,
10
+ });
11
+ <% } else { -%>
12
+ const app = await AppFactory.create(AppModule, {
13
+ bufferLogs: true,
14
+ });
15
+ <% } -%>
16
+ app.useLogger(app.get(Logger));
17
+
18
+ const appService = app.get(AppService);
19
+
20
+ await app.useServerSecurityConfig();
21
+
22
+ app
23
+ .useAppGlobalPrefix()
24
+ .useAppGlobalPipes()
25
+ .useAppGlobalFilters()
26
+ .useAppGlobalGuards()
27
+ .useSwaggerUIOnDevOnly(appService.getAppInfo());
28
+
29
+ await app.start();
30
+ }
31
+ bootstrap();
@@ -0,0 +1,47 @@
1
+ import { INestApplication } from '@nestjs/common';
2
+ import { Test, TestingModule } from '@nestjs/testing';
3
+ <% if (isFastify) { -%>
4
+ import {
5
+ FastifyAdapter,
6
+ NestFastifyApplication,
7
+ } from '@nestjs/platform-fastify';
8
+ <% } -%>
9
+ import request from 'supertest';
10
+ import { AppModule } from '../src/app.module';
11
+ import { AppService } from '../src/app.service';
12
+
13
+ describe('AppController (e2e)', () => {
14
+ let app: INestApplication;
15
+ let appService: AppService;
16
+
17
+ beforeEach(async () => {
18
+ const moduleFixture: TestingModule = await Test.createTestingModule({
19
+ imports: [AppModule],
20
+ }).compile();
21
+
22
+ <% if (isFastify) { -%>
23
+ app = moduleFixture.createNestApplication<NestFastifyApplication>(
24
+ new FastifyAdapter(),
25
+ );
26
+ <% } else { -%>
27
+ app = moduleFixture.createNestApplication();
28
+ <% } -%>
29
+ appService = app.get(AppService);
30
+ await app.init();
31
+ <% if (isFastify) { -%>
32
+ await app.getHttpAdapter().getInstance().ready();
33
+ <% } -%>
34
+ });
35
+
36
+ afterEach(async () => {
37
+ await app.close();
38
+ });
39
+
40
+ it('/ (GET)', () => {
41
+ const response = appService.displayVersion();
42
+ return request(app.getHttpServer())
43
+ .get('/')
44
+ .expect(200)
45
+ .expect({ ret: response.ret, data: response.data });
46
+ });
47
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "include": ["src/**/*"],
4
+ "exclude": ["generated", "node_modules", "test", "dist", "**/*spec.ts", "ormconfig.ts"]
5
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "moduleResolution": "node",
5
+ "declaration": true,
6
+ "removeComments": true,
7
+ "emitDecoratorMetadata": true,
8
+ "experimentalDecorators": true,
9
+ "allowSyntheticDefaultImports": true,
10
+ "esModuleInterop": true,
11
+ "resolveJsonModule": true,
12
+ "target": "ES2022",
13
+ "lib": ["ES2022"],
14
+ "sourceMap": true,
15
+ "outDir": "./dist",
16
+ "baseUrl": "./",
17
+ "incremental": true,
18
+ "skipLibCheck": true,
19
+ "strictNullChecks": false,
20
+ "noImplicitAny": false,
21
+ "strictBindCallApply": false,
22
+ "forceConsistentCasingInFileNames": true,
23
+ "noFallthroughCasesInSwitch": false,
24
+ "paths": {
25
+ "@/*": ["src/*"]
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "noEmit": true,
5
+ "types": ["vitest/globals", "node"]
6
+ },
7
+ "include": ["src/**/*", "test/**/*"],
8
+ "exclude": ["node_modules", "dist"]
9
+ }