{"size": 1051, "ext": "js", "max_stars_repo_path": "index.js", "max_stars_repo_name": "nathan-kansu/mern-example", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "index.js", "max_issues_repo_name": "nathan-kansu/mern-example", "max_issues_repo_issues_event_min_datetime": "2021-05-11T14:33:43.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-19T06:15:39.000Z", "max_forks_repo_path": "index.js", "max_forks_repo_name": "nathan-kansu/mern-example", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 3, "max_forks_count": null, "avg_line_length": 27.6578947368, "max_line_length": 76, "alphanum_fraction": 0.7059942912}
const express = require("express");
const app = express();
const http = require("http");
const socketIo = require("socket.io");
const cors = require("cors");
const compression = require("compression");
const server = http.createServer(app);
const path = require("path");
const io = socketIo(server);
const passport = require("passport");

require("./server/config/passport.js");
require("dotenv").config();

const port = process.env.PORT || 3000;
const clientBuildFolderPath = path.join(__dirname, "..", "client", "build");
const categoriesRouter = require("./server/routes/categories");
const usersRouter = require("./server/routes/users");

app.use(compression());
app.use(cors());
app.use(express.json());
app.use(express.static(clientBuildFolderPath));
app.use(
  "/api/categories",
  passport.authenticate("jwt", { session: false }),
  categoriesRouter
);
app.use("/api/users", usersRouter);

app.set("socketio", io);

app.get("/*", function (_req, res) {
  res.sendFile(path.join(clientBuildFolderPath, "index.html"));
});

server.listen(port);
