-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add v3 lent module #114
- Loading branch information
Showing
6 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Controller, Get, Logger, UseGuards } from '@nestjs/common'; | ||
import { JWTAuthGuard } from 'src/auth/auth.guard'; | ||
import { LentService } from './lent.service'; | ||
|
||
@Controller('lent') | ||
@UseGuards(JWTAuthGuard) | ||
export class LentController { | ||
private logger = new Logger(LentController.name); | ||
|
||
constructor(private lentService: LentService) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { AuthModule } from 'src/auth/auth.module'; | ||
import Lent from 'src/entities/lent.entity'; | ||
import { LentController } from './lent.controller'; | ||
import { LentService } from './lent.service'; | ||
import { LentRepository } from './repository/lent.repository'; | ||
|
||
const repo = { | ||
provide: 'ILentRepository', | ||
useClass: LentRepository, | ||
}; | ||
|
||
@Module({ | ||
controllers: [LentController], | ||
providers: [LentService, repo], | ||
imports: [AuthModule, TypeOrmModule.forFeature([Lent])], // for JWTAuthGuard | ||
}) | ||
export class LentModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Inject, Injectable, Logger } from '@nestjs/common'; | ||
import { ILentRepository } from './repository/lent.repository.interface'; | ||
|
||
@Injectable() | ||
export class LentService { | ||
private logger = new Logger(LentService.name); | ||
|
||
constructor( | ||
@Inject('ILentRepository') | ||
private lentRepository: ILentRepository, | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface ILentRepository { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { InjectRepository } from "@nestjs/typeorm"; | ||
import Lent from "src/entities/lent.entity"; | ||
import { Repository } from "typeorm"; | ||
import { ILentRepository } from "./lent.repository.interface"; | ||
|
||
export class LentRepository implements ILentRepository { | ||
constructor( | ||
@InjectRepository(Lent) | ||
private lentRepository: Repository<Lent>, | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters