{"size": 925, "ext": "js", "max_stars_repo_path": "nu-node/app.js", "max_stars_repo_name": "knekvasil/nuchess", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "nu-node/app.js", "max_issues_repo_name": "knekvasil/nuchess", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nu-node/app.js", "max_forks_repo_name": "knekvasil/nuchess", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.3421052632, "max_line_length": 57, "alphanum_fraction": 0.6616216216}
// app.js

const express = require("express");

const cors = require("cors");
const mongoose = require("mongoose");
const fileUpload = require("express-fileupload");

app = express();

require("dotenv").config(); // to start our .env package

// db connection
mongoose
	.connect(process.env.MONGODB_URL)
	.then(() => console.log("Connected to DB..."))
	.catch(() => console.log("Couldn't connect to DB..."));

// middleware connection
app.use(express.json());
app.use(cors());
app.use(
	fileUpload({
		useTempFiles: true,
		tempFileDir: "/tmp/",
		createParentPath: true,
	})
);

app.use("/api/v1/posts", require("./routes/post"));
app.use("/api/v1/users", require("./routes/user"));
app.use("/api/v1/auth", require("./routes/auth"));
app.use("/api/v1/comments", require("./routes/comment"));

// port setup & listen to clients
const port = process.env.PORT || 5000;
app.listen(port, () => console.log("Server running..."));
