You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.5 KiB
48 lines
1.5 KiB
import express from "express";
|
|
import dotenv from "dotenv";
|
|
import UserRoute from "./app/routes/user.route.js";
|
|
import ChannelRoute from "./app/routes/channel.route.js";
|
|
import VideoRoute from "./app/routes/video.route.js";
|
|
import CommentRoute from "./app/routes/comment.route.js";
|
|
import RecommendationRoute from "./app/routes/redommendation.route.js";
|
|
import * as http from "node:http";
|
|
import cors from "cors";
|
|
import PlaylistRoute from "./app/routes/playlist.route.js";
|
|
import {initDb} from "./app/utils/database.js";
|
|
import MediaRoutes from "./app/routes/media.routes.js";
|
|
import SearchRoute from "./app/routes/search.route.js";
|
|
|
|
console.clear();
|
|
dotenv.config();
|
|
|
|
|
|
const app = express();
|
|
|
|
// Increase body size limits for file uploads
|
|
app.use(express.urlencoded({extended: true, limit: '500mb'}));
|
|
app.use(express.json({limit: '500mb'}));
|
|
app.use(cors())
|
|
|
|
// ROUTES
|
|
app.use("/api/users/", UserRoute);
|
|
app.use("/api/channels/", ChannelRoute);
|
|
app.use("/api/videos/", VideoRoute);
|
|
app.use("/api/comments/", CommentRoute);
|
|
app.use("/api/playlists", PlaylistRoute);
|
|
app.use("/api/recommendations", RecommendationRoute);
|
|
app.use("/api/media", MediaRoutes);
|
|
app.use("/api/search", SearchRoute);
|
|
|
|
const port = process.env.PORT;
|
|
|
|
if (process.env.NODE_ENV !== "test") {
|
|
const server = http.createServer(app);
|
|
server.listen(port, '0.0.0.0', async () => {
|
|
console.log("Server's listening on port " + port);
|
|
console.log("Initializing database...");
|
|
await initDb();
|
|
console.log("Database initialized successfully.");
|
|
});
|
|
}
|
|
|
|
export default app;
|