Added the new statsClient class for stats api auth

ref #56
This commit is contained in:
Nicolai Ort 2020-12-29 19:29:16 +01:00
parent 63b8176bdf
commit a738c19316
1 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,33 @@
import { IsInt, IsOptional, IsString } from "class-validator";
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
/**
* Defines the StatsClient entity.
* StatsClients can be used to access the protected parts of the stats api (top runners, donators and so on).
*/
@Entity()
export abstract class StatsClient {
/**
* Autogenerated unique id (primary key).
*/
@PrimaryGeneratedColumn()
@IsInt()
id: number;
/**
* The clients's description.
* Mostly for better UX when traceing back stuff.
*/
@Column({ nullable: true })
@IsOptional()
@IsString()
description?: string;
/**
* The client's api key.
* This is used to authorize a statsClient against the api.
* It only grants access to the /stats/** routes.
*/
@Column()
@IsString()
key: string;
}