├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ ├── back.yml │ ├── front.yml │ └── npmupdate.yml ├── .gitignore ├── .mvn └── wrapper │ └── maven-wrapper.properties ├── Dockerfile ├── LICENSE ├── README.md ├── front ├── .editorconfig ├── angular.json ├── cypress.config.ts ├── cypress │ ├── e2e │ │ └── spec.cy.ts │ └── tsconfig.json ├── eslint.config.js ├── jest.config.ts ├── package-lock.json ├── package.json ├── proxy.conf.json ├── src │ ├── app │ │ ├── app.component.html │ │ ├── app.component.scss │ │ ├── app.component.spec.ts │ │ ├── app.component.ts │ │ ├── app.config.ts │ │ ├── app.routes.ts │ │ ├── basehref-interceptor.ts │ │ ├── factory │ │ │ └── app-base-href-without-static-provider.factory.ts │ │ ├── first │ │ │ └── components │ │ │ │ └── first │ │ │ │ ├── first.component.html │ │ │ │ ├── first.component.scss │ │ │ │ ├── first.component.spec.ts │ │ │ │ └── first.component.ts │ │ ├── http.service.spec.ts │ │ ├── http.service.ts │ │ └── second │ │ │ └── components │ │ │ └── second │ │ │ ├── second.component.html │ │ │ ├── second.component.scss │ │ │ ├── second.component.spec.ts │ │ │ └── second.component.ts │ ├── assets │ │ ├── .gitkeep │ │ └── test.txt │ ├── favicon.ico │ ├── index.html │ ├── main.ts │ └── styles.scss ├── tsconfig.app.json ├── tsconfig.json └── tsconfig.spec.json ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── mpalourdio │ │ └── html5 │ │ ├── SpringBootAngularHTML5Application.java │ │ ├── api │ │ └── ApiController.java │ │ ├── config │ │ ├── SinglePageAppConfig.java │ │ └── WebSecurityConfig.java │ │ └── frontcontroller │ │ ├── FrontControllerException.java │ │ └── FrontControllerHandler.java └── resources │ ├── application.properties │ └── logback-spring.xml └── test ├── .gitkeep └── java └── com └── mpalourdio └── html5 └── fake └── UselessTest.java /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: mpalourdio 2 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "npm" 4 | directory: "/front" 5 | schedule: 6 | interval: "weekly" 7 | allow: 8 | - dependency-type: "direct" 9 | versioning-strategy: "lockfile-only" 10 | 11 | - package-ecosystem: "maven" 12 | directory: "/" 13 | schedule: 14 | interval: "weekly" 15 | allow: 16 | - dependency-type: "direct" 17 | -------------------------------------------------------------------------------- /.github/workflows/back.yml: -------------------------------------------------------------------------------- 1 | name: back 2 | 3 | on: [ push, pull_request, workflow_dispatch ] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | strategy: 9 | max-parallel: 4 10 | matrix: 11 | java-version: [ 21.x ] 12 | graalvm-version: [ 21 ] 13 | 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v4 17 | 18 | - name: Set up JDK ${{ matrix.java-version }} 19 | uses: actions/setup-java@v4 20 | with: 21 | distribution: 'temurin' 22 | java-version: ${{ matrix.java-version }} 23 | cache: 'maven' 24 | 25 | - name: Run full build 26 | run: ./mvnw clean test -B 27 | 28 | - uses: graalvm/setup-graalvm@v1 29 | with: 30 | distribution: 'liberica' 31 | java-version: ${{ matrix.graalvm-version }} 32 | cache: 'maven' 33 | 34 | - name: GraalVM Compile 35 | run: ./mvnw clean -Pnative native:compile 36 | continue-on-error: true 37 | 38 | -------------------------------------------------------------------------------- /.github/workflows/front.yml: -------------------------------------------------------------------------------- 1 | name: front 2 | 3 | on: [ push, pull_request, workflow_dispatch ] 4 | 5 | env: 6 | FORCE_COLOR: 3 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | strategy: 12 | max-parallel: 4 13 | matrix: 14 | node-version: [ 22.x ] 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v4 18 | 19 | - name: Use Node.js ${{ matrix.node-version }} 20 | uses: actions/setup-node@v4 21 | with: 22 | node-version: ${{ matrix.node-version }} 23 | cache: 'npm' 24 | cache-dependency-path: 'front' 25 | 26 | - name: install, lint, audit, build, test 27 | run: | 28 | cd front 29 | npm ci 30 | npm run lint 31 | npm run audit:prod 32 | npm run e2e 33 | npm run build 34 | npm test 35 | -------------------------------------------------------------------------------- /.github/workflows/npmupdate.yml: -------------------------------------------------------------------------------- 1 | name: npm update 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: '0 0 * * 2' # Every Tuesday at midnight 7 | 8 | env: 9 | FORCE_COLOR: 3 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | strategy: 15 | max-parallel: 4 16 | matrix: 17 | node-version: [ 22.x ] 18 | steps: 19 | - name: Checkout 20 | uses: actions/checkout@v4 21 | 22 | - name: Use Node.js ${{ matrix.node-version }} 23 | uses: actions/setup-node@v4 24 | with: 25 | node-version: ${{ matrix.node-version }} 26 | cache: 'npm' 27 | cache-dependency-path: 'front' 28 | 29 | - name: Run npm update 30 | run: | 31 | cd front && npm update 32 | 33 | - name: Create Pull Request 34 | uses: peter-evans/create-pull-request@v7 35 | with: 36 | token: ${{ secrets.GH_PR_PAT }} 37 | commit-message: "chore: npm update" 38 | committer: 'Michel Palourdio ' 39 | author: 'Michel Palourdio ' 40 | branch: 'npm-update' 41 | delete-branch: 'true' 42 | title: 'chore: npm update' 43 | labels: 'dependencies' 44 | body: '' 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | front/node_modules/ 3 | front/dist 4 | front/coverage/ 5 | front/.angular/cache 6 | front/.sass-cache/ 7 | front/.tmp/ 8 | .idea/ 9 | *.iml 10 | logs 11 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM eclipse-temurin:17-alpine 2 | RUN apk update && apk upgrade && apk add bash 3 | RUN adduser -D -s /bin/bash user && chgrp -R 0 /home/user && chmod -R g=u /home/user 4 | WORKDIR /home/user 5 | COPY target/springbootangularhtml5.jar app.jar 6 | RUN chown user:user app.jar 7 | USER user 8 | ENTRYPOINT ["./app.jar"] 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-2025 mpalourdio 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![back](https://github.com/mpalourdio/SpringBootAngularHTML5/actions/workflows/back.yml/badge.svg)](https://github.com/mpalourdio/SpringBootAngularHTML5/actions/workflows/back.yml) 2 | [![front](https://github.com/mpalourdio/SpringBootAngularHTML5/actions/workflows/front.yml/badge.svg)](https://github.com/mpalourdio/SpringBootAngularHTML5/actions/workflows/front.yml) 3 | 4 | This project is available in **Kotlin** too. Take a look at [this repository](https://github.com/mpalourdio/SpringBootKotlinAngular). 5 | 6 | Spring Boot 3.x and Angular with HTML 5 router 7 | ==================================================== 8 | 9 | This project provides an example of an Angular single page application, served by ``Tomcat``, 10 | configured with the ``html5 router``. Some endpoints have Spring Webflux integration too. 11 | 12 | The [SinglePageAppConfig](src/main/java/com/mpalourdio/html5/config/SinglePageAppConfig.java) makes the magic here. 13 | 14 | The ``base-href`` in configured by the ResourceResolver. It's generated from the value of the application's [context-path](src/main/resources/application.properties#L11) at runtime when served by tomcat. 15 | 16 | It's useful if you want to serve an Angular application with the ``html5 router``, and avoid the dashed URL. 17 | 18 | This ``html5 router`` mode makes pretty URL, but has a default : Refreshing pages (or accessing them directly) will give you a 404 19 | HTTP error if no RewriteRule is provided by the HTTP server that serves the application. 20 | 21 | Handling the ``base-href`` dynamically can be tricky too. Here it's done once and for all by the ResourceResolver. 22 | 23 | This project includes a custom [HTTP interceptor](https://github.com/mpalourdio/ng-http-loader). It's useful to show a [loader](https://github.com/tobiasahlin/SpinKit) during long HTTP requests for example. 24 | 25 | To test the fully built project, run [SpringBootAngularHTML5Application](src/main/java/com/mpalourdio/html5/SpringBootAngularHTML5Application.java) after an ``./mvnw clean install -Pfront``, and point your browser to [http://localhost:10000/my-context/path](http://localhost:10000/my-context/path). 26 | 27 | If you want to play with the front part, go to the [front folder](front) and run ``yarn start`` or ``npm start``. HTTP requests will be correctly proxyfied to your backend. 28 | 29 | The front-end part has been scaffolded with [angular-cli](https://github.com/angular/angular-cli). 30 | -------------------------------------------------------------------------------- /front/.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 4 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [{package.json,angular.json,.eslintrc.json,karma.conf.js,protractor.conf.js,tsconfig*.json,test.ts,main.ts,polyfills.ts}] 13 | indent_size = 2 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /front/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "front": { 7 | "projectType": "application", 8 | "schematics": { 9 | "@schematics/angular:component": { 10 | "style": "scss" 11 | }, 12 | "@schematics/angular:application": { 13 | "strict": true 14 | } 15 | }, 16 | "root": "", 17 | "sourceRoot": "src", 18 | "prefix": "app", 19 | "architect": { 20 | "build": { 21 | "builder": "@angular-devkit/build-angular:application", 22 | "options": { 23 | "outputPath": { 24 | "base": "dist/package", 25 | "browser": "" 26 | }, 27 | "index": "src/index.html", 28 | "browser": "src/main.ts", 29 | "tsConfig": "tsconfig.app.json", 30 | "inlineStyleLanguage": "scss", 31 | "baseHref": "/my-context/path/", 32 | "preserveSymlinks": true, 33 | "assets": [ 34 | "src/favicon.ico", 35 | "src/assets", 36 | { 37 | "glob": "**/*.eot", 38 | "input": "./node_modules/font-awesome/fonts", 39 | "output": "/assets/font-awesome/fonts" 40 | } 41 | ], 42 | "styles": [ 43 | "src/styles.scss" 44 | ], 45 | "scripts": [] 46 | }, 47 | "configurations": { 48 | "production": { 49 | "budgets": [ 50 | { 51 | "type": "initial", 52 | "maximumWarning": "500kb", 53 | "maximumError": "1mb" 54 | }, 55 | { 56 | "type": "anyComponentStyle", 57 | "maximumWarning": "2kb", 58 | "maximumError": "4kb" 59 | } 60 | ], 61 | "outputHashing": "all", 62 | "baseHref": "#base-href#static/", 63 | "progress": false 64 | }, 65 | "development": { 66 | "optimization": false, 67 | "extractLicenses": false, 68 | "sourceMap": true 69 | } 70 | }, 71 | "defaultConfiguration": "production" 72 | }, 73 | "serve": { 74 | "builder": "@angular-devkit/build-angular:dev-server", 75 | "options": { 76 | "proxyConfig": "proxy.conf.json", 77 | "buildTarget": "front:build" 78 | }, 79 | "configurations": { 80 | "production": { 81 | "buildTarget": "front:build:production" 82 | }, 83 | "development": { 84 | "buildTarget": "front:build:development" 85 | } 86 | }, 87 | "defaultConfiguration": "development" 88 | }, 89 | "extract-i18n": { 90 | "builder": "@angular-devkit/build-angular:extract-i18n" 91 | }, 92 | "test": { 93 | "builder": "@angular-builders/jest:run", 94 | "options": { 95 | "configPath": "./jest.config.ts", 96 | "tsConfig": "tsconfig.spec.json", 97 | "preserveSymlinks": [ 98 | "true" 99 | ], 100 | "watch": false, 101 | "styles": [ 102 | "src/styles.scss" 103 | ], 104 | "scripts": [], 105 | "assets": [ 106 | "src/static" 107 | ] 108 | } 109 | }, 110 | "lint": { 111 | "builder": "@angular-eslint/builder:lint", 112 | "options": { 113 | "lintFilePatterns": [ 114 | "src/**/*.ts", 115 | "src/**/*.html" 116 | ] 117 | } 118 | }, 119 | "e2e": { 120 | "builder": "@cypress/schematic:cypress", 121 | "options": { 122 | "devServerTarget": "front:serve", 123 | "browser": "chromium", 124 | "watch": false, 125 | "record": false 126 | }, 127 | "configurations": { 128 | "production": { 129 | "devServerTarget": "front:serve:production" 130 | } 131 | } 132 | } 133 | } 134 | } 135 | }, 136 | "cli": { 137 | "schematicCollections": [ 138 | "@angular-eslint/schematics" 139 | ] 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /front/cypress.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'cypress'; 2 | import Browser = Cypress.Browser; 3 | 4 | const puppeteer = require('puppeteer'); 5 | 6 | const findPuppeteer: () => Promise = async () => { 7 | const browserPath = puppeteer.executablePath(); 8 | const browser = await puppeteer.launch({ args: ['--no-sandbox'] }); 9 | const version = await browser.version(); 10 | const majorVersion = parseInt(version.split('/')[1]); 11 | 12 | return { 13 | name: 'chromium', 14 | family: 'chromium', 15 | displayName: `Puppeteer - ${version}`, 16 | version: version, 17 | majorVersion: majorVersion, 18 | path: browserPath, 19 | channel: 'stable', 20 | isHeaded: false, 21 | isHeadless: true 22 | }; 23 | }; 24 | 25 | export default defineConfig({ 26 | e2e: { 27 | 'baseUrl': 'http://localhost:4200', 28 | supportFile: false, 29 | video: false, 30 | setupNodeEvents: (on, config) => { 31 | return findPuppeteer().then((browser) => { 32 | config.browsers.push(browser); 33 | return config; 34 | }); 35 | } 36 | } 37 | }); 38 | -------------------------------------------------------------------------------- /front/cypress/e2e/spec.cy.ts: -------------------------------------------------------------------------------- 1 | describe('My First Test', () => { 2 | it('should do things', () => { 3 | cy.visit('/'); 4 | cy.contains('I am a very long url - click me'); 5 | }); 6 | }); 7 | -------------------------------------------------------------------------------- /front/cypress/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "include": [ 4 | "**/*.ts", 5 | "../cypress.config.ts" 6 | ], 7 | "compilerOptions": { 8 | "sourceMap": false, 9 | "types": [ 10 | "cypress" 11 | ] 12 | }, 13 | "exclude": [] 14 | } 15 | -------------------------------------------------------------------------------- /front/eslint.config.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const eslint = require('@eslint/js'); 3 | const tseslint = require('typescript-eslint'); 4 | const angular = require('angular-eslint'); 5 | const rxjs = require('@smarttools/eslint-plugin-rxjs'); 6 | 7 | module.exports = tseslint.config( 8 | { 9 | files: ['**/*.ts'], 10 | extends: [ 11 | eslint.configs.recommended, 12 | ...tseslint.configs.recommended, 13 | ...tseslint.configs.stylistic, 14 | ...angular.configs.tsRecommended, 15 | { 16 | languageOptions: { 17 | parserOptions: { 18 | projectService: true, 19 | tsconfigRootDir: __dirname, 20 | }, 21 | }, 22 | }, 23 | ], 24 | plugins: { 25 | rxjs, 26 | }, 27 | processor: angular.processInlineTemplates, 28 | 'rules': { 29 | '@typescript-eslint/explicit-function-return-type': [ 30 | 'error' 31 | ], 32 | 'no-extra-boolean-cast': [ 33 | 'off' 34 | ], 35 | '@angular-eslint/component-selector': [ 36 | 'error', 37 | { 38 | 'type': 'element', 39 | 'prefix': '', 40 | 'style': 'kebab-case' 41 | } 42 | ], 43 | '@angular-eslint/directive-selector': [ 44 | 'error', 45 | { 46 | 'type': 'attribute', 47 | 'prefix': '', 48 | 'style': 'camelCase' 49 | } 50 | ], 51 | 'comma-dangle': [ 52 | 'error', 53 | { 54 | 'objects': 'never', 55 | 'arrays': 'always-multiline', 56 | 'functions': 'never' 57 | } 58 | ], 59 | 'rxjs/finnish': [ 60 | 'error', 61 | { 62 | 'functions': true, 63 | 'methods': true, 64 | 'names': { 65 | '^(canActivate|canActivateChild|canDeactivate|canLoad|intercept|resolve|validate)$': false 66 | }, 67 | 'parameters': true, 68 | 'properties': true, 69 | 'strict': false, 70 | 'types': { 71 | '^EventEmitter$': false 72 | }, 73 | 'variables': true 74 | } 75 | ], 76 | 'rxjs/no-implicit-any-catch': [ 77 | 'error', 78 | { 79 | 'allowExplicitAny': true 80 | } 81 | ] 82 | }, 83 | }, 84 | { 85 | files: ['**/*.html'], 86 | extends: [ 87 | ...angular.configs.templateRecommended, 88 | ...angular.configs.templateAccessibility, 89 | ], 90 | rules: {}, 91 | } 92 | ); 93 | -------------------------------------------------------------------------------- /front/jest.config.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from 'jest'; 2 | 3 | export default { 4 | preset: 'jest-preset-angular', 5 | coverageReporters: ["lcovonly"], 6 | coverageDirectory: './coverage', 7 | verbose: true 8 | } satisfies Config; 9 | -------------------------------------------------------------------------------- /front/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "front", 3 | "version": "2.0.0", 4 | "license": "MIT", 5 | "scripts": { 6 | "ng": "ng", 7 | "start": "ng serve", 8 | "build": "ng build", 9 | "watch": "ng build --watch --configuration development", 10 | "gzip": "gzipper ./dist", 11 | "build:prod": "npm run build && npm run gzip", 12 | "test": "ng test", 13 | "lint": "ng lint", 14 | "e2e": "ng e2e", 15 | "audit:prod": "npm audit --omit=dev" 16 | }, 17 | "private": true, 18 | "dependencies": { 19 | "@angular/animations": "^19.0.0", 20 | "@angular/common": "^19.0.0", 21 | "@angular/compiler": "^19.0.0", 22 | "@angular/core": "^19.0.0", 23 | "@angular/forms": "^19.0.0", 24 | "@angular/platform-browser": "^19.0.0", 25 | "@angular/platform-browser-dynamic": "^19.0.0", 26 | "@angular/router": "^19.0.0", 27 | "font-awesome": "^4.7.0", 28 | "ng-http-loader": "^17.0.0", 29 | "rxjs": "~7.8.0", 30 | "tslib": "^2.3.0" 31 | }, 32 | "devDependencies": { 33 | "@angular-builders/jest": "^19.0.0", 34 | "@angular-devkit/build-angular": "^19.0.0", 35 | "@angular/cli": "^19.0.0", 36 | "@angular/compiler-cli": "^19.0.0", 37 | "@cypress/schematic": "^3.0.0", 38 | "@smarttools/eslint-plugin-rxjs": "^1.0.18", 39 | "@types/jest": "^29.5.14", 40 | "@typescript-eslint/parser": "^8.23.0", 41 | "angular-eslint": "^19.0.0", 42 | "cypress": "^14.2.0", 43 | "eslint": "^9.23.0", 44 | "gzipper": "1.4.2", 45 | "jest": "^29.7.0", 46 | "jest-preset-angular": "^14.5.3", 47 | "puppeteer": "^24.0.0", 48 | "typescript": "~5.7.2", 49 | "typescript-eslint": "^8.18.0" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /front/proxy.conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "/my-context/path/api": { 3 | "target": "http://localhost:10000", 4 | "changeOrigin": true, 5 | "secure": false, 6 | "pathRewrite": { 7 | "^/api": "" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /front/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /front/src/app/app.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpalourdio/SpringBootAngularHTML5/4065b451233f907d9f93c846f7bfcb63ccd273fc/front/src/app/app.component.scss -------------------------------------------------------------------------------- /front/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 3 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 4 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 5 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 6 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 7 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | */ 9 | 10 | import { TestBed } from '@angular/core/testing'; 11 | import { AppComponent } from './app.component'; 12 | import { provideExperimentalZonelessChangeDetection } from "@angular/core"; 13 | 14 | describe('AppComponent', () => { 15 | beforeEach(async () => { 16 | await TestBed.configureTestingModule({ 17 | imports: [AppComponent], 18 | providers: [ 19 | provideExperimentalZonelessChangeDetection(), 20 | ] 21 | }).compileComponents(); 22 | }); 23 | 24 | it('should create a component instance', () => { 25 | const fixture = TestBed.createComponent(AppComponent); 26 | const app = fixture.debugElement.componentInstance; 27 | expect(app).toBeTruthy(); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /front/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 3 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 4 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 5 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 6 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 7 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | */ 9 | 10 | import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core'; 11 | import { NgHttpLoaderComponent, PendingRequestsInterceptorConfigurer } from 'ng-http-loader'; 12 | import { RouterOutlet } from "@angular/router"; 13 | 14 | @Component({ 15 | selector: 'app-root', 16 | templateUrl: './app.component.html', 17 | standalone: true, 18 | styleUrls: ['./app.component.scss'], 19 | imports: [RouterOutlet, NgHttpLoaderComponent] 20 | }) 21 | export class AppComponent implements OnInit, AfterViewInit { 22 | 23 | @ViewChild('ngHttpLoader') 24 | ngHttpLoader!: NgHttpLoaderComponent; 25 | 26 | constructor(private pendingRequestsInterceptor: PendingRequestsInterceptorConfigurer) { 27 | } 28 | 29 | ngOnInit(): void { 30 | this.pendingRequestsInterceptor.pendingRequestsStatus$.subscribe(pending => { 31 | if (!pending) { 32 | console.log('No HTTP requests pending anymore'); 33 | } 34 | }); 35 | } 36 | 37 | ngAfterViewInit(): void { 38 | this.ngHttpLoader.isVisible$.subscribe(v => { 39 | if (!v) { 40 | console.log('No HTTP requests pending anymore (from ngAfterViewInit)'); 41 | } 42 | }); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /front/src/app/app.config.ts: -------------------------------------------------------------------------------- 1 | import { ApplicationConfig, provideExperimentalZonelessChangeDetection } from '@angular/core'; 2 | import { provideRouter } from '@angular/router'; 3 | 4 | import { routes } from './app.routes'; 5 | import { AppBaseHrefWithoutStaticProvider } from "./factory/app-base-href-without-static-provider.factory"; 6 | import { basehrefInterceptor$ } from "./basehref-interceptor"; 7 | import { provideHttpClient, withInterceptors } from "@angular/common/http"; 8 | import { pendingRequestsInterceptor$ } from "ng-http-loader"; 9 | 10 | export const appConfig: ApplicationConfig = { 11 | providers: [ 12 | provideExperimentalZonelessChangeDetection(), 13 | provideRouter(routes), 14 | AppBaseHrefWithoutStaticProvider, 15 | provideHttpClient( 16 | withInterceptors([basehrefInterceptor$, pendingRequestsInterceptor$]) 17 | ), 18 | ] 19 | }; 20 | -------------------------------------------------------------------------------- /front/src/app/app.routes.ts: -------------------------------------------------------------------------------- 1 | import { Routes } from '@angular/router'; 2 | 3 | export const routes: Routes = [ 4 | { 5 | path: '', 6 | loadComponent : () => import('./first/components/first/first.component').then(m => m.FirstComponent) 7 | }, 8 | { 9 | path: 'iam/a/very/long/url', 10 | loadComponent : () => import('./second/components/second/second.component').then(m => m.SecondComponent) 11 | 12 | }, 13 | { 14 | path: '**', 15 | redirectTo: '' 16 | }, 17 | ]; 18 | -------------------------------------------------------------------------------- /front/src/app/basehref-interceptor.ts: -------------------------------------------------------------------------------- 1 | import { HttpEvent, HttpHandlerFn, HttpRequest } from "@angular/common/http"; 2 | import { inject } from "@angular/core"; 3 | import { APP_BASE_HREF } from "@angular/common"; 4 | import { Observable } from "rxjs"; 5 | 6 | export function basehrefInterceptor$(req: HttpRequest, next: HttpHandlerFn): Observable> { 7 | const baseHref = inject(APP_BASE_HREF); 8 | if (!req.url.toLocaleLowerCase().startsWith('http')) { 9 | const clonedReq = req.clone({ url: baseHref + req.url }); 10 | return next(clonedReq); 11 | } 12 | 13 | return next(req); 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /front/src/app/factory/app-base-href-without-static-provider.factory.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 3 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 4 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 5 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 6 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 7 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | */ 9 | 10 | import { APP_BASE_HREF, PlatformLocation } from '@angular/common'; 11 | import { FactoryProvider } from '@angular/core'; 12 | 13 | export const AppBaseHrefWithoutStaticProvider: FactoryProvider = { 14 | provide: APP_BASE_HREF, 15 | useFactory: (platformLocation: PlatformLocation) => { 16 | return platformLocation 17 | .getBaseHrefFromDOM() 18 | .replace('static/', ''); 19 | }, 20 | deps: [PlatformLocation] 21 | }; 22 | 23 | -------------------------------------------------------------------------------- /front/src/app/first/components/first/first.component.html: -------------------------------------------------------------------------------- 1 | I am a very long url - click me
2 | 3 | Spring will forward the requested url to index.html, and angular will do the job.

