add base api path to nestjs: "api"

This commit is contained in:
Roland Schneider 2025-11-13 21:49:41 +01:00
parent e09110346e
commit 19ca0c086c
9 changed files with 73 additions and 6 deletions

View File

@ -3,7 +3,7 @@
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"

8
admin/proxy.conf.json Normal file
View File

@ -0,0 +1,8 @@
{
"/api": {
"target": "http://localhost:3000",
"secure": false,
"logLevel": "debug",
"changeOrigin": true
}
}

View File

@ -1,4 +1,7 @@
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import {
ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection,
provideZonelessChangeDetection,
} from '@angular/core';
import { provideRouter } from '@angular/router';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
@ -9,7 +12,8 @@ import { AuthGuard } from './auth/auth.guard';
export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideBrowserGlobalErrorListeners(),
provideZonelessChangeDetection(),
provideRouter(routes),
provideHttpClient(withInterceptorsFromDi()),
AuthService,

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
@Injectable({
@ -8,7 +8,7 @@ import { tap } from 'rxjs/operators';
})
export class AuthService {
private readonly TOKEN_KEY = 'access_token';
private apiUrl = 'http://localhost:3000/auth'; // Adjust if your server URL is different
private apiUrl = 'http://localhost:4200/api/auth'; // Adjust if your server URL is different
constructor(private http: HttpClient) {}

View File

@ -0,0 +1,19 @@
<div class="navbar bg-base-100 shadow-sm">
<div class="flex-1">
<a class="btn btn-ghost text-xl">daisyUI</a>
</div>
<div class="flex-none">
<ul class="menu menu-horizontal px-1">
<li><a>Link</a></li>
<li>
<details>
<summary>Parent</summary>
<ul class="bg-base-100 rounded-t-none p-2">
<li><a>Link 1</a></li>
<li><a>Link 2</a></li>
</ul>
</details>
</li>
</ul>
</div>
</div>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Navbar } from './navbar';
describe('Navbar', () => {
let component: Navbar;
let fixture: ComponentFixture<Navbar>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Navbar]
})
.compileComponents();
fixture = TestBed.createComponent(Navbar);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,11 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-navbar',
imports: [],
templateUrl: './navbar.html',
styleUrl: './navbar.css',
})
export class Navbar {
}

View File

@ -7,6 +7,8 @@ async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.useLogger(app.get(DvbookingLoggerService));
app.setGlobalPrefix('api');
const config = new DocumentBuilder()
.setTitle('DV Booking API')
.setDescription('The DV Booking API description')