1.3.0 • Published 2 years ago

sd-nest-base v1.3.0

Weekly downloads
4
License
MIT
Repository
-
Last release
2 years ago

add new functionality

Entity

  • add => nest g cl <name>/<name>.entity
  • inherit from BaseEntity from 'typeorm' feature.entity.ts
  • don't forget to add the line @Entity()
import { Base } from './../base.entity';

@Entity()
export class Feature extends Base {
  ...
}

Service

  • add => nest g s <name>
  • inherit from BaseService from './../base.service.ts' feature.service.ts
import { Injectable } from '@nestjs/common';
import { FeatureService } from './../feature.service';
import { Feature } from './feature.entity';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';

@Injectable()
export class FeatureService extends BaseService<Product> {
    constructor(
        @InjectRepository(Feature)
        private readonly fRepo: Repository<Feature>,
    ) {
        super(fRepo);
    }
}

Controller

  • add => nest g co <name>
  • inherit from BaseController from './../base.controller.ts'
  • issue at testing with <name>.controller.spec.ts yet. Remove this file! feature.controller.ts
import { FeatureService } from './feature.service';
import { Controller } from '@nestjs/common';
import { Feature } from './feature.entity';
import { BaseController } from './../base.controller';

@Controller('feature')
export class FeatureController extends BaseController<Feature> {
    constructor(public readonly service: FeatureService) {
        super();
    }
}

Module

  • add => nest g mo <name>

feature.module.ts

@Module({
    imports: [TypeOrmModule.forFeature([Feature])],
    providers: [FeatureService],
    controllers: [FeatureController],
})
export class FeatureModule {}

app.module.ts ( example for mongodb)

@Module({
  imports: [TypeOrmModule.forRoot({
      type: 'mongodb',
      host: 'localhost',
      database: 'ApiCalls',
      entities: [join(__dirname, '**/**.entity{.ts,.js}')],
      synchronize: true,
      useNewUrlParser: true,
    }),
    ...
    FeatureModule,
  ],
})
export class AppModule { }
1.2.7

2 years ago

1.2.6

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

0.1.4

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago