Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: various improvements #5

Merged
merged 8 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions .idea/tailwindcss.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
"sourceMap": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.development.ts"
}
]
}
},
"defaultConfiguration": "production"
Expand Down
2 changes: 1 addition & 1 deletion e2e/example.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ test("has title", async ({ page }) => {
await page.goto("/");

// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/StarterAngular19/);
await expect(page).toHaveTitle(/home/i);
});
2 changes: 1 addition & 1 deletion src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppComponent } from "@/app/app.component";
import { ComponentFixture, TestBed } from "@angular/core/testing";
import { AppComponent } from "./app.component";

describe("AppComponent", () => {
let component: AppComponent;
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.config.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { appConfig } from "@/app/app.config";
import { ApplicationConfig, mergeApplicationConfig } from "@angular/core";
import { provideServerRendering } from "@angular/platform-server";
import { appConfig } from "./app.config";

const serverConfig: ApplicationConfig = {
providers: [provideServerRendering()],
Expand Down
14 changes: 11 additions & 3 deletions src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import { ApplicationConfig, provideZoneChangeDetection } from "@angular/core";
import { routes } from "@/app/app.routes";
import { GlobalErrorHandler } from "@/app/global-error-handler";
import {
ApplicationConfig,
ErrorHandler,
provideZoneChangeDetection,
} from "@angular/core";
import {
provideClientHydration,
withEventReplay,
} from "@angular/platform-browser";
import { provideRouter } from "@angular/router";

import { routes } from "./app.routes";

export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes),
provideClientHydration(withEventReplay()),
{
provide: ErrorHandler,
useClass: GlobalErrorHandler,
},
],
};
12 changes: 8 additions & 4 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { Routes } from "@angular/router";
import { HomePageComponent } from "./pages/home-page/home-page.component";
import { NotFoundPageComponent } from "./pages/not-found-page/not-found-page.component";

export const routes: Routes = [
{
path: "",
pathMatch: "full",
component: HomePageComponent,
loadComponent: async () =>
(await import("@/app/pages/home-page/home-page.component"))
.HomePageComponent,
title: "Home",
},
{
path: "**",
component: NotFoundPageComponent,
loadComponent: async () =>
(await import("@/app/pages/not-found-page/not-found-page.component"))
.NotFoundPageComponent,
title: "Not Found",
},
];
11 changes: 11 additions & 0 deletions src/app/global-error-handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ErrorHandler } from "@angular/core";

/**
* Handle uncaught client-side errors.
*/
export class GlobalErrorHandler implements ErrorHandler {
handleError(e: unknown): void {
console.error(e);
alert("An unknown error has occurred. Please try again later.");
}
}
2 changes: 1 addition & 1 deletion src/app/pages/home-page/home-page.component.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p>home-page works!</p>
<p>Deployment successful!</p>
3 changes: 3 additions & 0 deletions src/environments/angular-environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type AngularEnvironment = {
name: "development" | "production";
};
5 changes: 5 additions & 0 deletions src/environments/environment.development.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { AngularEnvironment } from "@/environments/angular-environment";

export const environment: AngularEnvironment = {
name: "development",
};
5 changes: 5 additions & 0 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { AngularEnvironment } from "@/environments/angular-environment";

export const environment: AngularEnvironment = {
name: "production",
};
4 changes: 2 additions & 2 deletions src/main.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AppComponent } from "@/app/app.component";
import { config } from "@/app/app.config.server";
import { bootstrapApplication } from "@angular/platform-browser";
import { AppComponent } from "./app/app.component";
import { config } from "./app/app.config.server";

const bootstrap = () => bootstrapApplication(AppComponent, config);

Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AppComponent } from "@/app/app.component";
import { appConfig } from "@/app/app.config";
import { bootstrapApplication } from "@angular/platform-browser";
import { AppComponent } from "./app/app.component";
import { appConfig } from "./app/app.config";

bootstrapApplication(AppComponent, appConfig).catch((err) =>
console.error(err),
Expand Down
2 changes: 1 addition & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import bootstrap from "@/main.server";
import { APP_BASE_HREF } from "@angular/common";
import { CommonEngine, isMainModule } from "@angular/ssr/node";
import express from "express";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import bootstrap from "./main.server";

const serverDistFolder = dirname(fileURLToPath(import.meta.url));
const browserDistFolder = resolve(serverDistFolder, "../browser");
Expand Down
6 changes: 5 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
"moduleResolution": "bundler",
"importHelpers": true,
"target": "ES2022",
"module": "ES2022"
"module": "ES2022",
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
}
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
Expand Down
Loading