diff --git a/src/controllers/ScanStationController.ts b/src/controllers/ScanStationController.ts
index 80aa6e3..30c10d3 100644
--- a/src/controllers/ScanStationController.ts
+++ b/src/controllers/ScanStationController.ts
@@ -1,8 +1,10 @@
-import { Authorized, Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put, QueryParam } from 'routing-controllers';
+import { Request } from 'express';
+import { Authorized, Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put, QueryParam, Req, UseBefore } from 'routing-controllers';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { getConnectionManager, Repository } from 'typeorm';
import { ScanStationHasScansError, ScanStationIdsNotMatchingError, ScanStationNotFoundError } from '../errors/ScanStationErrors';
import { TrackNotFoundError } from '../errors/TrackErrors';
+import ScanAuth from '../middlewares/ScanAuth';
import { CreateScanStation } from '../models/actions/create/CreateScanStation';
import { UpdateScanStation } from '../models/actions/update/UpdateScanStation';
import { ScanStation } from '../models/entities/ScanStation';
@@ -47,6 +49,18 @@ export class ScanStationController {
return scan.toResponse();
}
+ @Get('/:id/me')
+ @UseBefore(ScanAuth)
+ @ResponseSchema(ResponseScanStation)
+ @ResponseSchema(ScanStationNotFoundError, { statusCode: 404 })
+ @OnUndefined(ScanStationNotFoundError)
+ @OpenAPI({ description: 'Lists basic information about the station whose token got provided.
This includes it\'s associated track.
Just set the ID to 0.', security: [{ "ScanApiToken": [] }] })
+ async getMe(@Req() req: Request) {
+ let scan = await this.stationRepository.findOne({ id: parseInt(req.headers["station_id"].toString()) }, { relations: ['track'] })
+ if (!scan) { throw new ScanStationNotFoundError(); }
+ return scan.toResponse();
+ }
+
@Post()
@Authorized("STATION:CREATE")
@ResponseSchema(ResponseScanStation)