@nathapp/na-cli 1.0.7 → 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.
- package/dist/templates/db-schema/.gitlab-ci.yml +139 -0
- package/dist/templates/db-schema/Makefile +885 -0
- package/dist/templates/k8s-deployment/.gitlab-ci.yml +158 -0
- package/dist/templates/k8s-deployment/Makefile +233 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/script/Makefile +12 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/script/Makefile +8 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/script/Makefile +56 -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-js/script/Makefile +14 -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/t-0200-start.ts +172 -0
- package/dist/templates/nestjs-api/.dockerignore +9 -0
- package/dist/templates/nestjs-api/.env +31 -0
- package/dist/templates/nestjs-api/.gitignore-rename +1 -0
- package/dist/templates/nestjs-api/.gitlab-ci.yml +180 -0
- package/dist/templates/nestjs-api/.nvmrc +1 -0
- package/dist/templates/nestjs-api/.oxlintrc.json +18 -0
- package/dist/templates/nestjs-api/.prettierrc +4 -0
- package/dist/templates/nestjs-api/Dockerfile +15 -21
- package/dist/templates/nestjs-api/Makefile +95 -0
- package/dist/templates/nestjs-api/README.md +22 -30
- package/dist/templates/nestjs-api/nest-cli.json +10 -0
- package/dist/templates/nestjs-api/ormconfig.ts +18 -0
- package/dist/templates/nestjs-api/package.json +58 -72
- package/dist/templates/nestjs-api/src/app.controller.spec.ts +24 -0
- package/dist/templates/nestjs-api/src/app.controller.ts +27 -0
- package/dist/templates/nestjs-api/src/app.module.ts +31 -0
- package/dist/templates/nestjs-api/src/app.service.ts +27 -0
- package/dist/templates/nestjs-api/src/main.ts +31 -0
- package/dist/templates/nestjs-api/test/app.e2e-spec.ts +47 -0
- package/dist/templates/nestjs-api/tsconfig.build.json +5 -0
- package/dist/templates/nestjs-api/tsconfig.json +28 -0
- package/dist/templates/nestjs-api/tsconfig.spec.json +9 -0
- package/dist/templates/nestjs-api/vitest.config.mts +33 -0
- package/dist/templates/nestjs-library/.gitignore-rename +1 -0
- package/dist/templates/nestjs-library/.gitlab-ci.yml +134 -0
- package/dist/templates/nestjs-library/.npmignore-rename +5 -2
- package/dist/templates/nestjs-library/.nvmrc +1 -0
- package/dist/templates/nestjs-library/.oxlintrc.json +18 -0
- package/dist/templates/nestjs-library/.prettierrc +6 -0
- package/dist/templates/nestjs-library/Makefile +60 -0
- package/dist/templates/nestjs-library/README.md +24 -0
- package/dist/templates/nestjs-library/lib/index.ts +2 -0
- package/dist/templates/nestjs-library/package.json +43 -33
- package/dist/templates/nestjs-library/test/app/controller/hello.controller.spec.ts +20 -0
- package/dist/templates/nestjs-library/test/app/controller/hello.controller.ts +7 -0
- package/dist/templates/nestjs-library/tsconfig.build.json +8 -0
- package/dist/templates/nestjs-library/tsconfig.json +21 -0
- package/dist/templates/nestjs-library/tsconfig.spec.json +9 -0
- package/dist/templates/nestjs-library/vitest.config.mts +29 -0
- package/dist/templates/ts-library/.dockerignore +2 -0
- package/dist/templates/ts-library/.eslintrc.js +24 -0
- package/dist/templates/ts-library/.gitlab-ci.yml +136 -0
- package/dist/templates/ts-library/.prettierrc +6 -0
- package/dist/templates/ts-library/Makefile +58 -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/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/templates/turbo-nestjs-vuexy/.dockerignore +2 -0
- package/dist/templates/turbo-nestjs-vuexy/.gitignore-rename +40 -0
- package/dist/templates/turbo-nestjs-vuexy/.npmrc-rename +0 -0
- package/dist/templates/turbo-nestjs-vuexy/Makefile +48 -0
- package/dist/templates/vuexy-portal/.dockerignore +2 -0
- package/dist/templates/vuexy-portal/.env +1 -0
- package/dist/templates/vuexy-portal/.gitlab-ci.yml +233 -0
- package/dist/templates/vuexy-portal/.npmrc-rename +2 -0
- package/dist/templates/vuexy-portal/.nvmrc +1 -0
- package/dist/templates/vuexy-portal/Makefile +55 -0
- package/dist/templates/vuexy-portal/src/@core/composable/createUrl.ts +20 -0
- package/dist/templates/vuexy-portal/src/@core/composable/useCookie.ts +43 -0
- package/dist/templates/vuexy-portal/src/@core/composable/useGenerateImageVariant.ts +25 -0
- package/dist/templates/vuexy-portal/src/@core/composable/useResponsiveSidebar.ts +29 -0
- package/dist/templates/vuexy-portal/src/@core/composable/useSkins.ts +42 -0
- package/dist/templates/vuexy-portal/src/@core/enums.ts +21 -0
- package/dist/templates/vuexy-portal/src/@core/index.ts +43 -0
- package/dist/templates/vuexy-portal/src/@core/initCore.ts +93 -0
- package/dist/templates/vuexy-portal/src/@core/libs/apex-chart/apexCharConfig.ts +701 -0
- package/dist/templates/vuexy-portal/src/@core/libs/chartjs/chartjsConfig.ts +372 -0
- package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/BarChart.ts +58 -0
- package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/BubbleChart.ts +58 -0
- package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/DoughnutChart.ts +58 -0
- package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/LineChart.ts +58 -0
- package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/PolarAreaChart.ts +58 -0
- package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/RadarChart.ts +58 -0
- package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/ScatterChart.ts +58 -0
- package/dist/templates/vuexy-portal/src/@core/stores/config.ts +80 -0
- package/dist/templates/vuexy-portal/src/@core/types.ts +49 -0
- package/dist/templates/vuexy-portal/src/@core/utils/formatters.ts +48 -0
- package/dist/templates/vuexy-portal/src/@core/utils/helpers.ts +32 -0
- package/dist/templates/vuexy-portal/src/@core/utils/plugins.ts +53 -0
- package/dist/templates/vuexy-portal/src/@core/utils/validators.ts +105 -0
- package/dist/templates/vuexy-portal/src/@core/utils/vuetify.ts +13 -0
- package/dist/templates/vuexy-portal/src/@custom/composables/toasts.ts +45 -0
- package/dist/templates/vuexy-portal/src/@custom/composables/validator.ts +160 -0
- package/dist/templates/vuexy-portal/src/@custom/enums/index.ts +0 -0
- package/dist/templates/vuexy-portal/src/@custom/types/common.ts +17 -0
- package/dist/templates/vuexy-portal/src/@custom/types/index.ts +0 -0
- package/dist/templates/vuexy-portal/src/@custom/types/pagination.ts +19 -0
- package/dist/templates/vuexy-portal/src/@custom/types/user.ts +5 -0
- package/dist/templates/vuexy-portal/src/@custom/utils/formatters.ts +83 -0
- package/dist/templates/vuexy-portal/src/@custom/utils/index.ts +0 -0
- package/dist/templates/vuexy-portal/src/@custom/utils/validators.ts +51 -0
- package/dist/templates/vuexy-portal/src/@layouts/components.ts +11 -0
- package/dist/templates/vuexy-portal/src/@layouts/config.ts +43 -0
- package/dist/templates/vuexy-portal/src/@layouts/enums.ts +27 -0
- package/dist/templates/vuexy-portal/src/@layouts/index.ts +49 -0
- package/dist/templates/vuexy-portal/src/@layouts/plugins/casl.ts +48 -0
- package/dist/templates/vuexy-portal/src/@layouts/stores/config.ts +115 -0
- package/dist/templates/vuexy-portal/src/@layouts/symbols.ts +1 -0
- package/dist/templates/vuexy-portal/src/@layouts/types.ts +126 -0
- package/dist/templates/vuexy-portal/src/@layouts/utils.ts +180 -0
- package/dist/templates/vuexy-portal/src/api/api.ts +1 -0
- package/dist/templates/vuexy-portal/src/api/commonApi.ts +25 -0
- package/dist/templates/vuexy-portal/src/api/index.ts +58 -0
- package/dist/templates/vuexy-portal/src/api/requestInterceptor.ts +21 -0
- package/dist/templates/vuexy-portal/src/api/responseInterceptor.ts +52 -0
- package/dist/templates/vuexy-portal/src/api/types.ts +14 -0
- package/dist/templates/vuexy-portal/src/api/useApi.ts +68 -0
- package/dist/templates/vuexy-portal/src/api/useFetchApi.ts +41 -0
- package/dist/templates/vuexy-portal/src/api/userApi.ts +11 -0
- package/dist/templates/vuexy-portal/src/composables/useApiFetch.ts +48 -0
- package/dist/templates/vuexy-portal/src/composables/useJwt.ts +108 -0
- package/dist/templates/vuexy-portal/src/main.ts +17 -0
- package/dist/templates/vuexy-portal/src/navigation/horizontal/index.ts +5 -0
- package/dist/templates/vuexy-portal/src/navigation/index.ts +7 -0
- package/dist/templates/vuexy-portal/src/navigation/vertical/index.ts +5 -0
- package/dist/templates/vuexy-portal/src/plugins/1.router/additional-routes.ts +23 -0
- package/dist/templates/vuexy-portal/src/plugins/1.router/guards.ts +50 -0
- package/dist/templates/vuexy-portal/src/plugins/1.router/index.ts +45 -0
- package/dist/templates/vuexy-portal/src/plugins/2.pinia.ts +8 -0
- package/dist/templates/vuexy-portal/src/plugins/casl/ability.ts +10 -0
- package/dist/templates/vuexy-portal/src/plugins/casl/composables/useAbility.ts +4 -0
- package/dist/templates/vuexy-portal/src/plugins/casl/index.ts +14 -0
- package/dist/templates/vuexy-portal/src/plugins/i18n/index.ts +29 -0
- package/dist/templates/vuexy-portal/src/plugins/iconify/build-icons.ts +299 -0
- package/dist/templates/vuexy-portal/src/plugins/iconify/index.ts +5 -0
- package/dist/templates/vuexy-portal/src/plugins/layouts.ts +13 -0
- package/dist/templates/vuexy-portal/src/plugins/toast/index.ts +9 -0
- package/dist/templates/vuexy-portal/src/plugins/vuetify/defaults.ts +192 -0
- package/dist/templates/vuexy-portal/src/plugins/vuetify/icons.ts +84 -0
- package/dist/templates/vuexy-portal/src/plugins/vuetify/index.ts +47 -0
- package/dist/templates/vuexy-portal/src/plugins/vuetify/theme.ts +155 -0
- package/dist/templates/vuexy-portal/src/plugins/webfontloader.ts +19 -0
- package/dist/templates/vuexy-portal/src/stores/auth.ts +22 -0
- package/dist/templates/vuexy-portal/src/stores/common.ts +41 -0
- package/dist/templates/vuexy-portal/src/stores/index.ts +0 -0
- package/dist/templates/vuexy-portal/src/utils/constants.ts +3 -0
- package/dist/templates/vuexy-portal/src/utils/paginationMeta.ts +10 -0
- package/dist/templates/vuexy-portal/themeConfig.ts +66 -0
- package/dist/templates/vuexy-portal/tsconfig.json +86 -0
- package/dist/templates/vuexy-portal/vite.config.ts +111 -0
- package/dist/utils/template.js +2 -0
- package/dist/utils/template.js.map +1 -1
- package/package.json +4 -1
- package/alias-script.sh +0 -30
- package/bunfig.toml +0 -3
- package/dist/templates/nestjs-api/test/jest-e2e.json +0 -12
- package/dist/templates/nestjs-api/test/jest-test.json +0 -26
- package/dist/templates/nestjs-library/test/jest-test.json +0 -23
- package/nax/config.json +0 -23
- package/nax/features/enhancements/prd.json +0 -61
|
@@ -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,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,33 @@
|
|
|
1
|
+
import swc from 'unplugin-swc';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { defineConfig } from 'vitest/config';
|
|
4
|
+
|
|
5
|
+
// Nest DI reads `design:paramtypes`, which Vite's default transform does not emit,
|
|
6
|
+
// so specs are compiled with SWC (legacy decorators + decorator metadata).
|
|
7
|
+
const swcPlugin = swc.vite({
|
|
8
|
+
module: { type: 'es6' },
|
|
9
|
+
jsc: {
|
|
10
|
+
target: 'es2022',
|
|
11
|
+
parser: { syntax: 'typescript', decorators: true },
|
|
12
|
+
transform: { legacyDecorator: true, decoratorMetadata: true },
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export default defineConfig({
|
|
17
|
+
plugins: [swcPlugin],
|
|
18
|
+
resolve: {
|
|
19
|
+
alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) },
|
|
20
|
+
},
|
|
21
|
+
test: {
|
|
22
|
+
globals: true,
|
|
23
|
+
environment: 'node',
|
|
24
|
+
include: ['src/**/*.spec.ts', 'test/**/*.e2e-spec.ts'],
|
|
25
|
+
exclude: ['**/node_modules/**', '**/dist/**'],
|
|
26
|
+
coverage: {
|
|
27
|
+
provider: 'v8',
|
|
28
|
+
include: ['src/**/*.ts'],
|
|
29
|
+
exclude: ['src/**/*.spec.ts', 'src/main.ts'],
|
|
30
|
+
reportsDirectory: './coverage',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
stages:
|
|
2
|
+
- test
|
|
3
|
+
# run test cases
|
|
4
|
+
- prepare
|
|
5
|
+
- build
|
|
6
|
+
- build-commit
|
|
7
|
+
- release
|
|
8
|
+
- notify
|
|
9
|
+
|
|
10
|
+
run-test:
|
|
11
|
+
stage: test
|
|
12
|
+
image:
|
|
13
|
+
name: nathapp/node-bun:24.22.0-1.4.3-alpine-ci
|
|
14
|
+
script:
|
|
15
|
+
- make test
|
|
16
|
+
rules:
|
|
17
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/'
|
|
18
|
+
when: never
|
|
19
|
+
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
20
|
+
- if: '$CI_COMMIT_REF_PROTECTED == "true"'
|
|
21
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-test/'
|
|
22
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
23
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-release/ && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
24
|
+
# NOT triggerred by bot
|
|
25
|
+
# merge request
|
|
26
|
+
# commit to protected branch
|
|
27
|
+
# commit message contains `run-test` keyword
|
|
28
|
+
# commit message contains `run-prerelease` keyword and commit branch is nott default branch (master)
|
|
29
|
+
# commit message contains `run-release` keyword and commit branch is default branch (master)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
run-pre-prepare:
|
|
33
|
+
stage: prepare
|
|
34
|
+
image: nathapp/node-bun:24.22.0-1.4.3-alpine-ci
|
|
35
|
+
artifacts:
|
|
36
|
+
paths:
|
|
37
|
+
- package.json
|
|
38
|
+
script:
|
|
39
|
+
- make version-prerelease
|
|
40
|
+
rules:
|
|
41
|
+
# NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
|
|
42
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
|
|
43
|
+
when: never
|
|
44
|
+
# Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
|
|
45
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
46
|
+
|
|
47
|
+
run-prepare:
|
|
48
|
+
stage: prepare
|
|
49
|
+
image: nathapp/node-bun:24.22.0-1.4.3-alpine-ci
|
|
50
|
+
artifacts:
|
|
51
|
+
paths:
|
|
52
|
+
- package.json
|
|
53
|
+
script:
|
|
54
|
+
- make version-patch
|
|
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 into default branch (master)
|
|
60
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
run-build:
|
|
64
|
+
stage: build
|
|
65
|
+
image:
|
|
66
|
+
name: nathapp/node-bun:24.22.0-1.4.3-alpine-ci
|
|
67
|
+
before_script:
|
|
68
|
+
- bun install --frozen-lockfile
|
|
69
|
+
- npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
|
|
70
|
+
script:
|
|
71
|
+
- make build
|
|
72
|
+
- make release
|
|
73
|
+
|
|
74
|
+
rules:
|
|
75
|
+
# NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
|
|
76
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
|
|
77
|
+
when: never
|
|
78
|
+
# Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
|
|
79
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
80
|
+
# Commit into default branch (master)
|
|
81
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
run-build-commit:
|
|
85
|
+
stage: build-commit
|
|
86
|
+
image: nathapp/node-bun:24.22.0-1.4.3-alpine-ci
|
|
87
|
+
before_script:
|
|
88
|
+
- git config --global user.name "$GITLAB_USER_NAME"
|
|
89
|
+
- git config --global user.email "$GITLAB_USER_EMAIL"
|
|
90
|
+
script:
|
|
91
|
+
- git add -A
|
|
92
|
+
- git commit -m "$(make version)" -m "== release-by-bot ($CI_COMMIT_SHA) =="
|
|
93
|
+
- git tag -a "$(make version)" -m "$(cat image-tag.txt) ($(cat image-digest.txt))"
|
|
94
|
+
- git push "https://${GITLAB_USER_NAME}:${CI_GIT_TOKEN}@${CI_REPOSITORY_URL#*@}" "HEAD:${CI_COMMIT_BRANCH}"
|
|
95
|
+
- git push "https://${GITLAB_USER_NAME}:${CI_GIT_TOKEN}@${CI_REPOSITORY_URL#*@}" --tags
|
|
96
|
+
rules:
|
|
97
|
+
# NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
|
|
98
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
|
|
99
|
+
when: never
|
|
100
|
+
# Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
|
|
101
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
102
|
+
# Commit into default branch (master)
|
|
103
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
104
|
+
|
|
105
|
+
run-release:
|
|
106
|
+
stage: release
|
|
107
|
+
image: nathapp/node-bun:24.22.0-1.4.3-alpine-ci
|
|
108
|
+
script:
|
|
109
|
+
- echo "Bumped version $(make version)"
|
|
110
|
+
rules:
|
|
111
|
+
# NOT commit message contains `run-without-release` keyword and NOT merge request
|
|
112
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
113
|
+
when: never
|
|
114
|
+
# Tag was created
|
|
115
|
+
- if: '$CI_COMMIT_TAG != null'
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
run-notify:
|
|
119
|
+
stage: notify
|
|
120
|
+
image: nathapp/node-bun:24.22.0-1.4.3-alpine-ci
|
|
121
|
+
before_script:
|
|
122
|
+
- apk --no-cache add curl
|
|
123
|
+
script:
|
|
124
|
+
- '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'
|
|
125
|
+
rules:
|
|
126
|
+
# NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
|
|
127
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
|
|
128
|
+
when: never
|
|
129
|
+
- if: '$TELEGRAM_BOT_TOKEN == null || $TELEGRAM_BOT_TOKEN == "" || $TELEGRAM_CHAT_ID == null || $TELEGRAM_CHAT_ID == ""'
|
|
130
|
+
when: never
|
|
131
|
+
# Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
|
|
132
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
133
|
+
# Commit into default branch (master)
|
|
134
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
@@ -16,13 +16,15 @@ nodemon-debug.json
|
|
|
16
16
|
package-lock.json
|
|
17
17
|
tsconfig.json
|
|
18
18
|
tsconfig.spec.json
|
|
19
|
+
vitest.config.mts
|
|
20
|
+
.oxlintrc.json
|
|
19
21
|
tsconfig.build.json
|
|
20
22
|
tslint.json
|
|
21
23
|
webpack.config.js
|
|
22
24
|
yarn.lock
|
|
23
25
|
bun.lockb
|
|
26
|
+
bun.lock
|
|
24
27
|
README.md
|
|
25
|
-
.eslintrc.js
|
|
26
28
|
.dockerignore
|
|
27
29
|
|
|
28
30
|
.npmrc
|
|
@@ -31,4 +33,5 @@ README.md
|
|
|
31
33
|
Makefile
|
|
32
34
|
|
|
33
35
|
.npm/
|
|
34
|
-
test/
|
|
36
|
+
test/
|
|
37
|
+
coverage/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v22.22.2
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
3
|
+
"plugins": ["typescript", "oxc"],
|
|
4
|
+
"categories": {
|
|
5
|
+
"correctness": "error"
|
|
6
|
+
},
|
|
7
|
+
"env": {
|
|
8
|
+
"node": true,
|
|
9
|
+
"es2022": true,
|
|
10
|
+
"vitest": true
|
|
11
|
+
},
|
|
12
|
+
"ignorePatterns": ["dist/", "node_modules/", "coverage/"],
|
|
13
|
+
"rules": {
|
|
14
|
+
"typescript/no-explicit-any": "off",
|
|
15
|
+
"typescript/explicit-module-boundary-types": "off",
|
|
16
|
+
"no-unused-vars": "off"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
|
|
2
|
+
ROOT_PATH := $(shell pwd)
|
|
3
|
+
SERVICE_NAME := <%= projectName %>
|
|
4
|
+
|
|
5
|
+
.PHONY: test build release
|
|
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
|
+
test:
|
|
51
|
+
@bun install --frozen-lockfile
|
|
52
|
+
@bun run test
|
|
53
|
+
|
|
54
|
+
build:
|
|
55
|
+
@bun run build
|
|
56
|
+
|
|
57
|
+
release:
|
|
58
|
+
@npm publish --access public
|
|
59
|
+
|
|
60
|
+
|
|
@@ -1,3 +1,27 @@
|
|
|
1
1
|
# <%= projectName %> Library
|
|
2
2
|
|
|
3
|
+
NestJS library (NestJS 10-12 as peers). Source lives in `lib/`, compiled output in `dist/`.
|
|
3
4
|
|
|
5
|
+
Requires Node >= 22.12 (see `.nvmrc`) and Bun.
|
|
6
|
+
|
|
7
|
+
## Development
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
bun install
|
|
11
|
+
bun run build
|
|
12
|
+
bun run lint
|
|
13
|
+
bun run type-check
|
|
14
|
+
bun run type-check:spec
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Tests
|
|
18
|
+
|
|
19
|
+
Specs are `lib/**/*.spec.ts` and `test/**/*.spec.ts`, run with Vitest (`vi` for mocks, `createMock` from `@golevelup/ts-vitest`).
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
bun run test
|
|
23
|
+
bun run test:cov
|
|
24
|
+
bun run test:watch
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`test/app/` holds a throwaway Nest app for exercising the library end to end.
|
|
@@ -3,48 +3,58 @@
|
|
|
3
3
|
"version": "1.0.0-rc.0",
|
|
4
4
|
"description": "<%= projectName %>",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"test
|
|
11
|
-
"
|
|
6
|
+
"clean": "rimraf dist/ coverage/",
|
|
7
|
+
"build": "rimraf dist && tsc -p tsconfig.build.json",
|
|
8
|
+
"type-check": "tsc --noEmit -p tsconfig.build.json",
|
|
9
|
+
"type-check:spec": "tsc -p tsconfig.spec.json",
|
|
10
|
+
"test": "vitest run --passWithNoTests",
|
|
11
|
+
"test:cov": "vitest run --coverage --passWithNoTests",
|
|
12
|
+
"test:watch": "vitest",
|
|
13
|
+
"lint": "oxlint lib test --max-warnings=0",
|
|
14
|
+
"lint:fix": "oxlint lib test --fix",
|
|
15
|
+
"format": "prettier --write \"lib/**/*.ts\" \"test/**/*.ts\""
|
|
12
16
|
},
|
|
13
17
|
"author": "<%= author %>",
|
|
14
18
|
"license": "ISC",
|
|
15
19
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
20
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
17
21
|
},
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
"@nestjs/platform-express": "^11.0.0",
|
|
21
|
-
"@nestjs/platform-fastify": "^11.0.0",
|
|
22
|
-
"@nestjs/testing": "^11.0.0",
|
|
23
|
-
"@types/jest": "^29.5.2",
|
|
24
|
-
"@types/node": "18.11.18",
|
|
25
|
-
"@types/supertest": "^2.0.12",
|
|
26
|
-
"@typescript-eslint/eslint-plugin": "^4",
|
|
27
|
-
"@typescript-eslint/parser": "^4",
|
|
28
|
-
"eslint": "*",
|
|
29
|
-
"eslint-config-prettier": "^6",
|
|
30
|
-
"eslint-plugin-prettier": "^3",
|
|
31
|
-
"jest": "^29.5.0",
|
|
32
|
-
"prettier": "^2",
|
|
33
|
-
"supertest": "^6.3.3",
|
|
34
|
-
"ts-jest": "^29.1.0",
|
|
35
|
-
"typescript": "^5"
|
|
36
|
-
},
|
|
37
|
-
"types": "./index.d.ts",
|
|
38
|
-
"main": "index.js",
|
|
22
|
+
"main": "dist/index.js",
|
|
23
|
+
"types": "dist/index.d.ts",
|
|
39
24
|
"directories": {
|
|
40
25
|
"lib": "lib"
|
|
41
26
|
},
|
|
42
27
|
"dependencies": {},
|
|
43
28
|
"peerDependencies": {
|
|
44
|
-
"@nestjs/common": "^
|
|
45
|
-
"@nestjs/core": "^
|
|
29
|
+
"@nestjs/common": "^10.0.0 || ^11.0.0 || ^12.0.0",
|
|
30
|
+
"@nestjs/core": "^10.0.0 || ^11.0.0 || ^12.0.0",
|
|
46
31
|
"class-transformer": "*",
|
|
47
32
|
"class-validator": "*",
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
}
|
|
33
|
+
"reflect-metadata": "^0.1.13 || ^0.2.0",
|
|
34
|
+
"rxjs": "^7.8.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@golevelup/ts-vitest": "^4.0.0",
|
|
38
|
+
"@nestjs/common": "^12.1.3",
|
|
39
|
+
"@nestjs/core": "^12.1.3",
|
|
40
|
+
"@nestjs/platform-express": "^12.1.3",
|
|
41
|
+
"@nestjs/platform-fastify": "^12.1.3",
|
|
42
|
+
"@nestjs/testing": "^12.1.3",
|
|
43
|
+
"@swc/core": "^1.16.13",
|
|
44
|
+
"@types/node": "^22.0.0",
|
|
45
|
+
"@types/supertest": "^7.2.0",
|
|
46
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
47
|
+
"class-transformer": "^0.5.1",
|
|
48
|
+
"class-validator": "^0.14.0",
|
|
49
|
+
"oxlint": "^1.87.0",
|
|
50
|
+
"prettier": "^3.6.0",
|
|
51
|
+
"reflect-metadata": "^0.2.2",
|
|
52
|
+
"rimraf": "^6.0.1",
|
|
53
|
+
"rxjs": "^7.8.2",
|
|
54
|
+
"supertest": "^7.2.2",
|
|
55
|
+
"typescript": "^5.9.0",
|
|
56
|
+
"unplugin-swc": "^2.0.0",
|
|
57
|
+
"vitest": "^4.1.11"
|
|
58
|
+
},
|
|
59
|
+
"packageManager": "bun@1.4.3"
|
|
60
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Test, TestingModule } from "@nestjs/testing";
|
|
2
|
+
import { HelloController } from "./hello.controller";
|
|
3
|
+
|
|
4
|
+
describe("HelloController", () => {
|
|
5
|
+
let module: TestingModule;
|
|
6
|
+
|
|
7
|
+
beforeEach(async () => {
|
|
8
|
+
module = await Test.createTestingModule({
|
|
9
|
+
controllers: [HelloController],
|
|
10
|
+
}).compile();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
afterEach(async () => {
|
|
14
|
+
await module.close();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("resolves from the Nest testing module", () => {
|
|
18
|
+
expect(module.get(HelloController)).toBeInstanceOf(HelloController);
|
|
19
|
+
});
|
|
20
|
+
});
|