mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
update imports and create ApiBasedRepository.ts stub
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
export interface IEntityWithIdAndOptionalTimestamp {
|
export interface IEntityWithIdAndOptionalTimestamp {
|
||||||
id: string;
|
id: string;
|
||||||
millisecondsSinceEpoch: number;
|
millisecondsSinceEpoch?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISystem extends IEntityWithIdAndOptionalTimestamp {
|
export interface ISystem extends IEntityWithIdAndOptionalTimestamp {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { IOrderedStop, IRoute, IShuttle, IStop, ISystem, GetterSetterRepository } from "../repositories/GetterSetterRepository";
|
import { GetterSetterRepository } from "../repositories/GetterSetterRepository";
|
||||||
|
import { IRoute, IShuttle, IStop, ISystem } from "../entities/entities";
|
||||||
|
|
||||||
const timeout = 10000;
|
const timeout = 10000;
|
||||||
const systemIdsToSupport = ["263"];
|
const systemIdsToSupport = ["263"];
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// Mock data
|
// Mock data
|
||||||
import { IEta, IOrderedStop, IRoute, IShuttle, IStop, ISystem, GetterSetterRepository } from "../repositories/GetterSetterRepository";
|
import { IEta, IOrderedStop, IRoute, IShuttle, IStop, ISystem } from "../entities/entities";
|
||||||
|
import { GetterSetterRepository } from "../repositories/GetterSetterRepository";
|
||||||
|
|
||||||
const systems: ISystem[] = [
|
const systems: ISystem[] = [
|
||||||
{
|
{
|
||||||
|
|||||||
68
src/repositories/ApiBasedRepository.ts
Normal file
68
src/repositories/ApiBasedRepository.ts
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
import { GetterRepository } from "./GetterRepository";
|
||||||
|
import { IEta } from "../entities/entities";
|
||||||
|
|
||||||
|
export class ApiBasedRepository implements GetterRepository {
|
||||||
|
public async getEtaForShuttleAndStopId(shuttleId: string, stopId: string): Promise<IEta | null> {
|
||||||
|
// TODO: implement
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getEtasForShuttleId(shuttleId: string): Promise<[]> {
|
||||||
|
// TODO: implement
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getEtasForStopId(stopId: string): Promise<[]> {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getOrderedStopByRouteAndStopId(routeId: string, stopId: string): Promise<| null> {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getOrderedStopsByRouteId(routeId: string): Promise<[]> {
|
||||||
|
return Promise.resolve([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getOrderedStopsByStopId(stopId: string): Promise<[]> {
|
||||||
|
return Promise.resolve([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getRouteById(routeId: string): Promise<| null> {
|
||||||
|
return Promise.resolve(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getRoutesBySystemId(systemId: string): Promise<[]> {
|
||||||
|
return Promise.resolve([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getShuttleById(shuttleId: string): Promise<| null> {
|
||||||
|
return Promise.resolve(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getShuttlesByRouteId(routeId: string): Promise<[]> {
|
||||||
|
return Promise.resolve([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getShuttlesBySystemId(systemId: string): Promise<[]> {
|
||||||
|
return Promise.resolve([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getStopById(stopId: string): Promise<| null> {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getStopsBySystemId(systemId: string): Promise<[]> {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getSystemById(systemId: string): Promise<| null> {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getSystems(): Promise<[]> {
|
||||||
|
return Promise.resolve([]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { IEta, IOrderedStop, IRoute, IShuttle, IStop, ISystem } from "./GetterSetterRepository";
|
import { IEta, IOrderedStop, IRoute, IShuttle, IStop, ISystem } from "../entities/entities";
|
||||||
|
|
||||||
export interface GetterRepository {
|
export interface GetterRepository {
|
||||||
getSystems(): Promise<ISystem[]>;
|
getSystems(): Promise<ISystem[]>;
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
import { IEntityWithId, IEta, IOrderedStop, IRoute, IShuttle, IStop, ISystem, GetterSetterRepository } from "./GetterSetterRepository";
|
import { GetterSetterRepository } from "./GetterSetterRepository";
|
||||||
|
import {
|
||||||
|
IEntityWithIdAndOptionalTimestamp,
|
||||||
|
IEta,
|
||||||
|
IOrderedStop,
|
||||||
|
IRoute,
|
||||||
|
IShuttle,
|
||||||
|
IStop,
|
||||||
|
ISystem
|
||||||
|
} from "../entities/entities";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An unoptimized in memory repository.
|
* An unoptimized in memory repository.
|
||||||
@@ -73,7 +82,7 @@ export class UnoptimizedInMemoryRepository implements GetterSetterRepository {
|
|||||||
return this.orderedStops.filter((value) => value.routeId === routeId);
|
return this.orderedStops.filter((value) => value.routeId === routeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private findEntityById<T extends IEntityWithId>(entityId: string, arrayToSearchIn: T[]) {
|
private findEntityById<T extends IEntityWithIdAndOptionalTimestamp>(entityId: string, arrayToSearchIn: T[]) {
|
||||||
return this.findEntityByMatcher((value) => value.id === entityId, arrayToSearchIn);
|
return this.findEntityByMatcher((value) => value.id === entityId, arrayToSearchIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user