@@ -52,7 +52,7 @@ export class DonorController {
 | 
				
			|||||||
	async post(@Body({ validate: true }) createRunner: CreateDonor) {
 | 
						async post(@Body({ validate: true }) createRunner: CreateDonor) {
 | 
				
			||||||
		let donor;
 | 
							let donor;
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			donor = await createRunner.toDonor();
 | 
								donor = await createRunner.toEntity();
 | 
				
			||||||
		} catch (error) {
 | 
							} catch (error) {
 | 
				
			||||||
			throw error;
 | 
								throw error;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -58,7 +58,7 @@ export class PermissionController {
 | 
				
			|||||||
    async post(@Body({ validate: true }) createPermission: CreatePermission) {
 | 
					    async post(@Body({ validate: true }) createPermission: CreatePermission) {
 | 
				
			||||||
        let permission;
 | 
					        let permission;
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            permission = await createPermission.toPermission();
 | 
					            permission = await createPermission.toEntity();
 | 
				
			||||||
        } catch (error) {
 | 
					        } catch (error) {
 | 
				
			||||||
            throw error;
 | 
					            throw error;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,7 +57,7 @@ export class RunnerController {
 | 
				
			|||||||
	async post(@Body({ validate: true }) createRunner: CreateRunner) {
 | 
						async post(@Body({ validate: true }) createRunner: CreateRunner) {
 | 
				
			||||||
		let runner;
 | 
							let runner;
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			runner = await createRunner.toRunner();
 | 
								runner = await createRunner.toEntity();
 | 
				
			||||||
		} catch (error) {
 | 
							} catch (error) {
 | 
				
			||||||
			throw error;
 | 
								throw error;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,7 +55,7 @@ export class RunnerOrganisationController {
 | 
				
			|||||||
	async post(@Body({ validate: true }) createRunnerOrganisation: CreateRunnerOrganisation) {
 | 
						async post(@Body({ validate: true }) createRunnerOrganisation: CreateRunnerOrganisation) {
 | 
				
			||||||
		let runnerOrganisation;
 | 
							let runnerOrganisation;
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			runnerOrganisation = await createRunnerOrganisation.toRunnerOrganisation();
 | 
								runnerOrganisation = await createRunnerOrganisation.toEntity();
 | 
				
			||||||
		} catch (error) {
 | 
							} catch (error) {
 | 
				
			||||||
			throw error;
 | 
								throw error;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -62,7 +62,7 @@ export class ScanController {
 | 
				
			|||||||
	@ResponseSchema(RunnerNotFoundError, { statusCode: 404 })
 | 
						@ResponseSchema(RunnerNotFoundError, { statusCode: 404 })
 | 
				
			||||||
	@OpenAPI({ description: 'Create a new scan (not track scan - use /scans/trackscans instead). <br> Please rmemember to provide the scan\'s runner\'s id and distance.', security: [{ "ScanApiToken": [] }, { "AuthToken": [] }, { "RefreshTokenCookie": [] }] })
 | 
						@OpenAPI({ description: 'Create a new scan (not track scan - use /scans/trackscans instead). <br> Please rmemember to provide the scan\'s runner\'s id and distance.', security: [{ "ScanApiToken": [] }, { "AuthToken": [] }, { "RefreshTokenCookie": [] }] })
 | 
				
			||||||
	async post(@Body({ validate: true }) createScan: CreateScan) {
 | 
						async post(@Body({ validate: true }) createScan: CreateScan) {
 | 
				
			||||||
		let scan = await createScan.toScan();
 | 
							let scan = await createScan.toEntity();
 | 
				
			||||||
		scan = await this.scanRepository.save(scan);
 | 
							scan = await this.scanRepository.save(scan);
 | 
				
			||||||
		return (await this.scanRepository.findOne({ id: scan.id }, { relations: ['runner', 'track', 'runner.scans', 'runner.scans.track', 'card', 'station'] })).toResponse();
 | 
							return (await this.scanRepository.findOne({ id: scan.id }, { relations: ['runner', 'track', 'runner.scans', 'runner.scans.track', 'card', 'station'] })).toResponse();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -73,7 +73,7 @@ export class ScanController {
 | 
				
			|||||||
	@ResponseSchema(RunnerNotFoundError, { statusCode: 404 })
 | 
						@ResponseSchema(RunnerNotFoundError, { statusCode: 404 })
 | 
				
			||||||
	@OpenAPI({ description: 'Create a new track scan (for "normal" scans use /scans instead). <br> Please remember that to provide the scan\'s card\'s station\'s id.', security: [{ "ScanApiToken": [] }, { "AuthToken": [] }, { "RefreshTokenCookie": [] }] })
 | 
						@OpenAPI({ description: 'Create a new track scan (for "normal" scans use /scans instead). <br> Please remember that to provide the scan\'s card\'s station\'s id.', security: [{ "ScanApiToken": [] }, { "AuthToken": [] }, { "RefreshTokenCookie": [] }] })
 | 
				
			||||||
	async postTrackScans(@Body({ validate: true }) createScan: CreateTrackScan) {
 | 
						async postTrackScans(@Body({ validate: true }) createScan: CreateTrackScan) {
 | 
				
			||||||
		let scan = await createScan.toScan();
 | 
							let scan = await createScan.toEntity();
 | 
				
			||||||
		scan = await this.trackScanRepository.save(scan);
 | 
							scan = await this.trackScanRepository.save(scan);
 | 
				
			||||||
		return (await this.scanRepository.findOne({ id: scan.id }, { relations: ['runner', 'track', 'runner.scans', 'runner.scans.track', 'card', 'station'] })).toResponse();
 | 
							return (await this.scanRepository.findOne({ id: scan.id }, { relations: ['runner', 'track', 'runner.scans', 'runner.scans.track', 'card', 'station'] })).toResponse();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -53,7 +53,7 @@ export class StatsClientController {
 | 
				
			|||||||
		@Body({ validate: true })
 | 
							@Body({ validate: true })
 | 
				
			||||||
		client: CreateStatsClient
 | 
							client: CreateStatsClient
 | 
				
			||||||
	) {
 | 
						) {
 | 
				
			||||||
		let newClient = await this.clientRepository.save(await client.toStatsClient());
 | 
							let newClient = await this.clientRepository.save(await client.toEntity());
 | 
				
			||||||
		let responseClient = new ResponseStatsClient(newClient);
 | 
							let responseClient = new ResponseStatsClient(newClient);
 | 
				
			||||||
		responseClient.key = newClient.cleartextkey;
 | 
							responseClient.key = newClient.cleartextkey;
 | 
				
			||||||
		return responseClient;
 | 
							return responseClient;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,7 +55,7 @@ export class TrackController {
 | 
				
			|||||||
		@Body({ validate: true })
 | 
							@Body({ validate: true })
 | 
				
			||||||
		track: CreateTrack
 | 
							track: CreateTrack
 | 
				
			||||||
	) {
 | 
						) {
 | 
				
			||||||
		return new ResponseTrack(await this.trackRepository.save(track.toTrack()));
 | 
							return new ResponseTrack(await this.trackRepository.save(track.toEntity()));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Put('/:id')
 | 
						@Put('/:id')
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,7 +56,7 @@ export class UserController {
 | 
				
			|||||||
	async post(@Body({ validate: true }) createUser: CreateUser) {
 | 
						async post(@Body({ validate: true }) createUser: CreateUser) {
 | 
				
			||||||
		let user;
 | 
							let user;
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			user = await createUser.toUser();
 | 
								user = await createUser.toEntity();
 | 
				
			||||||
		} catch (error) {
 | 
							} catch (error) {
 | 
				
			||||||
			throw error;
 | 
								throw error;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -48,7 +48,7 @@ export class UserGroupController {
 | 
				
			|||||||
	async post(@Body({ validate: true }) createUserGroup: CreateUserGroup) {
 | 
						async post(@Body({ validate: true }) createUserGroup: CreateUserGroup) {
 | 
				
			||||||
		let userGroup;
 | 
							let userGroup;
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			userGroup = await createUserGroup.toUserGroup();
 | 
								userGroup = await createUserGroup.toEntity();
 | 
				
			||||||
		} catch (error) {
 | 
							} catch (error) {
 | 
				
			||||||
			throw error;
 | 
								throw error;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,7 +56,7 @@ export class CreateAddress {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates a new Address entity from this.
 | 
					     * Creates a new Address entity from this.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public toAddress(): Address {
 | 
					    public toEntity(): Address {
 | 
				
			||||||
        let newAddress: Address = new Address();
 | 
					        let newAddress: Address = new Address();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        newAddress.address1 = this.address1;
 | 
					        newAddress.address1 = this.address1;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,7 +18,7 @@ export class CreateDonor extends CreateParticipant {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates a new Donor entity from this.
 | 
					     * Creates a new Donor entity from this.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public async toDonor(): Promise<Donor> {
 | 
					    public async toEntity(): Promise<Donor> {
 | 
				
			||||||
        let newDonor: Donor = new Donor();
 | 
					        let newDonor: Donor = new Donor();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        newDonor.firstname = this.firstname;
 | 
					        newDonor.firstname = this.firstname;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -72,7 +72,7 @@ export class CreateGroupContact {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates a new Address entity from this.
 | 
					     * Creates a new Address entity from this.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public async toGroupContact(): Promise<GroupContact> {
 | 
					    public async toEntity(): Promise<GroupContact> {
 | 
				
			||||||
        let contact: GroupContact = new GroupContact();
 | 
					        let contact: GroupContact = new GroupContact();
 | 
				
			||||||
        contact.firstname = this.firstname;
 | 
					        contact.firstname = this.firstname;
 | 
				
			||||||
        contact.middlename = this.middlename;
 | 
					        contact.middlename = this.middlename;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,7 +39,7 @@ export class CreatePermission {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates a new Permission entity from this.
 | 
					     * Creates a new Permission entity from this.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public async toPermission(): Promise<Permission> {
 | 
					    public async toEntity(): Promise<Permission> {
 | 
				
			||||||
        let newPermission: Permission = new Permission();
 | 
					        let newPermission: Permission = new Permission();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        newPermission.principal = await this.getPrincipal();
 | 
					        newPermission.principal = await this.getPrincipal();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,7 +21,7 @@ export class CreateRunner extends CreateParticipant {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates a new Runner entity from this.
 | 
					     * Creates a new Runner entity from this.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public async toRunner(): Promise<Runner> {
 | 
					    public async toEntity(): Promise<Runner> {
 | 
				
			||||||
        let newRunner: Runner = new Runner();
 | 
					        let newRunner: Runner = new Runner();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        newRunner.firstname = this.firstname;
 | 
					        newRunner.firstname = this.firstname;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,7 +36,7 @@ export class CreateRunnerOrganisation extends CreateRunnerGroup {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates a new RunnerOrganisation entity from this.
 | 
					     * Creates a new RunnerOrganisation entity from this.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public async toRunnerOrganisation(): Promise<RunnerOrganisation> {
 | 
					    public async toEntity(): Promise<RunnerOrganisation> {
 | 
				
			||||||
        let newRunnerOrganisation: RunnerOrganisation = new RunnerOrganisation();
 | 
					        let newRunnerOrganisation: RunnerOrganisation = new RunnerOrganisation();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        newRunnerOrganisation.name = this.name;
 | 
					        newRunnerOrganisation.name = this.name;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,7 +36,7 @@ export abstract class CreateScan {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates a new Scan entity from this.
 | 
					     * Creates a new Scan entity from this.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public async toScan(): Promise<Scan> {
 | 
					    public async toEntity(): Promise<Scan> {
 | 
				
			||||||
        let newScan = new Scan();
 | 
					        let newScan = new Scan();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        newScan.distance = this.distance;
 | 
					        newScan.distance = this.distance;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,7 +18,7 @@ export class CreateStatsClient {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Converts this to a StatsClient entity.
 | 
					     * Converts this to a StatsClient entity.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public async toStatsClient(): Promise<StatsClient> {
 | 
					    public async toEntity(): Promise<StatsClient> {
 | 
				
			||||||
        let newClient: StatsClient = new StatsClient();
 | 
					        let newClient: StatsClient = new StatsClient();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        newClient.description = this.description;
 | 
					        newClient.description = this.description;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,7 +31,7 @@ export class CreateTrack {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates a new Track entity from this.
 | 
					     * Creates a new Track entity from this.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public toTrack(): Track {
 | 
					    public toEntity(): Track {
 | 
				
			||||||
        let newTrack: Track = new Track();
 | 
					        let newTrack: Track = new Track();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        newTrack.name = this.name;
 | 
					        newTrack.name = this.name;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,7 +30,7 @@ export class CreateTrackScan {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates a new Track entity from this.
 | 
					     * Creates a new Track entity from this.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public async toScan(): Promise<TrackScan> {
 | 
					    public async toEntity(): Promise<TrackScan> {
 | 
				
			||||||
        let newScan: TrackScan = new TrackScan();
 | 
					        let newScan: TrackScan = new TrackScan();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        newScan.station = await this.getStation();
 | 
					        newScan.station = await this.getStation();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -89,7 +89,7 @@ export class CreateUser {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Converts this to a User entity.
 | 
					     * Converts this to a User entity.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public async toUser(): Promise<User> {
 | 
					    public async toEntity(): Promise<User> {
 | 
				
			||||||
        let newUser: User = new User();
 | 
					        let newUser: User = new User();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (this.email === undefined && this.username === undefined) {
 | 
					        if (this.email === undefined && this.username === undefined) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,7 +22,7 @@ export class CreateUserGroup {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates a new UserGroup entity from this.
 | 
					     * Creates a new UserGroup entity from this.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public async toUserGroup(): Promise<UserGroup> {
 | 
					    public async toEntity(): Promise<UserGroup> {
 | 
				
			||||||
        let newUserGroup: UserGroup = new UserGroup();
 | 
					        let newUserGroup: UserGroup = new UserGroup();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        newUserGroup.name = this.name;
 | 
					        newUserGroup.name = this.name;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,7 +24,7 @@ export default class SeedUsers implements Seeder {
 | 
				
			|||||||
        let adminGroup = new CreateUserGroup();
 | 
					        let adminGroup = new CreateUserGroup();
 | 
				
			||||||
        adminGroup.name = "ADMINS";
 | 
					        adminGroup.name = "ADMINS";
 | 
				
			||||||
        adminGroup.description = "Have all possible permissions";
 | 
					        adminGroup.description = "Have all possible permissions";
 | 
				
			||||||
        return await connection.getRepository(UserGroup).save(await adminGroup.toUserGroup());
 | 
					        return await connection.getRepository(UserGroup).save(await adminGroup.toEntity());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public async createUser(connection: Connection, group: number) {
 | 
					    public async createUser(connection: Connection, group: number) {
 | 
				
			||||||
@@ -34,7 +34,7 @@ export default class SeedUsers implements Seeder {
 | 
				
			|||||||
        initialUser.username = "demo";
 | 
					        initialUser.username = "demo";
 | 
				
			||||||
        initialUser.password = "demo";
 | 
					        initialUser.password = "demo";
 | 
				
			||||||
        initialUser.groups = group;
 | 
					        initialUser.groups = group;
 | 
				
			||||||
        return await connection.getRepository(User).save(await initialUser.toUser());
 | 
					        return await connection.getRepository(User).save(await initialUser.toEntity());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public async createPermissions(connection: Connection, principal: number) {
 | 
					    public async createPermissions(connection: Connection, principal: number) {
 | 
				
			||||||
@@ -45,7 +45,7 @@ export default class SeedUsers implements Seeder {
 | 
				
			|||||||
                permission.target = <PermissionTarget>target;
 | 
					                permission.target = <PermissionTarget>target;
 | 
				
			||||||
                permission.action = <PermissionAction>action;
 | 
					                permission.action = <PermissionAction>action;
 | 
				
			||||||
                permission.principal = principal;
 | 
					                permission.principal = principal;
 | 
				
			||||||
                await repo.save(await permission.toPermission());
 | 
					                await repo.save(await permission.toEntity());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user