1.2.2 • Published 3 years ago

nestjs-abstract-module v1.2.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

nest abstract module

how use

change controller.ts

import { Controller, Get, HttpException, HttpStatus } from "@nestjs/common";
import { WrapController } from "nestjs-abstract-module";
import { UserEntity } from "./entity";
import { UserService } from "./user.service";
const CrudController = WrapController<UserEntity>({
  model: UserEntity,
  afterFunctions: {
    findOne: (result) => {
      return result;
    },
  },
});
@Controller("user")
export class UserController extends CrudController {
  constructor(private readonly service: UserService) {
    super(service);
  }
}

change service.ts

import { HttpException, HttpStatus, Injectable } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";
import { Repository, SelectQueryBuilder } from "typeorm";
import { AbstractTypeOrmService } from "nestjs-abstract-module";
import { UserEntity } from "./entity";

@Injectable()
export class UserService extends AbstractTypeOrmService<UserEntity> {
  constructor(
    @InjectRepository(UserEntity)
    private readonly repository: Repository<UserEntity>
  ) {
    super(repository, UserEntity);
  }
  getUsers(): Promise<UserEntity[]> {
    throw new HttpException("asd", HttpStatus.FORBIDDEN);
  }
}

change entity.ts

import { IsNumber, IsOptional, IsString } from "class-validator";
import { AbstractTypeEntity } from "nestjs-abstract-module";
import { Column, Entity } from "typeorm";

@Entity("users")
export class UserEntity extends AbstractTypeEntity {

}
1.2.0

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.1

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago