diff --git a/src/controllers/ScanStationController.ts b/src/controllers/ScanStationController.ts
index ac4aa11..665a010 100644
--- a/src/controllers/ScanStationController.ts
+++ b/src/controllers/ScanStationController.ts
@@ -1,7 +1,8 @@
-import { JsonController } from 'routing-controllers';
-import { OpenAPI } from 'routing-controllers-openapi';
+import { Authorized, Get, JsonController } from 'routing-controllers';
+import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { getConnectionManager, Repository } from 'typeorm';
import { ScanStation } from '../models/entities/ScanStation';
+import { ResponseScanStation } from '../models/responses/ResponseScanStation';
@JsonController('/stations')
@OpenAPI({ security: [{ "AuthToken": [] }, { "RefreshTokenCookie": [] }] })
@@ -15,19 +16,18 @@ export class ScanStationController {
this.stationRepository = getConnectionManager().get().getRepository(ScanStation);
}
- // @Get()
- // @Authorized("SCAN:GET")
- // @ResponseSchema(ResponseScan, { isArray: true })
- // @ResponseSchema(ResponseTrackScan, { isArray: true })
- // @OpenAPI({ description: 'Lists all scans (normal or track) from all runners.
This includes the runner\'s group and distance ran.' })
- // async getAll() {
- // let responseScans: ResponseScan[] = new Array();
- // const scans = await this.scanRepository.find({ relations: ['runner'] });
- // scans.forEach(scan => {
- // responseScans.push(scan.toResponse());
- // });
- // return responseScans;
- // }
+ @Get()
+ @Authorized("STATION:GET")
+ @ResponseSchema(ResponseScanStation, { isArray: true })
+ @OpenAPI({ description: 'Lists all scans (normal or track) from all runners.
This includes the runner\'s group and distance ran.' })
+ async getAll() {
+ let responseStations: ResponseScanStation[] = new Array();
+ const stations = await this.stationRepository.find({ relations: ['track'] });
+ stations.forEach(station => {
+ responseStations.push(station.toResponse());
+ });
+ return responseStations;
+ }
// @Get('/:id')
// @Authorized("SCAN:GET")
diff --git a/src/models/entities/ScanStation.ts b/src/models/entities/ScanStation.ts
index e9c03d2..93fde64 100644
--- a/src/models/entities/ScanStation.ts
+++ b/src/models/entities/ScanStation.ts
@@ -5,6 +5,7 @@ import {
IsString
} from "class-validator";
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
+import { ResponseScanStation } from '../responses/ResponseScanStation';
import { Track } from "./Track";
import { TrackScan } from "./TrackScan";
@@ -72,7 +73,7 @@ export class ScanStation {
/**
* Turns this entity into it's response class.
*/
- public toResponse() {
- return new Error("NotImplemented");
+ public toResponse(): ResponseScanStation {
+ return new ResponseScanStation(this);
}
}