change archi and use schema routes
This commit is contained in:
26
back/abl/Account-abl.ts
Normal file
26
back/abl/Account-abl.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Response } from "express";
|
||||
import { getAccounts, registerAccount } from "../db/api";
|
||||
import { getAddresseId } from "../db/utils/mail";
|
||||
import statusCodes from "../utils/statusCodes";
|
||||
|
||||
export default class Account {
|
||||
static async getAll(body, res: Response) {
|
||||
getAccounts().then((data) => {
|
||||
res.status(statusCodes.OK).json(data);
|
||||
});
|
||||
}
|
||||
|
||||
static async register(body, res: Response) {
|
||||
const { email, pwd, xoauth, xoauth2, host, port, tls } = body;
|
||||
getAddresseId(email).then((addressId) => {
|
||||
registerAccount(addressId, pwd, xoauth, xoauth2, host, port, tls)
|
||||
.then((mailboxId) => {
|
||||
res.status(statusCodes.OK).json({ id: mailboxId });
|
||||
})
|
||||
.catch(() => {
|
||||
res.status(statusCodes.INTERNAL_SERVER_ERROR);
|
||||
});
|
||||
});
|
||||
// todo change mailbox to account
|
||||
}
|
||||
}
|
||||
13
back/abl/members.ts
Normal file
13
back/abl/members.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import statusCode from "../utils/statusCodes";
|
||||
import { getMembers } from "../db/api";
|
||||
import logger from "../system/Logger";
|
||||
|
||||
export async function members(body, res) {
|
||||
const { roomId } = body;
|
||||
getMembers(roomId).then((addresses) => {
|
||||
res.status(statusCode.OK).json(addresses);
|
||||
}).catch((err) => {
|
||||
logger.err(err)
|
||||
res.status(statusCode.INTERNAL_SERVER_ERROR);
|
||||
});
|
||||
}
|
||||
14
back/abl/messages.ts
Normal file
14
back/abl/messages.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import statusCode from "../utils/statusCodes";
|
||||
import { getMessages } from "../db/api";
|
||||
import logger from "../system/Logger";
|
||||
import { Response } from "express";
|
||||
|
||||
export async function messages(body, res: Response) {
|
||||
const { roomId } = body;
|
||||
getMessages(roomId).then((messages) => {
|
||||
res.status(statusCode.OK).json(messages);
|
||||
}).catch((err) => {
|
||||
logger.err(err)
|
||||
res.status(statusCode.INTERNAL_SERVER_ERROR);
|
||||
});
|
||||
}
|
||||
14
back/abl/rooms.ts
Normal file
14
back/abl/rooms.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import statusCode from "../utils/statusCodes";
|
||||
import { getRooms } from "../db/api";
|
||||
import logger from "../system/Logger";
|
||||
import { Response } from "express";
|
||||
|
||||
export async function rooms(body, res: Response) {
|
||||
const { mailboxId, offset, limit } = body;
|
||||
getRooms(mailboxId).then((rooms) => {
|
||||
res.status(statusCode.OK).json(rooms);
|
||||
}).catch((err) => {
|
||||
logger.err(err)
|
||||
res.status(statusCode.INTERNAL_SERVER_ERROR);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user