backend_adaptive_learning/index.js

33 lines
792 B
JavaScript
Raw Normal View History

2024-09-13 13:03:35 +00:00
import express from "express";
import cors from "cors";
import dotenv from "dotenv";
2024-08-12 02:44:06 +00:00
import { testConnection } from "./database/db.js";
import router from "./routes/index.js";
2024-09-13 13:03:35 +00:00
import cookieParser from "cookie-parser";
2024-08-12 02:44:06 +00:00
dotenv.config();
const app = express();
2024-09-13 13:03:35 +00:00
const corsOptions = {
origin: "http://localhost:5173",
2024-09-13 13:03:35 +00:00
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
allowedHeaders: ["Content-Type", "Authorization"],
credentials: true,
};
app.use(cors(corsOptions));
2024-08-12 02:44:06 +00:00
app.use(cookieParser());
app.use(express.json());
2024-09-13 13:03:35 +00:00
app.use(express.urlencoded({ extended: true }));
2024-08-12 02:44:06 +00:00
app.use(router);
2024-09-13 13:03:35 +00:00
app.use(express.static("public"));
2024-08-12 02:44:06 +00:00
app.listen(process.env.APP_PORT, () => {
2024-09-13 13:03:35 +00:00
testConnection();
console.log(
`Server running on port http://localhost:${process.env.APP_PORT}`
);
});