change archi and use schema routes
This commit is contained in:
14
back/validator/schemas/createAccount-schema.json
Normal file
14
back/validator/schemas/createAccount-schema.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": { "type": "string", "format": "email" },
|
||||
"pwd": { "type": "string" },
|
||||
"xoauth": { "type": "string" },
|
||||
"xoauth2": { "type": "string" },
|
||||
"host": { "type": "string", "format": "hostname" },
|
||||
"port": { "type": "number", "maximum": 65535 },
|
||||
"tls": { "type": "boolean" }
|
||||
},
|
||||
"required": ["email", "host", "port", "tls"],
|
||||
"additionalProperties": false
|
||||
}
|
||||
6
back/validator/schemas/getAccounts-schema.json
Normal file
6
back/validator/schemas/getAccounts-schema.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"required": [],
|
||||
"additionalProperties": false
|
||||
}
|
||||
12
back/validator/schemas/getMembers-schema.json
Normal file
12
back/validator/schemas/getMembers-schema.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"roomId": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"roomId"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
12
back/validator/schemas/getMessages-schema.json
Normal file
12
back/validator/schemas/getMessages-schema.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"roomId": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"roomId"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
12
back/validator/schemas/getRooms-schema.json
Normal file
12
back/validator/schemas/getRooms-schema.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"mailboxId": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"mailboxId"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
16
back/validator/validator.ts
Normal file
16
back/validator/validator.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import Ajv from "ajv";
|
||||
import addFormats from "ajv-formats";
|
||||
const ajv = new Ajv({ allErrors: true });
|
||||
addFormats(ajv);
|
||||
|
||||
import createAccountSchema from "./schemas/createAccount-schema.json";
|
||||
import getAccountSchema from "./schemas/getAccounts-schema.json";
|
||||
import getRoomSchema from "./schemas/getRooms-schema.json";
|
||||
import getMessagesSchema from "./schemas/getMessages-schema.json";
|
||||
import getMembersSchema from "./schemas/getMembers-schema.json";
|
||||
|
||||
export const validateCreateAccount = ajv.compile(createAccountSchema);
|
||||
export const validateGetAccounts = ajv.compile(getAccountSchema);
|
||||
export const validateGetRooms = ajv.compile(getRoomSchema);
|
||||
export const validateGetMessages = ajv.compile(getMessagesSchema);
|
||||
export const validateGetMembers = ajv.compile(getMembersSchema);
|
||||
Reference in New Issue
Block a user