parent
ce55dce011
commit
e2cc0c0b80
|
@ -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<StatsClient> {
|
||||
let newClient: StatsClient = new StatsClient();
|
||||
|
||||
newClient.description = this.description;
|
||||
newClient.key = crypto.randomBytes(20).toString('hex');
|
||||
|
||||
return newClient;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue