29 lines
625 B
TypeScript
29 lines
625 B
TypeScript
|
import express from "express";
|
||
|
import cors from "cors";
|
||
|
import { sequelize } from "./db.js";
|
||
|
import { router } from "./routes/routes.ts";
|
||
|
import { ErrorHandlingMiddleware } from "./middleware/error-handling.middleware.ts";
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
start();
|