import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { PackageListComponent } from './components/package-list/package-list.component';
import { PackageComponent } from './components/package/package.component';
import { PackageResolver } from './resolvers/package/package.resolver';

const routes: Routes = [
  {
    path: 'packages',
    component: PackageListComponent
  },
  {
    path: 'packages/:id',
    component: PackageComponent,
    resolve: {
      package: PackageResolver,
    },
  },
  {
    path: '',
    pathMatch: 'full',
    redirectTo: 'packages',
  },
  {
   path: '**',
   redirectTo: 'packages',
  },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
