33 lines
792 B
JavaScript
33 lines
792 B
JavaScript
import express from "express";
|
|
import cors from "cors";
|
|
import dotenv from "dotenv";
|
|
import { testConnection } from "./database/db.js";
|
|
import router from "./routes/index.js";
|
|
import cookieParser from "cookie-parser";
|
|
|
|
dotenv.config();
|
|
const app = express();
|
|
|
|
const corsOptions = {
|
|
origin: "http://localhost:5173",
|
|
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
|
allowedHeaders: ["Content-Type", "Authorization"],
|
|
credentials: true,
|
|
};
|
|
|
|
app.use(cors(corsOptions));
|
|
|
|
app.use(cookieParser());
|
|
app.use(express.json());
|
|
app.use(express.urlencoded({ extended: true }));
|
|
app.use(router);
|
|
|
|
app.use(express.static("public"));
|
|
|
|
app.listen(process.env.APP_PORT, () => {
|
|
testConnection();
|
|
console.log(
|
|
`Server running on port http://localhost:${process.env.APP_PORT}`
|
|
);
|
|
});
|