4 | Download a file from node_modules
5 | Download a project asset 6 | -------------------------------------------------------------------------------- /front/src/app/first/components/first/first.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpalourdio/SpringBootAngularHTML5/4065b451233f907d9f93c846f7bfcb63ccd273fc/front/src/app/first/components/first/first.component.scss -------------------------------------------------------------------------------- /front/src/app/first/components/first/first.component.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 3 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 4 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 5 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 6 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 7 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | */ 9 | 10 | import { provideHttpClient } from '@angular/common/http'; 11 | import { provideHttpClientTesting } from '@angular/common/http/testing'; 12 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 13 | import { FirstComponent } from './first.component'; 14 | import { provideRouter } from "@angular/router"; 15 | import { provideExperimentalZonelessChangeDetection } from "@angular/core"; 16 | 17 | describe('FirstComponent', () => { 18 | let component: FirstComponent; 19 | let fixture: ComponentFixture; 20 | 21 | beforeEach(async () => { 22 | await TestBed.configureTestingModule({ 23 | imports: [FirstComponent], 24 | providers: [ 25 | provideHttpClient(), 26 | provideHttpClientTesting(), 27 | provideRouter([]), 28 | provideExperimentalZonelessChangeDetection(), 29 | ] 30 | }) 31 | .compileComponents(); 32 | 33 | fixture = TestBed.createComponent(FirstComponent); 34 | component = fixture.componentInstance; 35 | await fixture.whenStable(); 36 | }); 37 | 38 | it('should create a component instance', () => { 39 | expect(component).toBeTruthy(); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /front/src/app/first/components/first/first.component.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 3 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 4 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 5 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 6 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 7 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | */ 9 | 10 | import { Component } from '@angular/core'; 11 | import { RouterLink } from "@angular/router"; 12 | 13 | @Component({ 14 | selector: 'app-first', 15 | templateUrl: './first.component.html', 16 | standalone: true, 17 | styleUrls: ['./first.component.scss'], 18 | imports: [RouterLink] 19 | }) 20 | export class FirstComponent { 21 | } 22 | -------------------------------------------------------------------------------- /front/src/app/http.service.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 3 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 4 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 5 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 6 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 7 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | */ 9 | 10 | import { provideHttpClient } from '@angular/common/http'; 11 | import { provideHttpClientTesting } from '@angular/common/http/testing'; 12 | import { TestBed } from '@angular/core/testing'; 13 | import { HttpService } from './http.service'; 14 | import { provideExperimentalZonelessChangeDetection } from "@angular/core"; 15 | 16 | describe('HttpServiceService', () => { 17 | beforeEach(() => { 18 | TestBed.configureTestingModule({ 19 | providers: [ 20 | provideHttpClient(), 21 | provideHttpClientTesting(), 22 | provideExperimentalZonelessChangeDetection(), 23 | ] 24 | }); 25 | }); 26 | 27 | it('should create a service instance', () => { 28 | const service = TestBed.inject(HttpService); 29 | expect(service).toBeTruthy(); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /front/src/app/http.service.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 3 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 4 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 5 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 6 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 7 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | */ 9 | 10 | import { HttpClient, HttpErrorResponse } from '@angular/common/http'; 11 | import { Injectable } from '@angular/core'; 12 | import { Observable, throwError } from 'rxjs'; 13 | import { catchError, map } from 'rxjs/operators'; 14 | 15 | @Injectable({ 16 | providedIn: 'root' 17 | }) 18 | export class HttpService { 19 | 20 | constructor(private http: HttpClient) { 21 | } 22 | 23 | runFastQuery$(): Observable { 24 | return this.http.post( 25 | 'api/fast', 26 | null 27 | ).pipe( 28 | map(this.extractData), 29 | catchError(this.handleError$) 30 | ); 31 | } 32 | 33 | runSlowQuery$(): Observable { 34 | return this.http.get('http://localhost:10000/my-context/path/api/slow', 35 | { 36 | headers: { 37 | 'x-requested-with': 'XmlHttpRequest' 38 | } 39 | } 40 | ).pipe( 41 | map(this.extractData), 42 | catchError(this.handleError$) 43 | ); 44 | } 45 | 46 | runReactiveQuery$(): Observable { 47 | return this.http 48 | .get('api/slow-but-reactive') 49 | .pipe( 50 | map(this.extractData), 51 | catchError(this.handleError$) 52 | ); 53 | } 54 | 55 | private extractData(res: unknown): string[] | object { 56 | return res || {}; 57 | } 58 | 59 | private handleError$(error: HttpErrorResponse | unknown): Observable { 60 | console.log(error); 61 | return throwError(() => error); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /front/src/app/second/components/second/second.component.html: -------------------------------------------------------------------------------- 1 | Now you can refresh this page (hit F5) (or go back)
2 | 3 |
4 |
5 |
6 |
7 |
8 | 9 | @if (fastQueryResult) { 10 |
11 | {{ fastQueryResult | json }}
12 | 
13 | } 14 | 15 | @if (slowQueryResult) { 16 |
17 | {{ slowQueryResult | json }}
18 | 
19 | } 20 | 21 | @if (errorMessage) { 22 |
23 | {{ errorMessage | json }}
24 | 
25 | } 26 | -------------------------------------------------------------------------------- /front/src/app/second/components/second/second.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpalourdio/SpringBootAngularHTML5/4065b451233f907d9f93c846f7bfcb63ccd273fc/front/src/app/second/components/second/second.component.scss -------------------------------------------------------------------------------- /front/src/app/second/components/second/second.component.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 3 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 4 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 5 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 6 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 7 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | */ 9 | 10 | import { provideHttpClient } from '@angular/common/http'; 11 | import { provideHttpClientTesting } from '@angular/common/http/testing'; 12 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 13 | import { SecondComponent } from './second.component'; 14 | import { provideRouter } from "@angular/router"; 15 | import { provideExperimentalZonelessChangeDetection } from "@angular/core"; 16 | 17 | describe('SecondComponent', () => { 18 | let component: SecondComponent; 19 | let fixture: ComponentFixture; 20 | 21 | beforeEach(async () => { 22 | await TestBed.configureTestingModule({ 23 | imports: [SecondComponent], 24 | providers: [ 25 | provideHttpClient(), 26 | provideHttpClientTesting(), 27 | provideRouter([]), 28 | provideExperimentalZonelessChangeDetection(), 29 | ] 30 | }) 31 | .compileComponents(); 32 | 33 | fixture = TestBed.createComponent(SecondComponent); 34 | component = fixture.componentInstance; 35 | await fixture.whenStable(); 36 | }); 37 | 38 | it('should create a component instance', () => { 39 | expect(component).toBeTruthy(); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /front/src/app/second/components/second/second.component.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 3 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 4 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 5 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 6 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 7 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | */ 9 | 10 | import { Component } from '@angular/core'; 11 | import { SpinnerVisibilityService } from 'ng-http-loader'; 12 | import { forkJoin } from 'rxjs'; 13 | import { HttpService } from '../../../http.service'; 14 | import { JsonPipe } from "@angular/common"; 15 | import { RouterLink } from "@angular/router"; 16 | 17 | @Component({ 18 | selector: 'app-second', 19 | templateUrl: './second.component.html', 20 | standalone: true, 21 | styleUrls: ['./second.component.scss'], 22 | imports: [JsonPipe, RouterLink] 23 | }) 24 | export class SecondComponent { 25 | 26 | fastQueryResult!: string[] | object | null; 27 | slowQueryResult!: string[] | object | null; 28 | errorMessage: unknown; 29 | 30 | constructor(private httpService: HttpService, private spinner: SpinnerVisibilityService) { 31 | } 32 | 33 | private resetFields(): void { 34 | this.fastQueryResult = null; 35 | this.slowQueryResult = null; 36 | this.errorMessage = undefined; 37 | } 38 | 39 | callAllQueries(): void { 40 | this.resetFields(); 41 | 42 | forkJoin([ 43 | this.httpService.runFastQuery$(), 44 | this.httpService.runSlowQuery$(), 45 | ]) 46 | .subscribe({ 47 | next: results => { 48 | console.log(results); 49 | this.fastQueryResult = results[0]; 50 | this.slowQueryResult = results[1]; 51 | }, 52 | error: (error: unknown) => this.errorMessage = error 53 | } 54 | ); 55 | } 56 | 57 | fastQuery(): void { 58 | this.resetFields(); 59 | 60 | this.httpService.runFastQuery$() 61 | .subscribe({ 62 | next: results => this.fastQueryResult = results, 63 | error: (error: unknown) => this.errorMessage = error 64 | } 65 | ); 66 | } 67 | 68 | slowQuery(): void { 69 | this.resetFields(); 70 | 71 | this.httpService.runSlowQuery$() 72 | .subscribe({ 73 | next: results => this.slowQueryResult = results, 74 | error: (error: unknown) => this.errorMessage = error 75 | } 76 | ); 77 | } 78 | 79 | reactiveQuery(): void { 80 | this.resetFields(); 81 | 82 | this.httpService.runReactiveQuery$() 83 | .subscribe({ 84 | next: results => this.slowQueryResult = results, 85 | error: (error: unknown) => this.errorMessage = error 86 | } 87 | ); 88 | } 89 | 90 | forceSpinner(): void { 91 | this.resetFields(); 92 | this.spinner.show(); 93 | this.httpService.runSlowQuery$().subscribe({ 94 | next: () => this.spinner.hide(), 95 | error: () => this.spinner.hide() 96 | } 97 | ); 98 | } 99 | } 100 | 101 | -------------------------------------------------------------------------------- /front/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpalourdio/SpringBootAngularHTML5/4065b451233f907d9f93c846f7bfcb63ccd273fc/front/src/assets/.gitkeep -------------------------------------------------------------------------------- /front/src/assets/test.txt: -------------------------------------------------------------------------------- 1 | hi! 2 | -------------------------------------------------------------------------------- /front/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpalourdio/SpringBootAngularHTML5/4065b451233f907d9f93c846f7bfcb63ccd273fc/front/src/favicon.ico -------------------------------------------------------------------------------- /front/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Front 6 | 7 | 8 | 9 | 10 | 11 | Loading... 12 | 13 | 14 | -------------------------------------------------------------------------------- /front/src/main.ts: -------------------------------------------------------------------------------- 1 | import { bootstrapApplication } from '@angular/platform-browser'; 2 | import { appConfig } from './app/app.config'; 3 | import { AppComponent } from './app/app.component'; 4 | 5 | bootstrapApplication(AppComponent, appConfig) 6 | .catch((err) => console.error(err)); 7 | -------------------------------------------------------------------------------- /front/src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | @import url('../node_modules/font-awesome/css/font-awesome.min.css'); 3 | -------------------------------------------------------------------------------- /front/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ 3 | { 4 | "extends": "./tsconfig.json", 5 | "compilerOptions": { 6 | "outDir": "./out-tsc/app", 7 | "types": [] 8 | }, 9 | "files": [ 10 | "src/main.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /front/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ 3 | { 4 | "compileOnSave": false, 5 | "compilerOptions": { 6 | "outDir": "./dist/out-tsc", 7 | "strict": true, 8 | "noImplicitOverride": true, 9 | "noPropertyAccessFromIndexSignature": true, 10 | "noImplicitReturns": true, 11 | "noFallthroughCasesInSwitch": true, 12 | "skipLibCheck": true, 13 | "isolatedModules": true, 14 | "esModuleInterop": true, 15 | "experimentalDecorators": true, 16 | "moduleResolution": "bundler", 17 | "importHelpers": true, 18 | "target": "ES2022", 19 | "module": "ES2022", 20 | }, 21 | "angularCompilerOptions": { 22 | "enableI18nLegacyMessageIdFormat": false, 23 | "strictInjectionParameters": true, 24 | "strictInputAccessModifiers": true, 25 | "strictTemplates": true 26 | }, 27 | "exclude": [ 28 | "cypress/**/*.ts", 29 | "cypress.config.ts" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /front/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ 3 | { 4 | "extends": "./tsconfig.json", 5 | "compilerOptions": { 6 | "outDir": "./out-tsc/spec", 7 | "types": [ 8 | "jest" 9 | ] 10 | }, 11 | "include": [ 12 | "src/**/*.spec.ts", 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Apache Maven Wrapper startup batch script, version 3.3.2 23 | # 24 | # Optional ENV vars 25 | # ----------------- 26 | # JAVA_HOME - location of a JDK home dir, required when download maven via java source 27 | # MVNW_REPOURL - repo url base for downloading maven distribution 28 | # MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven 29 | # MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output 30 | # ---------------------------------------------------------------------------- 31 | 32 | set -euf 33 | [ "${MVNW_VERBOSE-}" != debug ] || set -x 34 | 35 | # OS specific support. 36 | native_path() { printf %s\\n "$1"; } 37 | case "$(uname)" in 38 | CYGWIN* | MINGW*) 39 | [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" 40 | native_path() { cygpath --path --windows "$1"; } 41 | ;; 42 | esac 43 | 44 | # set JAVACMD and JAVACCMD 45 | set_java_home() { 46 | # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched 47 | if [ -n "${JAVA_HOME-}" ]; then 48 | if [ -x "$JAVA_HOME/jre/sh/java" ]; then 49 | # IBM's JDK on AIX uses strange locations for the executables 50 | JAVACMD="$JAVA_HOME/jre/sh/java" 51 | JAVACCMD="$JAVA_HOME/jre/sh/javac" 52 | else 53 | JAVACMD="$JAVA_HOME/bin/java" 54 | JAVACCMD="$JAVA_HOME/bin/javac" 55 | 56 | if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then 57 | echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 58 | echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 59 | return 1 60 | fi 61 | fi 62 | else 63 | JAVACMD="$( 64 | 'set' +e 65 | 'unset' -f command 2>/dev/null 66 | 'command' -v java 67 | )" || : 68 | JAVACCMD="$( 69 | 'set' +e 70 | 'unset' -f command 2>/dev/null 71 | 'command' -v javac 72 | )" || : 73 | 74 | if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then 75 | echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 76 | return 1 77 | fi 78 | fi 79 | } 80 | 81 | # hash string like Java String::hashCode 82 | hash_string() { 83 | str="${1:-}" h=0 84 | while [ -n "$str" ]; do 85 | char="${str%"${str#?}"}" 86 | h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) 87 | str="${str#?}" 88 | done 89 | printf %x\\n $h 90 | } 91 | 92 | verbose() { :; } 93 | [ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } 94 | 95 | die() { 96 | printf %s\\n "$1" >&2 97 | exit 1 98 | } 99 | 100 | trim() { 101 | # MWRAPPER-139: 102 | # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. 103 | # Needed for removing poorly interpreted newline sequences when running in more 104 | # exotic environments such as mingw bash on Windows. 105 | printf "%s" "${1}" | tr -d '[:space:]' 106 | } 107 | 108 | # parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties 109 | while IFS="=" read -r key value; do 110 | case "${key-}" in 111 | distributionUrl) distributionUrl=$(trim "${value-}") ;; 112 | distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; 113 | esac 114 | done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" 115 | [ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" 116 | 117 | case "${distributionUrl##*/}" in 118 | maven-mvnd-*bin.*) 119 | MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ 120 | case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in 121 | *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; 122 | :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; 123 | :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; 124 | :Linux*x86_64*) distributionPlatform=linux-amd64 ;; 125 | *) 126 | echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 127 | distributionPlatform=linux-amd64 128 | ;; 129 | esac 130 | distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" 131 | ;; 132 | maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; 133 | *) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; 134 | esac 135 | 136 | # apply MVNW_REPOURL and calculate MAVEN_HOME 137 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ 138 | [ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" 139 | distributionUrlName="${distributionUrl##*/}" 140 | distributionUrlNameMain="${distributionUrlName%.*}" 141 | distributionUrlNameMain="${distributionUrlNameMain%-bin}" 142 | MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" 143 | MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" 144 | 145 | exec_maven() { 146 | unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : 147 | exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" 148 | } 149 | 150 | if [ -d "$MAVEN_HOME" ]; then 151 | verbose "found existing MAVEN_HOME at $MAVEN_HOME" 152 | exec_maven "$@" 153 | fi 154 | 155 | case "${distributionUrl-}" in 156 | *?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; 157 | *) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; 158 | esac 159 | 160 | # prepare tmp dir 161 | if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then 162 | clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } 163 | trap clean HUP INT TERM EXIT 164 | else 165 | die "cannot create temp dir" 166 | fi 167 | 168 | mkdir -p -- "${MAVEN_HOME%/*}" 169 | 170 | # Download and Install Apache Maven 171 | verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." 172 | verbose "Downloading from: $distributionUrl" 173 | verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" 174 | 175 | # select .zip or .tar.gz 176 | if ! command -v unzip >/dev/null; then 177 | distributionUrl="${distributionUrl%.zip}.tar.gz" 178 | distributionUrlName="${distributionUrl##*/}" 179 | fi 180 | 181 | # verbose opt 182 | __MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' 183 | [ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v 184 | 185 | # normalize http auth 186 | case "${MVNW_PASSWORD:+has-password}" in 187 | '') MVNW_USERNAME='' MVNW_PASSWORD='' ;; 188 | has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; 189 | esac 190 | 191 | if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then 192 | verbose "Found wget ... using wget" 193 | wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" 194 | elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then 195 | verbose "Found curl ... using curl" 196 | curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" 197 | elif set_java_home; then 198 | verbose "Falling back to use Java to download" 199 | javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" 200 | targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" 201 | cat >"$javaSource" <<-END 202 | public class Downloader extends java.net.Authenticator 203 | { 204 | protected java.net.PasswordAuthentication getPasswordAuthentication() 205 | { 206 | return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); 207 | } 208 | public static void main( String[] args ) throws Exception 209 | { 210 | setDefault( new Downloader() ); 211 | java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); 212 | } 213 | } 214 | END 215 | # For Cygwin/MinGW, switch paths to Windows format before running javac and java 216 | verbose " - Compiling Downloader.java ..." 217 | "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" 218 | verbose " - Running Downloader.java ..." 219 | "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" 220 | fi 221 | 222 | # If specified, validate the SHA-256 sum of the Maven distribution zip file 223 | if [ -n "${distributionSha256Sum-}" ]; then 224 | distributionSha256Result=false 225 | if [ "$MVN_CMD" = mvnd.sh ]; then 226 | echo "Checksum validation is not supported for maven-mvnd." >&2 227 | echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 228 | exit 1 229 | elif command -v sha256sum >/dev/null; then 230 | if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then 231 | distributionSha256Result=true 232 | fi 233 | elif command -v shasum >/dev/null; then 234 | if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then 235 | distributionSha256Result=true 236 | fi 237 | else 238 | echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 239 | echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 240 | exit 1 241 | fi 242 | if [ $distributionSha256Result = false ]; then 243 | echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 244 | echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 245 | exit 1 246 | fi 247 | fi 248 | 249 | # unzip and move 250 | if command -v unzip >/dev/null; then 251 | unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" 252 | else 253 | tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" 254 | fi 255 | printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" 256 | mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" 257 | 258 | clean || : 259 | exec_maven "$@" 260 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | <# : batch portion 2 | @REM ---------------------------------------------------------------------------- 3 | @REM Licensed to the Apache Software Foundation (ASF) under one 4 | @REM or more contributor license agreements. See the NOTICE file 5 | @REM distributed with this work for additional information 6 | @REM regarding copyright ownership. The ASF licenses this file 7 | @REM to you under the Apache License, Version 2.0 (the 8 | @REM "License"); you may not use this file except in compliance 9 | @REM with the License. You may obtain a copy of the License at 10 | @REM 11 | @REM http://www.apache.org/licenses/LICENSE-2.0 12 | @REM 13 | @REM Unless required by applicable law or agreed to in writing, 14 | @REM software distributed under the License is distributed on an 15 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | @REM KIND, either express or implied. See the License for the 17 | @REM specific language governing permissions and limitations 18 | @REM under the License. 19 | @REM ---------------------------------------------------------------------------- 20 | 21 | @REM ---------------------------------------------------------------------------- 22 | @REM Apache Maven Wrapper startup batch script, version 3.3.2 23 | @REM 24 | @REM Optional ENV vars 25 | @REM MVNW_REPOURL - repo url base for downloading maven distribution 26 | @REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven 27 | @REM MVNW_VERBOSE - true: enable verbose log; others: silence the output 28 | @REM ---------------------------------------------------------------------------- 29 | 30 | @IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) 31 | @SET __MVNW_CMD__= 32 | @SET __MVNW_ERROR__= 33 | @SET __MVNW_PSMODULEP_SAVE=%PSModulePath% 34 | @SET PSModulePath= 35 | @FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( 36 | IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) 37 | ) 38 | @SET PSModulePath=%__MVNW_PSMODULEP_SAVE% 39 | @SET __MVNW_PSMODULEP_SAVE= 40 | @SET __MVNW_ARG0_NAME__= 41 | @SET MVNW_USERNAME= 42 | @SET MVNW_PASSWORD= 43 | @IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) 44 | @echo Cannot start maven from wrapper >&2 && exit /b 1 45 | @GOTO :EOF 46 | : end batch / begin powershell #> 47 | 48 | $ErrorActionPreference = "Stop" 49 | if ($env:MVNW_VERBOSE -eq "true") { 50 | $VerbosePreference = "Continue" 51 | } 52 | 53 | # calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties 54 | $distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl 55 | if (!$distributionUrl) { 56 | Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" 57 | } 58 | 59 | switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { 60 | "maven-mvnd-*" { 61 | $USE_MVND = $true 62 | $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" 63 | $MVN_CMD = "mvnd.cmd" 64 | break 65 | } 66 | default { 67 | $USE_MVND = $false 68 | $MVN_CMD = $script -replace '^mvnw','mvn' 69 | break 70 | } 71 | } 72 | 73 | # apply MVNW_REPOURL and calculate MAVEN_HOME 74 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ 75 | if ($env:MVNW_REPOURL) { 76 | $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } 77 | $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" 78 | } 79 | $distributionUrlName = $distributionUrl -replace '^.*/','' 80 | $distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' 81 | $MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" 82 | if ($env:MAVEN_USER_HOME) { 83 | $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" 84 | } 85 | $MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' 86 | $MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" 87 | 88 | if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { 89 | Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" 90 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 91 | exit $? 92 | } 93 | 94 | if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { 95 | Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" 96 | } 97 | 98 | # prepare tmp dir 99 | $TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile 100 | $TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" 101 | $TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null 102 | trap { 103 | if ($TMP_DOWNLOAD_DIR.Exists) { 104 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 105 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 106 | } 107 | } 108 | 109 | New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null 110 | 111 | # Download and Install Apache Maven 112 | Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." 113 | Write-Verbose "Downloading from: $distributionUrl" 114 | Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" 115 | 116 | $webclient = New-Object System.Net.WebClient 117 | if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { 118 | $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) 119 | } 120 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 121 | $webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null 122 | 123 | # If specified, validate the SHA-256 sum of the Maven distribution zip file 124 | $distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum 125 | if ($distributionSha256Sum) { 126 | if ($USE_MVND) { 127 | Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." 128 | } 129 | Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash 130 | if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { 131 | Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." 132 | } 133 | } 134 | 135 | # unzip and move 136 | Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null 137 | Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null 138 | try { 139 | Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null 140 | } catch { 141 | if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { 142 | Write-Error "fail to move MAVEN_HOME" 143 | } 144 | } finally { 145 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 146 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 147 | } 148 | 149 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 150 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.mpalourdio.projects 7 | springbootangularhtml5 8 | 2.0.0-SNAPSHOT 9 | jar 10 | 11 | Spring Boot - Angular - HTML5 Router 12 | https://github.com/mpalourdio/SpringBootAngularHTML5 13 | Spring Boot and Angular project with HTML5 router 14 | 15 | 16 | scm:git:git@github.com:mpalourdio/SpringBootAngularHTML5.git 17 | HEAD 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-parent 23 | 3.5.0 24 | 25 | 26 | 27 | 28 | 29 | spring-milestones 30 | Spring Milestones 31 | https://repo.spring.io/milestone 32 | 33 | false 34 | 35 | 36 | 37 | 38 | 39 | spring-milestones 40 | Spring Milestones 41 | https://repo.spring.io/milestone 42 | 43 | false 44 | 45 | 46 | 47 | 48 | 49 | 50 | UTF-8 51 | UTF-8 52 | 21 53 | true 54 | 55 | 56 | 2.19.0 57 | 3.1.1 58 | 59 | 60 | 3.6.0 61 | 10.25.0 62 | https://raw.githubusercontent.com/mpalourdio/configuration/main/checkstyle.xml 63 | 64 | 65 | 66 | 67 | front 68 | 69 | false 70 | true 71 | 72 | 73 | 74 | 75 | 76 | 77 | org.springframework.boot 78 | spring-boot-starter-web 79 | 80 | 81 | org.springframework.boot 82 | spring-boot-starter-webflux 83 | 84 | 85 | org.springframework.boot 86 | spring-boot-starter-security 87 | 88 | 89 | org.springframework.boot 90 | spring-boot-configuration-processor 91 | true 92 | 93 | 94 | org.springframework.boot 95 | spring-boot-devtools 96 | true 97 | 98 | 99 | org.apache.commons 100 | commons-lang3 101 | 102 | 103 | org.projectlombok 104 | lombok 105 | provided 106 | 107 | 108 | commons-io 109 | commons-io 110 | ${commons-io.version} 111 | 112 | 113 | org.springframework.boot 114 | spring-boot-starter-test 115 | test 116 | 117 | 118 | 119 | 120 | ${project.artifactId} 121 | 122 | 123 | org.graalvm.buildtools 124 | native-maven-plugin 125 | 126 | 127 | org.springframework.boot 128 | spring-boot-maven-plugin 129 | 130 | true 131 | 132 | 133 | 134 | org.apache.maven.plugins 135 | maven-release-plugin 136 | ${maven-release-plugin.version} 137 | 138 | false 139 | true 140 | true 141 | 142 | 143 | 144 | org.codehaus.mojo 145 | exec-maven-plugin 146 | 3.5.1 147 | 148 | ${basedir}/front 149 | 150 | 151 | 152 | exec-npm-install 153 | prepare-package 154 | 155 | npm 156 | 157 | ci 158 | 159 | ${build.nofront} 160 | 161 | 162 | exec 163 | 164 | 165 | 166 | exec-ngcli-build 167 | prepare-package 168 | 169 | npm 170 | 171 | run 172 | build:prod 173 | 174 | ${build.nofront} 175 | 176 | 177 | exec 178 | 179 | 180 | 181 | 182 | 183 | org.apache.maven.plugins 184 | maven-resources-plugin 185 | 186 | ${project.build.sourceEncoding} 187 | 188 | 189 | 190 | exec-copy-noindex 191 | prepare-package 192 | 193 | copy-resources 194 | 195 | 196 | ${basedir}/target/classes/public/static 197 | 198 | 199 | front/dist/package 200 | false 201 | 202 | index.html 203 | 204 | 205 | 206 | 207 | 208 | 209 | exec-copy-index-assets 210 | prepare-package 211 | 212 | copy-resources 213 | 214 | 215 | ${basedir}/target/classes/public 216 | 217 | 218 | front/dist/package 219 | false 220 | 221 | index.html 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | org.apache.maven.plugins 231 | maven-checkstyle-plugin 232 | ${maven-checkstyle-plugin.version} 233 | 234 | 235 | com.puppycrawl.tools 236 | checkstyle 237 | ${checkstyle.version} 238 | 239 | 240 | 241 | 242 | validate 243 | validate 244 | 245 | ${maven-checkstyle-plugin.configLocation} 246 | true 247 | true 248 | 249 | 250 | check 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | -------------------------------------------------------------------------------- /src/main/java/com/mpalourdio/html5/SpringBootAngularHTML5Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 3 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 4 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 5 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 6 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 7 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | */ 9 | 10 | package com.mpalourdio.html5; 11 | 12 | import org.springframework.boot.SpringApplication; 13 | import org.springframework.boot.autoconfigure.SpringBootApplication; 14 | 15 | @SpringBootApplication 16 | public class SpringBootAngularHTML5Application { 17 | 18 | public static void main(String... args) { 19 | SpringApplication.run(SpringBootAngularHTML5Application.class, args); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/mpalourdio/html5/api/ApiController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 3 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 4 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 5 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 6 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 7 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | */ 9 | 10 | package com.mpalourdio.html5.api; 11 | 12 | import com.mpalourdio.html5.config.SinglePageAppConfig; 13 | import org.apache.commons.lang3.StringUtils; 14 | import org.springframework.boot.autoconfigure.web.ServerProperties; 15 | import org.springframework.http.ResponseEntity; 16 | import org.springframework.web.bind.annotation.*; 17 | import org.springframework.web.reactive.function.client.WebClient; 18 | import reactor.core.publisher.Mono; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | import static java.util.List.of; 24 | 25 | @RestController 26 | @RequestMapping(path = SinglePageAppConfig.IGNORED_PATH) 27 | public class ApiController { 28 | 29 | private final WebClient webClient; 30 | private final ServerProperties serverProperties; 31 | 32 | public ApiController(ServerProperties serverProperties) { 33 | this.serverProperties = serverProperties; 34 | 35 | this.webClient = WebClient.create("http://localhost:" 36 | + serverProperties.getPort() 37 | + StringUtils.stripToEmpty(serverProperties.getServlet().getContextPath()) 38 | + SinglePageAppConfig.IGNORED_PATH); 39 | } 40 | 41 | @PostMapping(path = "/fast") 42 | public ResponseEntity> fast() { 43 | return ResponseEntity.ok(of("Hey, I am the fast response")); 44 | } 45 | 46 | @GetMapping(path = "/slow-but-reactive") 47 | public Mono>> slowButReactive() { 48 | return webClient 49 | .get() 50 | .uri("/slow") 51 | .retrieve() 52 | .toEntityList(String.class) 53 | .onErrorReturn(ResponseEntity.ok(new ArrayList<>())); 54 | } 55 | 56 | @CrossOrigin(origins = "http://localhost:4200", allowedHeaders = "x-requested-with") 57 | @GetMapping(path = "/slow") 58 | public ResponseEntity> slow() throws InterruptedException { 59 | Thread.sleep(3000); 60 | return ResponseEntity.ok(of("Hey, I am the slow cross-origin response " 61 | + "(if performed from a port different from " + serverProperties.getPort() + ")")); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/mpalourdio/html5/config/SinglePageAppConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 3 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 4 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 5 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 6 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 7 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | */ 9 | 10 | package com.mpalourdio.html5.config; 11 | 12 | import com.mpalourdio.html5.frontcontroller.FrontControllerHandler; 13 | import lombok.extern.slf4j.Slf4j; 14 | import org.springframework.boot.autoconfigure.web.WebProperties; 15 | import org.springframework.context.ApplicationContext; 16 | import org.springframework.context.annotation.Configuration; 17 | import org.springframework.core.io.Resource; 18 | import org.springframework.lang.NonNull; 19 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 20 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 21 | import org.springframework.web.servlet.resource.PathResourceResolver; 22 | 23 | import java.io.IOException; 24 | import java.util.Arrays; 25 | import java.util.Objects; 26 | 27 | import static com.mpalourdio.html5.frontcontroller.FrontControllerHandler.FRONT_CONTROLLER; 28 | import static com.mpalourdio.html5.frontcontroller.FrontControllerHandler.URL_SEPARATOR; 29 | 30 | @Slf4j 31 | @Configuration(proxyBeanMethods = false) 32 | public class SinglePageAppConfig implements WebMvcConfigurer { 33 | 34 | public static final String IGNORED_PATH = "/api"; 35 | private static final String PATH_PATTERNS = "/**"; 36 | 37 | private final FrontControllerHandler frontControllerHandler; 38 | private final ApplicationContext applicationContext; 39 | private final String[] staticLocations; 40 | 41 | public SinglePageAppConfig( 42 | WebProperties webProperties, 43 | FrontControllerHandler frontControllerHandler, 44 | ApplicationContext applicationContext 45 | ) { 46 | this.frontControllerHandler = frontControllerHandler; 47 | this.applicationContext = applicationContext; 48 | this.staticLocations = webProperties.getResources().getStaticLocations(); 49 | } 50 | 51 | @Override 52 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 53 | registry.addResourceHandler(PATH_PATTERNS) 54 | .addResourceLocations(staticLocations) 55 | .resourceChain(true) 56 | .addResolver(new SinglePageAppResourceResolver()); 57 | } 58 | 59 | private class SinglePageAppResourceResolver extends PathResourceResolver { 60 | 61 | private final Resource frontControllerResource; 62 | 63 | SinglePageAppResourceResolver() { 64 | this.frontControllerResource = Arrays 65 | .stream(staticLocations) 66 | .map(path -> applicationContext.getResource(path + FRONT_CONTROLLER)) 67 | .filter(this::resourceExistsAndIsReadable) 68 | .findFirst() 69 | .map(frontControllerHandler::buildFrontControllerResource) 70 | .orElseGet(() -> { 71 | log.warn(FRONT_CONTROLLER + " not found. " 72 | + "Ensure you have built the frontend part if you are not in dev mode."); 73 | 74 | return null; 75 | }); 76 | } 77 | 78 | @Override 79 | protected Resource getResource(@NonNull String resourcePath, Resource location) throws IOException { 80 | var resource = location.createRelative(resourcePath); 81 | if (resourceExistsAndIsReadable(resource)) { 82 | //if the asked resource is index.html itself, we serve it with the base-href rewritten 83 | if (resourcePath.endsWith(FRONT_CONTROLLER)) { 84 | return frontControllerResource; 85 | } 86 | //here we serve js, css, etc. 87 | return resource; 88 | } 89 | 90 | //do not serve a Resource on an ignored path 91 | if ((URL_SEPARATOR + resourcePath).startsWith(IGNORED_PATH)) { 92 | return null; 93 | } 94 | 95 | //we are in the case of an angular route here, we rewrite to index.html 96 | if (resourceExistsAndIsReadable(location.createRelative(FRONT_CONTROLLER))) { 97 | return frontControllerResource; 98 | } 99 | 100 | return null; 101 | } 102 | 103 | private boolean resourceExistsAndIsReadable(Resource resource) { 104 | Objects.requireNonNull(resource, "resource cannot be null"); 105 | return resource.exists() && resource.isReadable(); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/com/mpalourdio/html5/config/WebSecurityConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 3 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 4 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 5 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 6 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 7 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | */ 9 | 10 | package com.mpalourdio.html5.config; 11 | 12 | import org.springframework.context.annotation.Bean; 13 | import org.springframework.context.annotation.Configuration; 14 | import org.springframework.core.annotation.Order; 15 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 16 | import org.springframework.security.web.SecurityFilterChain; 17 | import org.springframework.security.web.csrf.CookieCsrfTokenRepository; 18 | import org.springframework.security.web.csrf.CsrfTokenRequestHandler; 19 | import org.springframework.security.web.csrf.XorCsrfTokenRequestAttributeHandler; 20 | 21 | @Configuration(proxyBeanMethods = false) 22 | public class WebSecurityConfig { 23 | 24 | @Bean 25 | public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { 26 | var tokenRepository = CookieCsrfTokenRepository.withHttpOnlyFalse(); 27 | var delegate = getXorCsrfTokenRequestAttributeHandler(); 28 | // Use only the handle() method of XorCsrfTokenRequestAttributeHandler and the 29 | // default implementation of resolveCsrfTokenValue() from CsrfTokenRequestHandler 30 | CsrfTokenRequestHandler requestHandler = delegate::handle; 31 | http 32 | .csrf(csrf -> csrf 33 | .csrfTokenRepository(tokenRepository) 34 | .csrfTokenRequestHandler(requestHandler) 35 | ); 36 | 37 | return http.build(); 38 | } 39 | 40 | private static XorCsrfTokenRequestAttributeHandler getXorCsrfTokenRequestAttributeHandler() { 41 | var delegate = new XorCsrfTokenRequestAttributeHandler(); 42 | // By setting the csrfRequestAttributeName to null, the CsrfToken must first be loaded to determine what attribute name to use. 43 | // This causes the CsrfToken to be loaded on every request. 44 | // Another solution would have been to create a OncePerRequestFilter to handle CrsfFilter. 45 | delegate.setCsrfRequestAttributeName(null); 46 | return delegate; 47 | } 48 | 49 | @Bean 50 | @Order(-1) 51 | SecurityFilterChain staticResources(HttpSecurity http) throws Exception { 52 | http.securityMatchers(matches -> matches.requestMatchers("/static/**")) 53 | .authorizeHttpRequests(authorize -> authorize.anyRequest().permitAll()); 54 | 55 | return http.build(); 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /src/main/java/com/mpalourdio/html5/frontcontroller/FrontControllerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 3 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 4 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 5 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 6 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 7 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | */ 9 | 10 | package com.mpalourdio.html5.frontcontroller; 11 | 12 | class FrontControllerException extends RuntimeException { 13 | 14 | FrontControllerException(String message) { 15 | super(message); 16 | } 17 | 18 | FrontControllerException(String message, Throwable throwable) { 19 | super(message, throwable); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/mpalourdio/html5/frontcontroller/FrontControllerHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 3 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 4 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 5 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 6 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 7 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | */ 9 | 10 | package com.mpalourdio.html5.frontcontroller; 11 | 12 | import org.apache.commons.io.IOUtils; 13 | import org.apache.commons.lang3.StringUtils; 14 | import org.springframework.boot.autoconfigure.web.ServerProperties; 15 | import org.springframework.core.io.Resource; 16 | import org.springframework.stereotype.Service; 17 | import org.springframework.web.servlet.resource.TransformedResource; 18 | 19 | import java.io.IOException; 20 | import java.nio.charset.StandardCharsets; 21 | import java.util.Objects; 22 | 23 | @Service 24 | public class FrontControllerHandler { 25 | 26 | private static final String BASE_HREF_PLACEHOLDER = "#base-href#"; 27 | private static final String FRONT_CONTROLLER_ENCODING = StandardCharsets.UTF_8.name(); 28 | public static final String URL_SEPARATOR = "/"; 29 | public static final String FRONT_CONTROLLER = "index.html"; 30 | 31 | private final ServerProperties serverProperties; 32 | 33 | public FrontControllerHandler(ServerProperties serverProperties) { 34 | this.serverProperties = serverProperties; 35 | } 36 | 37 | public TransformedResource buildFrontControllerResource(Resource resource) { 38 | Objects.requireNonNull(resource, "resource cannot be null"); 39 | 40 | try { 41 | var frontControllerContent = IOUtils.toString(resource.getInputStream(), FRONT_CONTROLLER_ENCODING); 42 | if (!frontControllerContent.contains(BASE_HREF_PLACEHOLDER)) { 43 | throw new FrontControllerException(FRONT_CONTROLLER + " does not contain " + BASE_HREF_PLACEHOLDER); 44 | } 45 | 46 | frontControllerContent = frontControllerContent.replace(BASE_HREF_PLACEHOLDER, buildBaseHref()); 47 | return new TransformedResource(resource, frontControllerContent.getBytes(FRONT_CONTROLLER_ENCODING)); 48 | } catch (IOException e) { 49 | throw new FrontControllerException("Unable to perform " + FRONT_CONTROLLER + " tranformation", e); 50 | } 51 | } 52 | 53 | private String buildBaseHref() { 54 | var contextPath = StringUtils.stripToNull(serverProperties.getServlet().getContextPath()); 55 | 56 | return null == contextPath || contextPath.equals(URL_SEPARATOR) 57 | ? URL_SEPARATOR 58 | : contextPath + URL_SEPARATOR; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | ## 2 | ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 3 | ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 4 | ## FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 5 | ## COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 6 | ## IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 7 | ## CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | ## 9 | 10 | server.port=10000 11 | server.servlet.context-path=/my-context/path 12 | server.compression.enabled=true 13 | server.compression.mime-types=application/javascript,application/json,text/css,text/html,text/plain 14 | logging.config=classpath:logback-spring.xml 15 | spring.output.ansi.enabled=always 16 | -------------------------------------------------------------------------------- /src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | logs/app.log 8 | 9 | logs/app-%d{yyyy-MM-dd}.log 10 | 11 | 12 | ${FILE_LOG_PATTERN} 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/test/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpalourdio/SpringBootAngularHTML5/4065b451233f907d9f93c846f7bfcb63ccd273fc/src/test/.gitkeep -------------------------------------------------------------------------------- /src/test/java/com/mpalourdio/html5/fake/UselessTest.java: -------------------------------------------------------------------------------- 1 | package com.mpalourdio.html5.fake; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import static org.assertj.core.api.Assertions.assertThat; 6 | 7 | class UselessTest { 8 | 9 | @Test 10 | void testOneEqualsOne() { 11 | assertThat(1).isEqualTo(1); 12 | } 13 | } 14 | --------------------------------------------------------------------------------