小编igo*_*gor的帖子

How not to show the login page for a logged in user in angular

I have an auth module and the routing auth module contains the following routes:

const authRoutes: Routes = [
    {
        path: 'sign-in', component: SignInComponent
    }
];
Run Code Online (Sandbox Code Playgroud)

The dashboard routing module contains the following routes:

const dashboardRoutes: Routes = [
  { path: 'home', component: HomeComponent, canActivate: [IsAuthenticatedGuard] }
];

Run Code Online (Sandbox Code Playgroud)

The app (root) routing module contains the following route configurations:

const appRoutes: Routes = [
  { path: '', redirectTo: 'home', pathMatch: 'full' },
  { path: '**', component: PageNotFoundComponent }
];
Run Code Online (Sandbox Code Playgroud)

So when …

typescript angular

2
推荐指数
1
解决办法
56
查看次数

Nestjs 中的元类型是什么?

阅读 Nestjs 官方文档,我发现了以下实现ValidationPipe

import { PipeTransform, Injectable, ArgumentMetadata, BadRequestException } from '@nestjs/common';
import { validate } from 'class-validator';
import { plainToClass } from 'class-transformer';

@Injectable()
export class ValidationPipe implements PipeTransform<any> {
  async transform(value: any, { metatype }: ArgumentMetadata) {
    if (!metatype || !this.toValidate(metatype)) {
      return value;
    }
    const object = plainToClass(metatype, value);
    const errors = await validate(object);
    if (errors.length > 0) {
      throw new BadRequestException('Validation failed');
    }
    return value;
  }

  private toValidate(metatype: Function): boolean {
    const types: Function[] …
Run Code Online (Sandbox Code Playgroud)

typescript nestjs

0
推荐指数
1
解决办法
1352
查看次数

标签 统计

typescript ×2

angular ×1

nestjs ×1