mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 19:59:20 +00:00
finished user store in typscript
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import "dotenv/config";
|
||||
import "express-async-errors";
|
||||
import express from "express";
|
||||
import express, { Request, Response, NextFunction } from "express";
|
||||
import cors from "cors";
|
||||
import AppError from "./errors/AppError";
|
||||
|
||||
import routes from "./routes";
|
||||
|
||||
@@ -15,14 +16,21 @@ import "./database";
|
||||
// const wbotMonitor = require("./services/wbotMonitor");
|
||||
// const Whatsapp = require("./models/Whatsapp");
|
||||
|
||||
// const Router = require("./router");
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(cors());
|
||||
app.use(express.json());
|
||||
app.use(routes);
|
||||
|
||||
app.use(async (err: Error, req: Request, res: Response, next: NextFunction) => {
|
||||
if (err instanceof AppError) {
|
||||
return res.status(err.statusCode).json({ error: err.message });
|
||||
}
|
||||
|
||||
console.error(err);
|
||||
return res.status(500).json({ error: "Internal server error" });
|
||||
});
|
||||
|
||||
const server = app.listen(process.env.PORT, () => {
|
||||
console.log(`Server started on port: ${process.env.PORT}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user