Merge for alpha 0.0.6 #61

Merged
niggl merged 39 commits from dev into main 2020-12-30 17:58:27 +00:00
Showing only changes of commit bb24ed53a4 - Show all commits

View File

@ -1,6 +1,8 @@
import * as argon2 from "argon2";
import { IsBoolean, IsOptional, IsString } from 'class-validator';
import crypto from "crypto";
import * as uuid from 'uuid';
import { StatsClient } from '../entities/StatsClient';
/**
* This classed is used to create a new StatsClient entity from a json body (post request).
*/
@ -22,11 +24,11 @@ export class CreateStatsClient {
/**
* Converts this to a StatsClient entity.
*/
public toStatsClient(): StatsClient {
public async toStatsClient(): Promise<StatsClient> {
let newClient: StatsClient = new StatsClient();
newClient.description = this.description;
newClient.key = crypto.randomBytes(20).toString('hex');
newClient.key = await argon2.hash(uuid.v4());
if (this.enabled === undefined || this.enabled === null) { newClient.enabled = true; }
else { newClient.enabled = this.enabled }