diff --git a/src/models/actions/CreateStatsClient.ts b/src/models/actions/CreateStatsClient.ts new file mode 100644 index 0000000..83fa199 --- /dev/null +++ b/src/models/actions/CreateStatsClient.ts @@ -0,0 +1,26 @@ +import { IsOptional, IsString } from 'class-validator'; +import crypto from "crypto"; +import { StatsClient } from '../entities/StatsClient'; +/** + * This classed is used to create a new StatsClient entity from a json body (post request). + */ +export class CreateStatsClient { + /** + * The new clients's description. + */ + @IsString() + @IsOptional() + description?: string; + + /** + * Converts this to a StatsClient entity. + */ + public async toStatsClient(): Promise { + let newClient: StatsClient = new StatsClient(); + + newClient.description = this.description; + newClient.key = crypto.randomBytes(20).toString('hex'); + + return newClient; + } +} \ No newline at end of file