summary refs log tree commit diff
path: root/src/dto/auth
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-06-01 17:41:31 +0200
committerRory& <root@rory.gay>2025-06-01 17:41:31 +0200
commit27cda7df659852317d751b4354f75dd54878d4a7 (patch)
tree6447a352b3b8395a3f51c4c4c647bc004473218a /src/dto/auth
parentRewrite routing (diff)
downloadnodejs-final-assignment-27cda7df659852317d751b4354f75dd54878d4a7.tar.xz
Add sensor history, balance
Diffstat (limited to 'src/dto/auth')
-rw-r--r--src/dto/auth/DeviceDto.js36
1 files changed, 0 insertions, 36 deletions
diff --git a/src/dto/auth/DeviceDto.js b/src/dto/auth/DeviceDto.js
deleted file mode 100644

index 40f1959..0000000 --- a/src/dto/auth/DeviceDto.js +++ /dev/null
@@ -1,36 +0,0 @@ -import { SafeNSoundError } from '#util/error.js'; -import Joi from 'joi'; - -export class RegisterDto { - static schema = new Joi.object({ - username: Joi.string().required(), - email: Joi.string().email().required(), - password: Joi.string().required(), - type: Joi.string().valid('user', 'monitor', 'admin').required() - }); - - username; - email; - password; - type = 'user'; - - static async create(data) { - const obj = new RegisterDto(); - for (const key of Object.keys(data)) { - if (key in obj) { - obj[key] = data[key]; - } - } - - try { - return await RegisterDto.schema.validateAsync(obj); - } catch (e) { - console.log(e); - throw new SafeNSoundError({ - errCode: 'JOI_VALIDATION_ERROR', - message: e.message, - validation_details: e.details - }); - } - } -}