Skip to content

Commit 6d7db1e

Browse files
committed
feat: updated packages
1 parent 7610423 commit 6d7db1e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+439
-39
lines changed

apps/api/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ async function bootstrap() {
1313
const globalPrefix = 'api';
1414
app.setGlobalPrefix(globalPrefix);
1515
app.enableShutdownHooks();
16-
const port = process.env.PORT || 3000;
16+
const port = process.env.PORT || 5000;
1717
await app.listen(port);
1818
Logger.log(
1919
`🚀 Application is running on: http://localhost:${port}/${globalPrefix}`,

apps/app/project.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
"input": "apps/app/public"
2424
}
2525
],
26-
"styles": [
27-
"apps/app/src/styles.scss"
28-
],
26+
"styles": ["apps/app/src/styles.scss"],
27+
"stylePreprocessorOptions": {
28+
"includePaths": ["node_modules/"]
29+
},
2930
"externalDependencies": [
3031
"@nestjs/microservices",
3132
"@nestjs/microservices/microservices-module",
@@ -36,7 +37,9 @@
3637
"class-validator"
3738
],
3839
"scripts": [],
39-
"prerender": true,
40+
"prerender": {
41+
"routesFile": "routes.txt"
42+
},
4043
"ssr": {
4144
"entry": "apps/app/server/server.ts"
4245
}

apps/app/proxy.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"/api": {
3-
"target": "http://localhost:3000",
3+
"target": "http://localhost:5000",
44
"secure": false
55
}
66
}

apps/app/public/robots.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
User-agent: *
2+
Disallow:

apps/app/server/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { AppModule } from '@app/backend-root';
99
import { ExpressAdapter } from '@nestjs/platform-express';
1010

1111
// The Express app is exported so that it can be used by serverless Functions.
12-
export async function app(): Promise<express.Express> {
12+
export async function app() {
1313
const server = express();
1414
const serverDistFolder = dirname(fileURLToPath(import.meta.url));
1515
const browserDistFolder = resolve(serverDistFolder, '../browser');

apps/app/src/index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<title>app</title>
5+
<title>Angular + NestJS example</title>
66
<base href="/" />
7-
<meta name="viewport" content="width=device-width, initial-scale=1" />
87
<link rel="icon" type="image/x-icon" href="favicon.ico" />
8+
<meta name="viewport" content="width=device-width, initial-scale=1" />
9+
<meta name="description" content="Angular + NestJS example" >
10+
<link rel="preconnect" href="https://fonts.gstatic.com" />
911
</head>
10-
<body class="mat-typography">
12+
<body>
1113
<app-root></app-root>
1214
</body>
1315
</html>

apps/app/src/main.server.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ import { RootComponent, config } from '@app/frontend-root';
33
const bootstrap = () => bootstrapApplication(RootComponent, config);
44

55
export default bootstrap;
6-

libs/backend/routes-generator/src/services/routes-generator.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { Injectable } from '@nestjs/common';
33
@Injectable()
44
export class RoutesGeneratorService {
55
generateRoutesTxt() {
6-
return `/home`;
6+
return `/`;
77
}
88
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"extends": ["../../../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts"],
7+
"extends": [
8+
"plugin:@nx/angular",
9+
"plugin:@angular-eslint/template/process-inline-templates"
10+
],
11+
"rules": {
12+
"@angular-eslint/directive-selector": [
13+
"error",
14+
{
15+
"type": "attribute",
16+
"prefix": "lib",
17+
"style": "camelCase"
18+
}
19+
],
20+
"@angular-eslint/component-selector": [
21+
"error",
22+
{
23+
"type": "element",
24+
"prefix": "lib",
25+
"style": "kebab-case"
26+
}
27+
]
28+
}
29+
},
30+
{
31+
"files": ["*.html"],
32+
"extends": ["plugin:@nx/angular-template"],
33+
"rules": {}
34+
}
35+
]
36+
}

