Skip to content

Commit

Permalink
add FindspotService
Browse files Browse the repository at this point in the history
  • Loading branch information
fsimonjetz committed Nov 3, 2023
1 parent 02f6a82 commit 541cbf9
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/fragmentarium/application/FindspotService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Bluebird from 'bluebird'

Check failure on line 1 in src/fragmentarium/application/FindspotService.ts

View workflow job for this annotation

GitHub Actions / test

Module '"fragmentarium/domain/archaeology"' has no exported member 'fromFindspotDto'.
import { Findspot, fromFindspotDto } from 'fragmentarium/domain/archaeology'

export interface FindspotRepository {
fetchFindspots(): Bluebird<Findspot[]>
}

export class ApiFindspotRepository implements FindspotRepository {
constructor(
private readonly apiClient: {
fetchJson: (url: string, authorize: boolean) => Bluebird<any>
postJson: (url: string, body: Record<string, unknown>) => Bluebird<any>
}
) {}

fetchFindspots(): Bluebird<Findspot[]> {
return this.apiClient
.fetchJson('/findspots', false)
.then((findspots) => findspots.map(fromFindspotDto))
}
}

export class FindspotService {
constructor(private readonly findspotRepository: FindspotRepository) {}

fetchFindspots(): Bluebird<Findspot[]> {
return this.findspotRepository.fetchFindspots()
}
}

0 comments on commit 541cbf9

Please sign in to comment.