2024-03-24 19:49:46 +04:00
|
|
|
import express from "express";
|
|
|
|
import cors from "cors";
|
2024-04-03 19:59:30 +04:00
|
|
|
import { sequelize } from "./db.js";
|
2024-03-24 22:46:34 +04:00
|
|
|
import { router } from "./routes/routes.ts";
|
|
|
|
import { ErrorHandlingMiddleware } from "./middleware/error-handling.middleware.ts";
|
2024-03-24 19:49:46 +04:00
|
|
|
|
|
|
|
const port = 5000;
|
|
|
|
const app = express();
|
|
|
|
|
|
|
|
app.use(cors());
|
|
|
|
app.use(express.json());
|
|
|
|
app.use("/api/", router);
|
|
|
|
|
|
|
|
app.use(ErrorHandlingMiddleware);
|
|
|
|
|
|
|
|
const start = async () => {
|
|
|
|
try {
|
|
|
|
await sequelize.authenticate();
|
|
|
|
await sequelize.sync();
|
|
|
|
app.listen(port, () => {
|
|
|
|
console.log(`Server is started on port ${port}`);
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error);
|
|
|
|
}
|
2024-04-03 19:59:30 +04:00
|
|
|
};
|
2024-03-24 19:49:46 +04:00
|
|
|
|
2024-04-03 19:59:30 +04:00
|
|
|
start();
|