-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add countries module with custom repository
- Loading branch information
Showing
15 changed files
with
86 additions
and
9 deletions.
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
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 @@ | ||
import { Controller } from '@nestjs/common'; | ||
|
||
@Controller('countries') | ||
export class CountriesController {} |
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,16 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { Country } from '@shared/entities/countries/country.entity'; | ||
import { CountriesController } from '@api/modules/countries/countries.controller'; | ||
|
||
import { MapController } from './map/map.controller'; | ||
import { CountryRepository } from '@api/modules/countries/countries.repository'; | ||
import { MapRepository } from '@api/modules/countries/map/map.repository'; | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([Country])], | ||
controllers: [CountriesController, MapController], | ||
providers: [CountryRepository, MapRepository], | ||
exports: [], | ||
}) | ||
export class CountriesModule {} |
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,14 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { Repository } from 'typeorm'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Country } from '@shared/entities/countries/country.entity'; | ||
|
||
@Injectable() | ||
export class CountryRepository extends Repository<Country> { | ||
constructor( | ||
@InjectRepository(Country) | ||
private readonly repository: Repository<Country>, | ||
) { | ||
super(repository.target, repository.manager, repository.queryRunner); | ||
} | ||
} |
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,9 @@ | ||
import { Controller, Get } from '@nestjs/common'; | ||
|
||
@Controller('map') | ||
export class MapController { | ||
@Get('/geojson') | ||
getGeoJson() { | ||
return 'This will return the geojson of the countries'; | ||
} | ||
} |
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,14 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { Repository } from 'typeorm'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Country } from '@shared/entities/countries/country.entity'; | ||
|
||
@Injectable() | ||
export class MapRepository extends Repository<Country> { | ||
constructor( | ||
@InjectRepository(Country) | ||
private readonly repository: Repository<Country>, | ||
) { | ||
super(repository.target, repository.manager, repository.queryRunner); | ||
} | ||
} |
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { User } from "@shared/entities/users/user.entity"; | ||
import { Country } from "@shared/entities/countries/country.entity"; | ||
|
||
export const COMMON_DATABASE_ENTITIES = [User]; | ||
export const COMMON_DATABASE_ENTITIES = [User, Country]; |
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