libs/frontend/pages/home/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frontend-pages-home
2+
3+
This library was generated with [Nx](https://nx.dev).
4+
5+
## Running unit tests
6+
7+
Run `nx test frontend-pages-home` to execute the unit tests.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'frontend-pages-home',
4+
preset: '../../../../jest.preset.js',
5+
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
6+
coverageDirectory: '../../../../coverage/libs/frontend/pages/home',
7+
transform: {
8+
'^.+\\.(ts|mjs|js|html)$': [
9+
'jest-preset-angular',
10+
{
11+
tsconfig: '<rootDir>/tsconfig.spec.json',
12+
stringifyContentPathRegex: '\\.(html|svg)$',
13+
},
14+
],
15+
},
16+
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
17+
snapshotSerializers: [
18+
'jest-preset-angular/build/serializers/no-ng-attributes',
19+
'jest-preset-angular/build/serializers/ng-snapshot',
20+
'jest-preset-angular/build/serializers/html-comment',
21+
],
22+
};

libs/frontend/pages/home/project.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "frontend-pages-home",
3+
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "libs/frontend/pages/home/src",
5+
"prefix": "lib",
6+
"projectType": "library",
7+
"tags": [],
8+
"targets": {
9+
"test": {
10+
"executor": "@nx/jest:jest",
11+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
12+
"options": {
13+
"jestConfig": "libs/frontend/pages/home/jest.config.ts"
14+
}
15+
},
16+
"lint": {
17+
"executor": "@nx/eslint:lint"
18+
}
19+
}
20+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<p>page-home works!</p>
2+
3+
<pre>{{ exampleFetch() | json }}</pre>

libs/frontend/pages/home/src/components/home/page-home.component.scss

Whitespace-only changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { CommonModule } from '@angular/common';
2+
import { HttpClient } from '@angular/common/http';
3+
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
4+
import { BASE_URL } from '@app/frontend-utils';
5+
import { derivedAsync } from 'ngxtension/derived-async';
6+
7+
@Component({
8+
selector: 'lib-page-home',
9+
standalone: true,
10+
imports: [CommonModule],
11+
templateUrl: './page-home.component.html',
12+
styleUrl: './page-home.component.scss',
13+
changeDetection: ChangeDetectionStrategy.OnPush,
14+
})
15+
export class PageHomeComponent {
16+
private readonly httpClient = inject(HttpClient);
17+
private readonly baseUrl = inject(BASE_URL);
18+
19+
exampleFetch = derivedAsync(() =>
20+
this.httpClient.get(`${this.baseUrl}/api/backend-test`),
21+
);
22+
}

libs/frontend/pages/home/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './lib.routes';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Route } from '@angular/router';
2+
import { PageHomeComponent } from './components/home/page-home.component';
3+
4+
export const pageHomeRoutes: Route[] = [
5+
{ path: '', component: PageHomeComponent },
6+
];
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
2+
globalThis.ngJest = {
3+
testEnvironmentOptions: {
4+
errorOnUnknownElements: true,
5+
errorOnUnknownProperties: true,
6+
},
7+
};
8+
import 'jest-preset-angular/setup-jest';
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2022",
4+
"useDefineForClassFields": false,
5+
"forceConsistentCasingInFileNames": true,
6+
"strict": true,
7+
"noImplicitOverride": true,
8+
"noPropertyAccessFromIndexSignature": true,
9+
"noImplicitReturns": true,
10+
"noFallthroughCasesInSwitch": true
11+
},
12+
"files": [],
13+
"include": [],
14+
"references": [
15+
{
16+
"path": "./tsconfig.lib.json"
17+
},
18+
{
19+
"path": "./tsconfig.spec.json"
20+
}
21+
],
22+
"extends": "../../../../tsconfig.base.json",
23+
"angularCompilerOptions": {
24+
"enableI18nLegacyMessageIdFormat": false,
25+
"strictInjectionParameters": true,
26+
"strictInputAccessModifiers": true,
27+
"strictTemplates": true
28+
}
29+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../../../dist/out-tsc",
5+
"declaration": true,
6+
"declarationMap": true,
7+
"inlineSources": true,
8+
"types": []
9+
},
10+
"exclude": [
11+
"src/**/*.spec.ts",
12+
"src/test-setup.ts",
13+
"jest.config.ts",
14+
"src/**/*.test.ts"
15+
],
16+
"include": ["src/**/*.ts"]
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../../../dist/out-tsc",
5+
"module": "commonjs",
6+
"target": "es2016",
7+
"types": ["jest", "node"]
8+
},
9+
"files": ["src/test-setup.ts"],
10+
"include": [
11+
"jest.config.ts",
12+
"src/**/*.test.ts",
13+
"src/**/*.spec.ts",
14+
"src/**/*.d.ts"
15+
]
16+
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
1+
import { ApplicationConfig, mergeApplicationConfig } from '@angular/core';
2+
import { provideNoopAnimations } from '@angular/platform-browser/animations';
23
import { provideServerRendering } from '@angular/platform-server';
4+
35
import { appConfig } from './app.config';
46

57
const serverConfig: ApplicationConfig = {
6-
providers: [provideServerRendering()],
8+
providers: [provideServerRendering(), provideNoopAnimations()],
79
};
810

911
export const config = mergeApplicationConfig(appConfig, serverConfig);
Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
1-
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
2-
import { provideRouter } from '@angular/router';
1+
import {
2+
ApplicationConfig,
3+
PLATFORM_ID,
4+
provideZoneChangeDetection,
5+
} from '@angular/core';
6+
import { provideRouter, withViewTransitions } from '@angular/router';
37
import { appRoutes } from './app.routes';
4-
import { provideClientHydration } from '@angular/platform-browser';
8+
import {
9+
provideClientHydration,
10+
withHttpTransferCacheOptions,
11+
} from '@angular/platform-browser';
512
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
613
import { provideHttpClient, withFetch } from '@angular/common/http';
14+
import { BASE_URL } from '@app/frontend-utils';
15+
import { isPlatformBrowser } from '@angular/common';
716

817
export const appConfig: ApplicationConfig = {
918
providers: [
10-
provideClientHydration(),
19+
provideClientHydration(
20+
withHttpTransferCacheOptions({
21+
includePostRequests: true,
22+
}),
23+
),
1124
provideZoneChangeDetection({ eventCoalescing: true }),
12-
provideRouter(appRoutes),
25+
provideRouter(appRoutes, withViewTransitions()),
1326
provideAnimationsAsync(),
1427
provideHttpClient(withFetch()),
28+
{
29+
provide: BASE_URL,
30+
useFactory: (platformId: string) => {
31+
if (isPlatformBrowser(platformId)) {
32+
return window.location.origin;
33+
}
34+
return process.env?.['BASE_URL'] || 'http://localhost:4200';
35+
},
36+
deps: [PLATFORM_ID],
37+
},
1538
],
1639
};
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
import { Route } from '@angular/router';
2+
import { pageHomeRoutes } from '@app/frontend-pages-home';
23

3-
export const appRoutes: Route[] = [];
4+
export const appRoutes: Route[] = [
5+
{
6+
path: '',
7+
children: pageHomeRoutes,
8+
},
9+
];
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
<h1>Welcome app!</h1>
1+
<h1>Angular + Nestjs!</h1>
22

3-
<pre>{{ testApiCall() | json }}</pre>
4-
5-
<router-outlet></router-outlet>
3+
<router-outlet></router-outlet>
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
import { provideHttpClient } from '@angular/common/http';
22
import { TestBed } from '@angular/core/testing';
33
import { RootComponent } from './root.component';
4+
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
5+
import { RouterModule } from '@angular/router';
46

57
describe('RootComponent', () => {
68
beforeEach(async () => {
79
await TestBed.configureTestingModule({
810
providers: [provideHttpClient()],
9-
imports: [RootComponent],
11+
imports: [RootComponent, NoopAnimationsModule, RouterModule.forRoot([])],
1012
}).compileComponents();
1113
});
1214

1315
it('should render title', () => {
1416
const fixture = TestBed.createComponent(RootComponent);
1517
fixture.detectChanges();
1618
const compiled = fixture.nativeElement as HTMLElement;
17-
expect(compiled.querySelector('h1')?.textContent).toContain('Welcome app');
19+
expect(compiled.querySelector('h1')?.textContent).toContain(
20+
'Angular + Nestjs!',
21+
);
1822
});
1923
});

0 commit comments

Comments
 (0)