<commit_before>let async = require("async");

module.exports = (app, passport, auth) => {
  const users = require("../app/controllers/users");
  app.get("/login", users.login);
  app.get("/signup", users.signup);
  app.get("/logout", users.logout);
  app.post("/users", users.create);
  app.get("/userslist", users.list);
  app.post(
    "/users/sessions",
    passport.authenticate("local", {
      failureRedirect: "/login",
      failureFlash: "Invalid email or password"
    }),
    users.session
  );
  app.get("/users/:userId", users.show);
  app.get("/users/:userId/followers", users.showFollowers);
  app.get("/users/:userId/following", users.showFollowing);

  app.get(
    "/auth/github",
    passport.authenticate("github", { failureRedirect: "/login" }),
    users.signin
  );
  app.get(
    "/auth/github/callback",
    passport.authenticate("github", { failureRedirect: "/login" }),
    users.authCallback
  );

  /**
   * API related code
   */
  const apiv1 = require("../app/controllers/apiv1");
  app.get("/apiv1/tweets", apiv1.tweetList);
  app.get("/apiv1/users", apiv1.usersList);

  /**
   * Chat related code
   */

  const chat = require('../app/controllers/chat');
  app.get('/chat', auth.requiresLogin, chat.index);
  app.get('/chat/:id', auth.requiresLogin, chat.show);
  app.get('/chat/get/:userid', auth.requiresLogin, chat.getChat);
  app.post('/chats', auth.requiresLogin, chat.create);
  /**
  * Analytics related code
  */
  const analytics = require("../app/controllers/analytics");
  app.get("/analytics", analytics.index);

  app.param("userId", users.user);

  //tweets routes
  const tweets = require("../app/controllers/tweets");
  app.get("/tweets", tweets.index);
  app.post("/tweets", auth.requiresLogin, tweets.create);
  app.get("/tweets/:id", tweets.show);
  app.post(
    "/tweets/:id",
    auth.requiresLogin,
    auth.tweet.hasAuthorization,
    tweets.update
  );
  app.del(
    "/tweets/:id",
    auth.requiresLogin,
    auth.tweet.hasAuthorization,
    tweets.destroy
  );
  app.param("id", tweets.tweet);

  //home route
  app.get("/", auth.requiresLogin, tweets.index);

  //comment routes
  const comments = require("../app/controllers/comments");
  app.post("/tweets/:id/comments", auth.requiresLogin, comments.create);
  app.get("/tweets/:id/comments", auth.requiresLogin, comments.create);
  app.del("/tweets/:id/comments", auth.requiresLogin, comments.destroy);

  /**
   * Favorite routes
   */
  const favorites = require("../app/controllers/favorites");

  app.post("/tweets/:id/favorites", auth.requiresLogin, favorites.create);
  app.del("/tweets/:id/favorites", auth.requiresLogin, favorites.destroy);

  /**
    * Follow
    */
  const follows = require("../app/controllers/follows");

  app.post("/users/:userId/follow", auth.requiresLogin, follows.follow);<commit_msg>Cleaned up the routes file<commit_after>module.exports = (app, passport, auth) => {
  const users = require("../app/controllers/users");
  const apiv1 = require("../app/controllers/apiv1");
  const chat = require('../app/controllers/chat');
  const analytics = require("../app/controllers/analytics");
  const tweets = require("../app/controllers/tweets");
  const comments = require("../app/controllers/comments");
  const favorites = require("../app/controllers/favorites");
  const follows = require("../app/controllers/follows");

  /**
   * Main routes
   */
  app.get("/", auth.requiresLogin, tweets.index);
  app.get("/login", users.login);
  app.get("/signup", users.signup);
  app.get("/logout", users.logout);
  app.post("/users", users.create);
  app.get("/userslist", users.list);

  /**
   * User routes
   */
  app.post(
    "/users/sessions",
    passport.authenticate("local", {
      failureRedirect: "/login",
      failureFlash: "Invalid email or password"
    }),
    users.session
  );
  app.get("/users/:userId", users.show);
  app.get("/users/:userId/followers", users.showFollowers);
  app.get("/users/:userId/following", users.showFollowing);
  app.post("/users/:userId/follow", auth.requiresLogin, follows.follow);
  app.param("userId", users.user);

  /**
   * Authentication routes
   */
  app.get(
    "/auth/github",
    passport.authenticate("github", { failureRedirect: "/login" }),
    users.signin
  );
  app.get(
    "/auth/github/callback",
    passport.authenticate("github", { failureRedirect: "/login" }),
    users.authCallback
  );

  /**
   * API routes
   */
  app.get("/apiv1/tweets", apiv1.tweetList);
  app.get("/apiv1/users", apiv1.usersList);

  /**
   * Chat routes
   */
  app.get('/chat', auth.requiresLogin, chat.index);
  app.get('/chat/:id', auth.requiresLogin, chat.show);
  app.get('/chat/get/:userid', auth.requiresLogin, chat.getChat);
  app.post('/chats', auth.requiresLogin, chat.create);
  /**
  * Analytics routes
  */
  app.get("/analytics", analytics.index);

  /**
   * Tweet routes
   */
  app.get("/tweets", tweets.index);
  app.get("/tweets/:id", tweets.show);
  app.post("/tweets", auth.requiresLogin, tweets.create);
  app.post(
    "/tweets/:id",
    auth.requiresLogin,
    auth.tweet.hasAuthorization,
    tweets.update
  );
  app.del(
    "/tweets/:id",
    auth.requiresLogin,
    auth.tweet.hasAuthorization,
    tweets.destroy
  );
  app.param("id", tweets.tweet);

  /**
   * Comment routes
   */
  app.post("/tweets/:id/comments", auth.requiresLogin, comments.create);
  app.get("/tweets/:id/comments", auth.requiresLogin, comments.create);
  app.del("/tweets/:id/comments", auth.requiresLogin, comments.destroy);

  /**
   * Favorite routes
   */
  app.post("/tweets/:id/favorites", auth.requiresLogin, favorites.create);
  app.del("/tweets/:id/favorites", auth.requiresLogin, favorites.destroy);
{'fraction_non_alphanumeric': 0.19401155664507092, 'fraction_numerical': 0.0021012081947119595, 'mean_word_length': 3.4694835680751175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1305156', 'n_tokens_mistral': 1960, 'n_tokens_neox': 1933, 'n_words': 296}