@nathapp/na-cli 1.0.0-rc.4 → 1.0.0-rc.40
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.
- package/.gitlab-ci.yml +135 -0
- package/Makefile +16 -9
- package/README.md +18 -2
- package/alias-script.sh +30 -0
- package/dist/index.js +106 -128
- package/dist/index.js.map +1 -1
- package/dist/templates/db-schema/.gitignore-rename +1 -0
- package/dist/templates/db-schema/.gitlab-ci.yml +139 -0
- package/dist/templates/db-schema/001_Schema.sql +1 -0
- package/dist/templates/db-schema/DEV_MODE.txt +1 -0
- package/dist/templates/db-schema/Dockerfile +3 -0
- package/dist/templates/db-schema/Email-Templates/Individual/README.md +1 -0
- package/dist/templates/db-schema/GET_VERSION.sql +47 -0
- package/dist/templates/db-schema/Makefile +885 -0
- package/dist/templates/db-schema/README.md +117 -0
- package/dist/templates/db-schema/SET_VERSION.sql +5 -0
- package/dist/templates/db-schema/docker-compose.yaml +47 -0
- package/dist/templates/db-schema/package.json +3 -0
- package/dist/templates/db-schema/push.sh +0 -0
- package/dist/templates/db-schema/samples/899_DB_Grant_User.sql +9 -0
- package/dist/templates/db-schema/samples/990_SAMPLE_Init_Data.sql +27 -0
- package/dist/templates/k8s-deployment/.gitignore-rename +1 -0
- package/dist/templates/k8s-deployment/.gitlab-ci.yml +128 -0
- package/dist/templates/k8s-deployment/.helmignore +23 -0
- package/dist/templates/k8s-deployment/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/Makefile +196 -0
- package/dist/templates/k8s-deployment/README.md +32 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/script/Makefile +12 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/templates/job.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/values.yaml +51 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/deployment.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/ingress.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/job.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/pv.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/pvc.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/sc.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/service.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/statefulset.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/values.yaml +15 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/script/Makefile +8 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/templates/job.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/values.yaml +42 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/deployment.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/ingress.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/job.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/pv.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/pvc.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/sc.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/service.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/statefulset.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/values.yaml +12 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/script/Makefile +49 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/script/_env.yaml +2 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/templates/job.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/values.yaml +36 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/cluster-role-binding.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/cronjob.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/deployment.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/ingress.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/pv.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/pvc.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/sc.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/service-account.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/service.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/statefulset.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/values.yaml +47 -0
- package/dist/templates/k8s-deployment/services/charts/tests/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/Makefile +9 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/fixtures/index.json +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/login/login-spec.js +47 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/login/loginEmailWrong-spec.js +14 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/login/loginPasswordWrong-spec.js +14 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/profile/updatePassword-spec.js +15 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/profile/updateProfile-spec.js +25 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/test-script.spec.js +9 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/plugins/index.js +22 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/support/commands.js +258 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/support/index.js +35 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/support/misc.js +8 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress.json +4 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/templates/pod.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/values.yaml +70 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/.helmignore +2 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/script/Makefile +14 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/templates/pod.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/_t-0100-readiness-liveness.ts +84 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/hub.ts +372 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-contact.ts +158 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-contract.ts +328 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-kyc.ts +304 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-onboard-app.ts +823 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-onboard-web.ts +493 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-profile.ts +277 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-whitelist.ts +133 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/resources/live.jpg +0 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/resources/mykad_front.jpg +0 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/resources/profile.jpg +0 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/t-0200-start.ts +172 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/values.yaml +59 -0
- package/dist/templates/k8s-deployment/templates/_cluster-role-binding.tpl +20 -0
- package/dist/templates/k8s-deployment/templates/_configmap.tpl +37 -0
- package/dist/templates/k8s-deployment/templates/_cronjob.tpl +225 -0
- package/dist/templates/k8s-deployment/templates/_deployment.tpl +246 -0
- package/dist/templates/k8s-deployment/templates/_helpers.tpl +31 -0
- package/dist/templates/k8s-deployment/templates/_ingress.tpl +77 -0
- package/dist/templates/k8s-deployment/templates/_job.tpl +233 -0
- package/dist/templates/k8s-deployment/templates/_pod.tpl +214 -0
- package/dist/templates/k8s-deployment/templates/_pv.tpl +42 -0
- package/dist/templates/k8s-deployment/templates/_pvc.tpl +27 -0
- package/dist/templates/k8s-deployment/templates/_root.tpl +314 -0
- package/dist/templates/k8s-deployment/templates/_sc.tpl +19 -0
- package/dist/templates/k8s-deployment/templates/_secret.tpl +15 -0
- package/dist/templates/k8s-deployment/templates/_service-account.tpl +8 -0
- package/dist/templates/k8s-deployment/templates/_service.tpl +40 -0
- package/dist/templates/k8s-deployment/templates/_statefulset.tpl +244 -0
- package/dist/templates/k8s-deployment/templates/root-cm.yaml +10 -0
- package/dist/templates/k8s-deployment/templates/root-pull-secret.yaml +11 -0
- package/dist/templates/k8s-deployment/templates/root-secret.yaml +24 -0
- package/dist/templates/k8s-deployment/values.yaml +38 -0
- package/dist/templates/k8s-helm-chart/Chart.yaml +23 -0
- package/dist/templates/k8s-helm-chart/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-helm-chart/templates/cluster-role-binding.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/cronjob.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/deployment.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/ingress.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/pv.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/pvc.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/sc.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/secret.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/service-account.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/service.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/statefulset.yaml +1 -0
- package/dist/templates/k8s-helm-chart/values.yaml +41 -0
- package/dist/templates/mxw-base-api-express/.dockerignore +2 -0
- package/dist/templates/mxw-base-api-express/.env +10 -0
- package/dist/templates/mxw-base-api-express/.gitignore-rename +3 -0
- package/dist/templates/mxw-base-api-express/.gitlab-ci.yml +174 -0
- package/dist/templates/mxw-base-api-express/.nvmrc +1 -0
- package/dist/templates/mxw-base-api-express/Dockerfile +14 -0
- package/dist/templates/mxw-base-api-express/Makefile +84 -0
- package/dist/templates/mxw-base-api-express/README.md +71 -0
- package/dist/templates/mxw-base-api-express/package.json +55 -0
- package/dist/templates/mxw-base-api-express/src/app-service.test.ts +94 -0
- package/dist/templates/mxw-base-api-express/src/app-service.ts +498 -0
- package/dist/templates/mxw-base-api-express/src/auth/auth-user.test.ts +215 -0
- package/dist/templates/mxw-base-api-express/src/auth/auth-user.ts +86 -0
- package/dist/templates/mxw-base-api-express/src/auth/auth.ts +81 -0
- package/dist/templates/mxw-base-api-express/src/core-service.ts +72 -0
- package/dist/templates/mxw-base-api-express/src/crud.ts +84 -0
- package/dist/templates/mxw-base-api-express/src/http-handler.ts +71 -0
- package/dist/templates/mxw-base-api-express/src/server.ts +54 -0
- package/dist/templates/mxw-base-api-express/src/test.ts +38 -0
- package/dist/templates/mxw-base-api-express/src/utils/api-utilities.ts +52 -0
- package/dist/templates/mxw-base-api-express/src/utils/file-utilities.ts +55 -0
- package/dist/templates/mxw-base-api-express/tsconfig.json +32 -0
- package/dist/templates/nestjs-api/.dockerignore +2 -0
- package/dist/templates/nestjs-api/.env +12 -0
- package/dist/templates/nestjs-api/.eslintrc.js +25 -0
- package/dist/templates/nestjs-api/.gitignore-rename +35 -0
- package/dist/templates/nestjs-api/.gitlab-ci.yml +174 -0
- package/dist/templates/nestjs-api/.nvmrc +1 -0
- package/dist/templates/nestjs-api/.prettierrc +4 -0
- package/dist/templates/nestjs-api/Dockerfile +19 -0
- package/dist/templates/nestjs-api/Makefile +84 -0
- package/dist/templates/nestjs-api/README.md +67 -0
- package/dist/templates/nestjs-api/nest-cli.json +8 -0
- package/dist/templates/nestjs-api/package.json +75 -0
- package/dist/templates/nestjs-api/src/app.controller.spec.ts +22 -0
- package/dist/templates/nestjs-api/src/app.controller.ts +27 -0
- package/dist/templates/nestjs-api/src/app.module.ts +10 -0
- package/dist/templates/nestjs-api/src/app.service.ts +12 -0
- package/dist/templates/nestjs-api/src/main.ts +31 -0
- package/dist/templates/nestjs-api/test/app.e2e-spec.ts +24 -0
- package/dist/templates/nestjs-api/test/jest-e2e.json +9 -0
- package/dist/templates/nestjs-api/tsconfig.build.json +4 -0
- package/dist/templates/nestjs-api/tsconfig.json +22 -0
- package/dist/templates/nestjs-library/.eslintrc.js +24 -0
- package/dist/templates/nestjs-library/.gitignore-rename +39 -0
- package/dist/templates/nestjs-library/.gitlab-ci.yml +135 -0
- package/dist/templates/nestjs-library/.npmignore-rename +30 -0
- package/dist/templates/nestjs-library/.prettierrc +6 -0
- package/dist/templates/nestjs-library/LICENSE +21 -0
- package/dist/templates/nestjs-library/Makefile +60 -0
- package/dist/templates/nestjs-library/README.md +3 -0
- package/dist/templates/nestjs-library/index.d.ts +1 -0
- package/dist/templates/nestjs-library/index.js +6 -0
- package/dist/templates/nestjs-library/index.ts +1 -0
- package/dist/templates/nestjs-library/lib/index.ts +2 -0
- package/dist/templates/nestjs-library/package.json +43 -0
- package/dist/templates/nestjs-library/tsconfig.build.json +4 -0
- package/dist/templates/nestjs-library/tsconfig.json +18 -0
- package/dist/templates/ts-library/.dockerignore +2 -0
- package/dist/templates/ts-library/.eslintrc.js +24 -0
- package/dist/templates/ts-library/.gitignore-rename +37 -0
- package/dist/templates/ts-library/.gitlab-ci.yml +135 -0
- package/dist/templates/ts-library/.npmignore-rename +30 -0
- package/dist/templates/ts-library/.prettierrc +6 -0
- package/dist/templates/ts-library/LICENSE +21 -0
- package/dist/templates/ts-library/Makefile +58 -0
- package/dist/templates/ts-library/README.md +1 -0
- package/dist/templates/ts-library/index.d.ts +1 -0
- package/dist/templates/ts-library/index.js +6 -0
- package/dist/templates/ts-library/index.ts +1 -0
- package/dist/templates/ts-library/lib/index.ts +1 -0
- package/dist/templates/ts-library/lib/samples/index.ts +5 -0
- package/dist/templates/ts-library/lib/samples/samples-function.ts +3 -0
- package/dist/templates/ts-library/package.json +34 -0
- package/dist/templates/ts-library/test/jest-e2e.json +9 -0
- package/dist/templates/ts-library/test/sample.e2e-spec.ts +10 -0
- package/dist/templates/ts-library/tsconfig.build.json +4 -0
- package/dist/templates/ts-library/tsconfig.json +18 -0
- package/dist/utils/env.js +146 -0
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/template.js +362 -1
- package/dist/utils/template.js.map +1 -1
- package/package.json +9 -5
- package/src/index.ts +0 -182
- package/src/utils/template.ts +0 -9
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { isUndefinedOrNullOrEmpty } from "mxw-libs-utils";
|
|
2
|
+
import { mxw } from "mxw-sdk-js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* NOTE: due to limited header size for Bearer this Utils is
|
|
6
|
+
* To Transform Large Size Property to hash.
|
|
7
|
+
*/
|
|
8
|
+
export default class ApiUtils {
|
|
9
|
+
|
|
10
|
+
// change to loop if having more property
|
|
11
|
+
public static transformParamsWithHash( params: any) {
|
|
12
|
+
const tokenParams = {
|
|
13
|
+
... params,
|
|
14
|
+
}
|
|
15
|
+
// docBase64 too large to header, will throw error
|
|
16
|
+
if(tokenParams.hasOwnProperty("docBase64") && !isUndefinedOrNullOrEmpty(tokenParams.docBase64)) {
|
|
17
|
+
tokenParams.docBase64Signature = this.hashMessage(tokenParams.docBase64);
|
|
18
|
+
delete tokenParams.docBase64;
|
|
19
|
+
params = {
|
|
20
|
+
...params,
|
|
21
|
+
docBase64Signature: tokenParams.docBase64Signature,
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
tokenParams,
|
|
26
|
+
requestParams: params,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public static verify(params: any) {
|
|
31
|
+
|
|
32
|
+
if(!params.hasOwnProperty("docBase64") || isUndefinedOrNullOrEmpty(params.docBase64)) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if(isUndefinedOrNullOrEmpty(params?.docBase64Signature)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return this.verifyHash(params.docBase64, params.docBase64Signature);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public static verifyHash(message: string, hash: string) {
|
|
44
|
+
const signature = this.hashMessage(message);
|
|
45
|
+
return signature == hash;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
public static hashMessage(message: string) {
|
|
50
|
+
return mxw.utils.hashMessage(message);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { errors, INVALID_REQUEST } from "mxw-libs-errors";
|
|
4
|
+
import { base64 } from "mxw-libs-utils";
|
|
5
|
+
import path from 'path'
|
|
6
|
+
import axios from "axios";
|
|
7
|
+
|
|
8
|
+
export default class FileUtils {
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
public static validUrl(url) {
|
|
12
|
+
return /http(s)?:\/\/(\w+:?\w*@)?(\S+)(:\d+)?((?<=\.)\w+)+(\/([\w#!:.?+=&%@!\-/])*)?/gi.test(url);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public static validFileType(filename) {
|
|
16
|
+
return /(?<=\S+)\.(jpg|png|jpeg|pdf)/gi.test(filename);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public static isImage(filename) {
|
|
20
|
+
return /(?<=\S+)\.(jpg|png|jpeg)/gi.test(filename);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public static readFileAndConvert(fileName: string) {
|
|
24
|
+
if (fs.statSync(fileName).isFile()) {
|
|
25
|
+
return FileUtils.base64ToNode(fs.readFileSync(path.resolve(fileName)));
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public static base64ToNode(buffer: Buffer) {
|
|
31
|
+
return buffer.toString('base64');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
public static writeFile(filename: string, data: string) {
|
|
36
|
+
const buffer = Buffer.from(base64.decode(data));
|
|
37
|
+
return this.writeBufferToFile(filename, buffer);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public static writeToFile(filename: string, data: string) {
|
|
41
|
+
const buffer = Buffer.from(data, "utf-8");
|
|
42
|
+
return this.writeBufferToFile(filename, buffer);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public static writeBufferToFile(filename: string, buffer: Buffer) {
|
|
46
|
+
return new Promise<void>((resolve, reject) => {
|
|
47
|
+
fs.writeFile(filename, buffer, {}, (error) => {
|
|
48
|
+
if (error) {
|
|
49
|
+
return reject(error);
|
|
50
|
+
}
|
|
51
|
+
return resolve();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"esModuleInterop": true,
|
|
5
|
+
"target": "es6",
|
|
6
|
+
"noImplicitAny": false,
|
|
7
|
+
// "noUnusedLocals": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
|
9
|
+
"noFallthroughCasesInSwitch": true,
|
|
10
|
+
"moduleResolution": "node",
|
|
11
|
+
"sourceMap": true,
|
|
12
|
+
"outDir": "dist",
|
|
13
|
+
"baseUrl": "./",
|
|
14
|
+
"paths": {
|
|
15
|
+
"*": [
|
|
16
|
+
"node_modules/*",
|
|
17
|
+
"src/types/*"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
"typeRoots": [
|
|
21
|
+
"node_modules/@types/*"
|
|
22
|
+
],
|
|
23
|
+
"types": [
|
|
24
|
+
"node"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"exclude": [
|
|
28
|
+
"src/**/*.test.ts",
|
|
29
|
+
"src/**/**/*.test.ts",
|
|
30
|
+
"src/**/**/**/*.test.ts"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
SERVER_PORT=8080
|
|
2
|
+
|
|
3
|
+
GLOBAL_PREFIX=/
|
|
4
|
+
|
|
5
|
+
JWT_ACCESS_SECERT=thisisasecret
|
|
6
|
+
JWT_ACCESS_EXPIRE=24h
|
|
7
|
+
JWT_REFRESH_SECRET=thisisarefreshsecret
|
|
8
|
+
JWT_REFRESH_EXPIRE=1y
|
|
9
|
+
|
|
10
|
+
#MONGO_URL=mongodb://root:password@127.0.0.1:27017/mongo?authSource=admin
|
|
11
|
+
|
|
12
|
+
#MYSQL_URL=mysql://root:password@127.0.0.1:3306/db?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT&pinGlobalTxToPhysicalConnection=true
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
parser: '@typescript-eslint/parser',
|
|
3
|
+
parserOptions: {
|
|
4
|
+
project: 'tsconfig.json',
|
|
5
|
+
tsconfigRootDir: __dirname,
|
|
6
|
+
sourceType: 'module',
|
|
7
|
+
},
|
|
8
|
+
plugins: ['@typescript-eslint/eslint-plugin'],
|
|
9
|
+
extends: [
|
|
10
|
+
'plugin:@typescript-eslint/recommended',
|
|
11
|
+
'plugin:prettier/recommended',
|
|
12
|
+
],
|
|
13
|
+
root: true,
|
|
14
|
+
env: {
|
|
15
|
+
node: true,
|
|
16
|
+
jest: true,
|
|
17
|
+
},
|
|
18
|
+
ignorePatterns: ['.eslintrc.js'],
|
|
19
|
+
rules: {
|
|
20
|
+
'@typescript-eslint/interface-name-prefix': 'off',
|
|
21
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
22
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
23
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# compiled output
|
|
2
|
+
/dist
|
|
3
|
+
/node_modules
|
|
4
|
+
|
|
5
|
+
# Logs
|
|
6
|
+
logs
|
|
7
|
+
*.log
|
|
8
|
+
npm-debug.log*
|
|
9
|
+
pnpm-debug.log*
|
|
10
|
+
yarn-debug.log*
|
|
11
|
+
yarn-error.log*
|
|
12
|
+
lerna-debug.log*
|
|
13
|
+
|
|
14
|
+
# OS
|
|
15
|
+
.DS_Store
|
|
16
|
+
|
|
17
|
+
# Tests
|
|
18
|
+
/coverage
|
|
19
|
+
/.nyc_output
|
|
20
|
+
|
|
21
|
+
# IDEs and editors
|
|
22
|
+
/.idea
|
|
23
|
+
.project
|
|
24
|
+
.classpath
|
|
25
|
+
.c9/
|
|
26
|
+
*.launch
|
|
27
|
+
.settings/
|
|
28
|
+
*.sublime-workspace
|
|
29
|
+
|
|
30
|
+
# IDE - VSCode
|
|
31
|
+
.vscode/*
|
|
32
|
+
!.vscode/settings.json
|
|
33
|
+
!.vscode/tasks.json
|
|
34
|
+
!.vscode/launch.json
|
|
35
|
+
!.vscode/extensions.json
|
|
@@ -0,0 +1,174 @@
|
|
|
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: registry-intl.cn-hongkong.aliyuncs.com/gkci/docker:18-ci
|
|
25
|
+
services:
|
|
26
|
+
- docker:18-dind
|
|
27
|
+
script:
|
|
28
|
+
- make test
|
|
29
|
+
rules:
|
|
30
|
+
# NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT tag was created
|
|
31
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_COMMIT_TAG != null'
|
|
32
|
+
when: never
|
|
33
|
+
# Merge request
|
|
34
|
+
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
35
|
+
# Commit to protected branch or commit branch is default branch (master)
|
|
36
|
+
- if: '$CI_COMMIT_REF_PROTECTED == "true" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
37
|
+
# Commit message contains `run-test` keyword
|
|
38
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-test/'
|
|
39
|
+
# Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
|
|
40
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
41
|
+
|
|
42
|
+
run-pre-prepare:
|
|
43
|
+
stage: prepare
|
|
44
|
+
image: registry-intl.cn-hongkong.aliyuncs.com/gkci/node:10.20.0-alpine-ci-1
|
|
45
|
+
artifacts:
|
|
46
|
+
paths:
|
|
47
|
+
- package.json
|
|
48
|
+
- package-lock.json
|
|
49
|
+
- image-tag.txt
|
|
50
|
+
- postman-collection.json
|
|
51
|
+
script:
|
|
52
|
+
- make spec
|
|
53
|
+
- make version-prerelease
|
|
54
|
+
- make image | awk '{ printf("%s/%s/%s", ENVIRON["CONTAINER_REGISTRY_URL"], ENVIRON["CONTAINER_REGISTRY_NAMESPACE"], $0)}' > image-tag.txt
|
|
55
|
+
rules:
|
|
56
|
+
# NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
|
|
57
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
|
|
58
|
+
when: never
|
|
59
|
+
# Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
|
|
60
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
61
|
+
|
|
62
|
+
run-prepare:
|
|
63
|
+
stage: prepare
|
|
64
|
+
image: registry-intl.cn-hongkong.aliyuncs.com/gkci/node:10.20.0-alpine-ci-1
|
|
65
|
+
artifacts:
|
|
66
|
+
paths:
|
|
67
|
+
- package.json
|
|
68
|
+
- package-lock.json
|
|
69
|
+
- image-tag.txt
|
|
70
|
+
- postman-collection.json
|
|
71
|
+
script:
|
|
72
|
+
- make spec
|
|
73
|
+
- make version-patch
|
|
74
|
+
- make image | awk '{ printf("%s/%s/%s", ENVIRON["CONTAINER_REGISTRY_URL"], ENVIRON["CONTAINER_REGISTRY_NAMESPACE"], $0)}' > image-tag.txt
|
|
75
|
+
rules:
|
|
76
|
+
# NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
|
|
77
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
|
|
78
|
+
when: never
|
|
79
|
+
# Commit into default branch (master)
|
|
80
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
81
|
+
|
|
82
|
+
run-build-warmer:
|
|
83
|
+
stage: build-init
|
|
84
|
+
image:
|
|
85
|
+
name: registry-intl.cn-hongkong.aliyuncs.com/gkci/kaniko-warmer:debug
|
|
86
|
+
entrypoint: [""]
|
|
87
|
+
before_script:
|
|
88
|
+
- echo "$DOCKER_AUTH_CONFIG" > /kaniko/.docker/config.json
|
|
89
|
+
script:
|
|
90
|
+
- warmer `cat $CI_PROJECT_DIR/Dockerfile | grep FROM | awk -F" " '{ printf("--image=%s ", $2) }'`
|
|
91
|
+
rules:
|
|
92
|
+
# NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
|
|
93
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
|
|
94
|
+
when: never
|
|
95
|
+
# Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
|
|
96
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
97
|
+
# Commit into default branch (master)
|
|
98
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
99
|
+
|
|
100
|
+
run-build:
|
|
101
|
+
stage: build
|
|
102
|
+
image:
|
|
103
|
+
name: registry-intl.cn-hongkong.aliyuncs.com/gkci/kaniko-executor:debug
|
|
104
|
+
entrypoint: [""]
|
|
105
|
+
artifacts:
|
|
106
|
+
paths:
|
|
107
|
+
- image-digest.txt
|
|
108
|
+
before_script:
|
|
109
|
+
- echo "$DOCKER_AUTH_CONFIG" > /kaniko/.docker/config.json
|
|
110
|
+
script:
|
|
111
|
+
- echo "BUILDING... `cat $CI_PROJECT_DIR/image-tag.txt`"
|
|
112
|
+
- 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
|
|
113
|
+
- echo -n 'LABEL DEPENDENCY='; cat $CI_PROJECT_DIR/dep.txt
|
|
114
|
+
- executor --cache=true --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`"
|
|
115
|
+
- echo "PUSHED `cat $CI_PROJECT_DIR/image-tag.txt` (`cat $CI_PROJECT_DIR/image-digest.txt`)"
|
|
116
|
+
rules:
|
|
117
|
+
# NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
|
|
118
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
|
|
119
|
+
when: never
|
|
120
|
+
# Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
|
|
121
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
122
|
+
# Commit into default branch (master)
|
|
123
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
124
|
+
|
|
125
|
+
run-build-commit:
|
|
126
|
+
stage: build-commit
|
|
127
|
+
image: registry-intl.cn-hongkong.aliyuncs.com/gkci/node:10.20.0-alpine-ci-1
|
|
128
|
+
before_script:
|
|
129
|
+
- git config --global user.name "$GITLAB_USER_NAME"
|
|
130
|
+
- git config --global user.email "$GITLAB_USER_EMAIL"
|
|
131
|
+
script:
|
|
132
|
+
- git add -A
|
|
133
|
+
- git commit -m "$(make version)" -m "== release-by-bot ($CI_COMMIT_SHA) =="
|
|
134
|
+
- git tag -a "$(make version)" -m "$(cat image-tag.txt) ($(cat image-digest.txt))"
|
|
135
|
+
- git push "https://${GITLAB_USER_NAME}:${CI_GIT_TOKEN}@${CI_REPOSITORY_URL#*@}" "HEAD:${CI_COMMIT_BRANCH}"
|
|
136
|
+
- git push "https://${GITLAB_USER_NAME}:${CI_GIT_TOKEN}@${CI_REPOSITORY_URL#*@}" --tags
|
|
137
|
+
rules:
|
|
138
|
+
# NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
|
|
139
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
|
|
140
|
+
when: never
|
|
141
|
+
# Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
|
|
142
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
143
|
+
# Commit into default branch (master)
|
|
144
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
145
|
+
|
|
146
|
+
run-release:
|
|
147
|
+
stage: release
|
|
148
|
+
image: registry-intl.cn-hongkong.aliyuncs.com/gkci/node:10.20.0-alpine-ci-1
|
|
149
|
+
script:
|
|
150
|
+
- echo "Bumped version $(make version)"
|
|
151
|
+
rules:
|
|
152
|
+
# NOT commit message contains `run-without-release` keyword and NOT merge request
|
|
153
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
154
|
+
when: never
|
|
155
|
+
# Tag was created
|
|
156
|
+
- if: '$CI_COMMIT_TAG != null'
|
|
157
|
+
|
|
158
|
+
run-notify:
|
|
159
|
+
stage: notify
|
|
160
|
+
image: registry-intl.cn-hongkong.aliyuncs.com/gkci/node:10.20.0-alpine-ci-1
|
|
161
|
+
before_script:
|
|
162
|
+
- apk --no-cache add curl
|
|
163
|
+
script:
|
|
164
|
+
- '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'
|
|
165
|
+
rules:
|
|
166
|
+
# NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
|
|
167
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
|
|
168
|
+
when: never
|
|
169
|
+
- if: '$TELEGRAM_BOT_TOKEN == null || $TELEGRAM_BOT_TOKEN == "" || $TELEGRAM_CHAT_ID == null || $TELEGRAM_CHAT_ID == ""'
|
|
170
|
+
when: never
|
|
171
|
+
# Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
|
|
172
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
173
|
+
# Commit into default branch (master)
|
|
174
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v16.14.2
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
FROM node:16.14.2-alpine3.15 AS builder
|
|
2
|
+
WORKDIR /app/
|
|
3
|
+
ADD ./package.json /app/
|
|
4
|
+
ADD ./package-lock.json /app/
|
|
5
|
+
ADD ./tsconfig.json /app/
|
|
6
|
+
ADD ./tsconfig.build.json /app/
|
|
7
|
+
ADD ./src /app/src
|
|
8
|
+
RUN npm install glob rimraf
|
|
9
|
+
RUN npm install --only=development
|
|
10
|
+
COPY . .
|
|
11
|
+
RUN npm run build
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
FROM node:16.14.2-alpine3.15
|
|
15
|
+
WORKDIR /app/
|
|
16
|
+
COPY package*.json ./
|
|
17
|
+
COPY --from=builder /app/dist /app/dist
|
|
18
|
+
RUN npm install --only=production
|
|
19
|
+
CMD ["npm", "run", "start:prod"]
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
|
|
2
|
+
ROOT_PATH := $(shell pwd)
|
|
3
|
+
SERVICE_NAME := <%= projectName %>
|
|
4
|
+
|
|
5
|
+
.PHONY: version name image
|
|
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
|
+
@npm i
|
|
55
|
+
@npm run -s 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;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# <%= projectName %>
|
|
2
|
+
|
|
3
|
+
### Getting Started
|
|
4
|
+
|
|
5
|
+
The <%= projectName %> API endpoints.
|
|
6
|
+
|
|
7
|
+
### How to setup environment?
|
|
8
|
+
|
|
9
|
+
1. Clone this repository.
|
|
10
|
+
|
|
11
|
+
2. Change directory to the repository.
|
|
12
|
+
|
|
13
|
+
3. Install package dependencies.
|
|
14
|
+
```
|
|
15
|
+
npm install
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### How to run unit-test?
|
|
19
|
+
|
|
20
|
+
1. Write test cases in a `*.test.ts` file under the same folder with the actual module file. For example, module file `src/app-service.ts`, unit-test file `src/app-service.test.ts`.
|
|
21
|
+
|
|
22
|
+
2. Run unit-test command.
|
|
23
|
+
|
|
24
|
+
- To run single module unit-test.
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
npm run test-this src/app-service.test.ts
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
- To run all unit-test.
|
|
31
|
+
```
|
|
32
|
+
npm run test
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### How to debug?
|
|
36
|
+
|
|
37
|
+
Please use unit-test method for debugging.
|
|
38
|
+
|
|
39
|
+
1. Set breakpoint on the source code by pressing `F9` key.
|
|
40
|
+
|
|
41
|
+
2. Run unit-test command with debugging.
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
npm run debug-this src/app-service.test.ts
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
3. Start debugging by pressing `F5` key.
|
|
48
|
+
|
|
49
|
+
### How to release version?
|
|
50
|
+
|
|
51
|
+
Git pipeline will perform unit-test, build container image and push to the container registry.
|
|
52
|
+
|
|
53
|
+
- Bump a `prerelease` version (E.g. `1.0.0-rc.0`).
|
|
54
|
+
|
|
55
|
+
- Write commit message that contain `run-prerelease` keyword to `feature` branch.
|
|
56
|
+
|
|
57
|
+
- Bump a `release` version (E.g. `1.0.0`).
|
|
58
|
+
|
|
59
|
+
- Merge into `default` branch (main/master) with any commit message.
|
|
60
|
+
|
|
61
|
+
> Note: **Code review** process should be perform before merge into `default` branch or release version.
|
|
62
|
+
|
|
63
|
+
### Merge into default branch without trigger pipeline
|
|
64
|
+
|
|
65
|
+
If you want to merge into `default` branch without triggering the pipeline, write commit message that contain `run-without-release`.
|
|
66
|
+
|
|
67
|
+
chatbot: 0
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= projectName %>",
|
|
3
|
+
"version": "1.0.0-rc.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"author": "",
|
|
6
|
+
"private": true,
|
|
7
|
+
"license": "UNLICENSED",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "nest build",
|
|
10
|
+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
11
|
+
"start": "nest start",
|
|
12
|
+
"start:dev": "nest start --watch",
|
|
13
|
+
"start:debug": "nest start --debug --watch",
|
|
14
|
+
"start:prod": "node dist/main",
|
|
15
|
+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
|
16
|
+
"test": "jest",
|
|
17
|
+
"test:watch": "jest --watch",
|
|
18
|
+
"test:cov": "jest --coverage",
|
|
19
|
+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
20
|
+
"test:e2e": "jest --config ./test/jest-e2e.json"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@nathapp/common": "^0.1.10",
|
|
24
|
+
"@nathapp/nestjs-common": "^1.0.1-rc.0",
|
|
25
|
+
"@nestjs/common": "^9.0.0",
|
|
26
|
+
"@nestjs/config": "^2.3.1",
|
|
27
|
+
"@nestjs/core": "^9.0.0",
|
|
28
|
+
"@nestjs/platform-express": "^9.0.0",
|
|
29
|
+
"@nestjs/swagger": "^6.2.1",
|
|
30
|
+
"class-transformer": "^0.5.1",
|
|
31
|
+
"class-validator": "^0.14.0",
|
|
32
|
+
"reflect-metadata": "^0.1.13",
|
|
33
|
+
"rxjs": "^7.2.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@nestjs/cli": "^9.0.0",
|
|
37
|
+
"@nestjs/schematics": "^9.0.0",
|
|
38
|
+
"@nestjs/testing": "^9.0.0",
|
|
39
|
+
"@types/express": "^4.17.13",
|
|
40
|
+
"@types/jest": "29.2.4",
|
|
41
|
+
"@types/node": "18.11.18",
|
|
42
|
+
"@types/supertest": "^2.0.11",
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
44
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
45
|
+
"eslint": "^8.0.1",
|
|
46
|
+
"eslint-config-prettier": "^8.3.0",
|
|
47
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
48
|
+
"jest": "29.3.1",
|
|
49
|
+
"prettier": "^2.3.2",
|
|
50
|
+
"source-map-support": "^0.5.20",
|
|
51
|
+
"supertest": "^6.1.3",
|
|
52
|
+
"ts-jest": "29.0.3",
|
|
53
|
+
"ts-loader": "^9.2.3",
|
|
54
|
+
"ts-node": "^10.0.0",
|
|
55
|
+
"tsconfig-paths": "4.1.1",
|
|
56
|
+
"typescript": "^4.7.4"
|
|
57
|
+
},
|
|
58
|
+
"jest": {
|
|
59
|
+
"moduleFileExtensions": [
|
|
60
|
+
"js",
|
|
61
|
+
"json",
|
|
62
|
+
"ts"
|
|
63
|
+
],
|
|
64
|
+
"rootDir": "src",
|
|
65
|
+
"testRegex": ".*\\.spec\\.ts$",
|
|
66
|
+
"transform": {
|
|
67
|
+
"^.+\\.(t|j)s$": "ts-jest"
|
|
68
|
+
},
|
|
69
|
+
"collectCoverageFrom": [
|
|
70
|
+
"**/*.(t|j)s"
|
|
71
|
+
],
|
|
72
|
+
"coverageDirectory": "../coverage",
|
|
73
|
+
"testEnvironment": "node"
|
|
74
|
+
}
|
|
75
|
+
}
|