{"size": 976, "ext": "js", "max_stars_repo_path": "src/index.js", "max_stars_repo_name": "marcotterra/twitter-api", "max_stars_repo_stars_event_min_datetime": "2018-08-14T20:13:51.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-31T21:02:25.000Z", "max_issues_repo_path": "src/index.js", "max_issues_repo_name": "marcotterra/twitter-api", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/index.js", "max_forks_repo_name": "marcotterra/twitter-api", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 4, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.6976744186, "max_line_length": 79, "alphanum_fraction": 0.6741803279}
import express from "express";
import bodyparser from "body-parser";
import cors from "cors";
import morgan from "morgan";
import mongoose from "mongoose";

import config from "./config";
import userRouter from "./routes/user.route";
import tweetRouter from "./routes/tweet.route";
import authRouter from "./routes/auth.route";

// Mongo connection
mongoose
  .connect(
    config.DB_URI,
    {
      autoReconnect: true,
      useNewUrlParser: true
    }
  )
  .catch(err =>
    console.error(`MongoDB connection failed with error: \n${err}`)
  );

const app = express();

// Dependencies
app.use(bodyparser.urlencoded({ extended: false }));
app.use(bodyparser.json());
app.use(cors());
app.use(morgan("dev"));

// Routes
app.get("/", (req, res) => {
  res.json({ created_by: "@marcotterra" });
});

app.use("/users", userRouter);
app.use("/tweets", tweetRouter);
app.use("/auth", authRouter);

app.listen(config.PORT, () => console.log(`Listening at port ${config.PORT}`));
