38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import express from "express";
|
|
import cors from "cors";
|
|
const app = express();
|
|
import ImapSync from "./mails/EmailManager";
|
|
import { execQueryAsync, execQuery } from "./db/db";
|
|
|
|
app.use(express.json());
|
|
app.use(
|
|
express.urlencoded({
|
|
extended: true,
|
|
}),
|
|
);
|
|
app.use(cors());
|
|
app.listen(process.env.PORT || 5500);
|
|
|
|
import mailRouter from "./routes/mail";
|
|
import emailManager from "./mails/EmailManager";
|
|
app.use("/api/mail", mailRouter);
|
|
|
|
emailManager.init();
|
|
|
|
// debug reset all tables
|
|
const shouldReset = false;
|
|
if (shouldReset) {
|
|
const query = "SELECT table_name FROM INFORMATION_SCHEMA.tables WHERE table_schema = 'mail'";
|
|
execQueryAsync(query, []).then((results) => {
|
|
execQuery("SET FOREIGN_KEY_CHECKS=0", []);
|
|
results.map((table) => {
|
|
if (table.table_name == "app_account") return;
|
|
if (table.table_name == "address") return;
|
|
if (table.table_name == "mailbox") return;
|
|
console.log(table.table_name);
|
|
execQuery("DELETE FROM " + table.table_name, []);
|
|
// execQuery("DROP TABLE " + table.table_name);
|
|
});
|
|
});
|
|
}
|