- Added A TON of stuff, separated everything neatly and cleaned most models

This commit is contained in:
Alexis
2020-06-08 19:55:36 +02:00
parent ce9018f65e
commit 48987b8349
28 changed files with 602 additions and 171 deletions

13
validations/Errors.js Normal file
View File

@@ -0,0 +1,13 @@
// Http error w/ http code
class HttpError extends Error {
constructor(code, message) {
super(message)
this.name = "HttpError"
this.code = code
Error.captureStackTrace(this, this.constructor);
}
}
module.exports = {
HttpError
}

View File

@@ -0,0 +1,10 @@
const Ingredient = {
"id": "/IngredientValidation",
"type": Object,
"properties": {
"name": { "type": "string" },
},
"required": ["name"]
}
module.exports = Ingredient

View File

@@ -0,0 +1,12 @@
const MetaSchool = {
"id": "/MetaSchoolValidation",
"type": Object,
"properties": {
"name": { "type": "string" },
"description": { "type": "string" },
"schools": { "type": "array" }
},
"required": ["name", "description"]
}
module.exports = MetaSchool

View File

@@ -0,0 +1,12 @@
const School = {
"id": "/SchoolValidation",
"type": Object,
"properties": {
"name": { "type": "string" },
"description": { "type": "string" },
"meta_school_id": { "type": "number" },
},
"required": ["name", "description", "meta_school_id"]
}
module.exports = School

View File

@@ -0,0 +1,39 @@
const Spell = {
"id": "/SpellValidation",
"type": Object,
"properties": {
"name": { "type": "string" },
"description": { "type": "string" },
"level": { "type": "number" },
"charge": { "type": "number" },
"cost": { "type": "string" },
"is_ritual": { "type": "boolean" },
"schools": {
"type": { "type": "array" },
"items": {
"properties": {
"id": { "type": "number" },
}
}
},
"variables": {
"type": { "type": "array" },
"items": {
"properties": {
"id": { "type": "number" },
}
}
},
"ingredients": {
"type": { "type": "array" },
"items": {
"properties": {
"id": { "type": "number" },
}
}
}
},
"required": ["name", "description"]
}
module.exports = Spell

View File

@@ -0,0 +1,13 @@
const User = {
"id": "/UserValidation",
"type": Object,
"properties": {
"name": { "type": "string" },
"mail": { "type": "string" },
"password": { "type": "string" },
"banned": { "type": "boolean"},
},
"required": ["name", "password", "mail"]
}
module.exports = User

View File

@@ -0,0 +1,10 @@
const Variable = {
"id": "/VariableValidation",
"type": Object,
"properties": {
"description": { "type": "string" },
},
"required": ["description"]
}
module.exports = Variable