{"size": 1822, "ext": "js", "max_stars_repo_path": "backend/app/app.js", "max_stars_repo_name": "it-academyproject/ita-directory-frontend", "max_stars_repo_stars_event_min_datetime": "2021-03-03T13:56:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-03T13:56:07.000Z", "max_issues_repo_path": "backend/app/app.js", "max_issues_repo_name": "it-academyproject/ita-directory-frontend", "max_issues_repo_issues_event_min_datetime": "2021-01-24T22:01:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-14T09:10:35.000Z", "max_forks_repo_path": "backend/app/app.js", "max_forks_repo_name": "it-academyproject/ita-directory-frontend", "max_forks_repo_forks_event_min_datetime": "2021-01-19T10:01:37.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-09T16:27:30.000Z"}
{"max_stars_count": 1, "max_issues_count": 25, "max_forks_count": 14, "avg_line_length": 25.661971831, "max_line_length": 75, "alphanum_fraction": 0.6805708013}
const express = require("express");
// const bodyParser = require("body-parser");
const morgan = require("morgan");
const cors = require("cors");
const helmet = require("helmet");
const expressJSDocSwagger = require("express-jsdoc-swagger");
const options = require("./utils/swaggerOptions");
const userRoutes = require("./routes/users");
const mediaRoutes = require("./routes/media");

// const constantsRoute = require("./routes/constants");
const adsRoutes = require("./routes/ads");
const authenticateToken = require("./middleware/verifyToken");

// const UsersController = require("./controllers/users");
// const {loadConstants} = require("./utils/CONSTANTS");
const {loadConstants} = require("./utils/CONSTANTS");

// Check the connection with the DB
loadConstants();

// Initiate the app
const app = express();

app.use(cors());
app.use(express.json());
app.use(
	express.urlencoded({
		extended: true,
	})
);

//Settings for testing SocketIO
app.use(express.static("public"));
//app.set('view engine', 'ejs');

// Middlewares
app.use(morgan("dev"));
app.use(helmet());
app.use(express.json({limit: "50mb", type: "application/json"}));




// API
expressJSDocSwagger(app)(options);
// app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));

// Simple, initial route
app.get("/", (req, res) => {
	res.json({message: "ITA DIRECTORY API"});
});

// Routes
// app.use("/", constantsRoute);
app.use("/ads", adsRoutes);
app.use("/users", userRoutes);
app.use("/media", mediaRoutes);

// app.get("/get-token", UsersController.getToken);
// app.get("/test-token", authenticateToken, (req, res) => {
// 	res.json({message: "Correct Token !", data: {user_id: req.userId}});
// });

//Routes for testing chat
app.get("/chat", (req, res) => {
	res.status(200).send("Hello World");
});

module.exports = app;
