parent
aad2c81993
commit
143666f5dd
@ -1,22 +0,0 @@ |
||||
import { Test, TestingModule } from '@nestjs/testing'; |
||||
import { AppController } from './app.controller'; |
||||
import { AppService } from './app.service'; |
||||
|
||||
describe('AppController', () => { |
||||
let appController: AppController; |
||||
|
||||
beforeEach(async () => { |
||||
const app: TestingModule = await Test.createTestingModule({ |
||||
controllers: [AppController], |
||||
providers: [AppService], |
||||
}).compile(); |
||||
|
||||
appController = app.get<AppController>(AppController); |
||||
}); |
||||
|
||||
describe('root', () => { |
||||
it('should return "Hello World!"', () => { |
||||
expect(appController.getHello()).toBe('Hello World!'); |
||||
}); |
||||
}); |
||||
}); |
@ -1,12 +0,0 @@ |
||||
import { Controller, Get } from '@nestjs/common'; |
||||
import { AppService } from './app.service'; |
||||
|
||||
@Controller() |
||||
export class AppController { |
||||
constructor(private readonly appService: AppService) {} |
||||
|
||||
@Get() |
||||
getHello(): string { |
||||
return this.appService.getHello(); |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
import { createOsmClient } from '../integration/geocoding/osm'; |
||||
import { GeocodingProvider } from '../integration/geocoding/types'; |
||||
import { createCachedDataProvider } from '../storage/cache'; |
||||
import { createKeyValueStorage } from '../storage/inMemoryDB'; |
||||
|
||||
export const createOsmClientWithCache = (): GeocodingProvider => { |
||||
return { |
||||
geocode: createCachedDataProvider({ |
||||
cacheStorage: createKeyValueStorage(20), |
||||
getNewValue: createOsmClient().geocode, |
||||
ttlMs: 86_400_000, |
||||
}), |
||||
}; |
||||
}; |
@ -0,0 +1,14 @@ |
||||
import { createOpenmeteoClient } from '../integration/weather/openmeteo'; |
||||
import { WeatherProvider } from '../integration/weather/types'; |
||||
import { createCachedDataProvider } from '../storage/cache'; |
||||
import { createKeyValueStorage } from '../storage/inMemoryDB'; |
||||
|
||||
export const createOpenmeteoClientWithCache = (): WeatherProvider => { |
||||
return { |
||||
getCurrentWeather: createCachedDataProvider({ |
||||
cacheStorage: createKeyValueStorage(20), |
||||
getNewValue: createOpenmeteoClient().getCurrentWeather, |
||||
ttlMs: 7_200_000, |
||||
}), |
||||
}; |
||||
}; |
@ -1,10 +0,0 @@ |
||||
export type WeatherProvider = { |
||||
getCurrentWeather(params: { |
||||
longitude: number; |
||||
latitude: number; |
||||
}): Promise<{ |
||||
temperature: string; |
||||
apparentTemperature: string; |
||||
relativeHumidity: string; |
||||
}>; |
||||
}; |
@ -1,5 +1,8 @@ |
||||
export type GeocodingProvider = { |
||||
geocode(query: string): Promise<{ |
||||
geocode( |
||||
this: void, |
||||
query: string, |
||||
): Promise<{ |
||||
longitude: number; |
||||
latitude: number; |
||||
}>; |
@ -0,0 +1,13 @@ |
||||
export type WeatherProvider = { |
||||
getCurrentWeather( |
||||
this: void, |
||||
params: { |
||||
longitude: number; |
||||
latitude: number; |
||||
}, |
||||
): Promise<{ |
||||
temperature: string; |
||||
apparentTemperature: string; |
||||
relativeHumidity: string; |
||||
}>; |
||||
}; |
Loading…
Reference in new issue