39 lines
886 B
TypeScript
39 lines
886 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { DiscoveryService, MetadataScanner, Reflector } from '@nestjs/core';
|
|
|
|
export interface NavItem {
|
|
path: string;
|
|
label: string;
|
|
active: boolean;
|
|
}
|
|
|
|
@Injectable()
|
|
export class NavigationService {
|
|
constructor(
|
|
private readonly discovery: DiscoveryService,
|
|
private readonly metadataScanner: MetadataScanner,
|
|
private readonly reflector: Reflector,
|
|
) {}
|
|
|
|
private isGetMethod(handler: (...args: any[]) => any): boolean {
|
|
return Reflect.getMetadata('method', handler) === 'GET';
|
|
}
|
|
|
|
getNavigationItems(currentPath: string = '/'): NavItem[] {
|
|
const navItems: NavItem[] = [
|
|
{
|
|
path: '/',
|
|
label: 'Home',
|
|
active: currentPath === '/',
|
|
},
|
|
{
|
|
path: '/cats',
|
|
label: 'Cats',
|
|
active: currentPath === '/cats',
|
|
},
|
|
];
|
|
|
|
return navItems;
|
|
}
|
|
}
|