<commit_before>import path from 'path';
import uc from '../APIv1/users/userController.js';
import rc from '../APIv1/recipes/recipeController.js';
import sc from '../APIv1/search/searchController.js';
import { handleGoogleLogin, authenticateGoogleLogin, checkAuth } from './auth.js';
import lc from '../APIv1/likes/likesController.js';
import fp from '../keys/getFPKey.js';

module.exports = (app, express) => {

  /**
  * Auth
  */
  app.get('/auth/google', handleGoogleLogin);

  app.get('/auth/google/callback', authenticateGoogleLogin,
    (req, res) => { res.redirect('/'); }
  );

  app.get('/auth/signout', (req, res) => {
    req.session.destroy(() => { res.redirect('/'); });
  });


  /**
   * Users
   */

  app.get('/api/v1/user/', uc.getLoggedInUser);

  app.post('/api/v1/users/', checkAuth, uc.createUser);
  app.get('/api/v1/users/:user_id', uc.getOneUser);

  // TODO: getAllUsers should be protected for only admins, eventually.
  app.get('/api/v1/users/', uc.getAllUsers);

  // app.get('/api/v1/users/me', /* auth, */ getCurrentUser);
  // app.put('/api/v1/users/:user_id', /* auth, */ updateUser);
  // app.get('/api/v1/users/followers/:user_id', findFollowers);

  /**
   * Recipes
   */
  app.get('/api/v1/trending', rc.trendingRecipes);

  app.post('/api/v1/recipes/', checkAuth, rc.createRecipe);
  app.put('/api/v1/recipes/', rc.editRecipe);
  // app.post('/api/v1/recipes/:recipe_id', /* auth, */ forkRecipe);
  app.get('/api/v1/recipes/', rc.getMultipleRecipes);
  app.get('/api/v1/recipes/:recipe_id', rc.getOneRecipe);

  // app.put('/api/v1/recipes/:recipe', /* auth, */ updateRecipe);
  // app.get('/api/v1/recipes/:user', /* auth, */ getUsersRecipes);
  // app.get('/api/v1/recipes/me', /* auth, */ namedFn);
  // app.get('/api/v1/recipes/me', /* auth, */ namedFn);

  /**
   * Created
   */

  app.get('/api/v1/created/:user', rc.getAllCreatedRecipes);

  /**
   * Search
   */
  app.get('/api/v1/search/:q', sc.searchRecipes);

  /**
   * Likes
   */
  app.get('/api/v1/likes', lc.getLikeState);
  app.post('/api/v1/likes', checkAuth, lc.addOrDeleteRecipeLike);
  app.get('/api/v1/likes/:user', lc.getAllLikedRecipes);
  // app.get('/api/v1/favorites/:user/count', /* auth, */ getUserFavoritesCount);

   /**
   * FPKey
   */
  app.get('/api/v1/FPKey', fp.getFPKey);

  /**
   * Catch unspecified routes
   */
  app.get('*', (request, response) => {
    response.sendFile(path.resolve(__dirname, '../../client', 'index.html'));
  });
};<commit_msg>Import and routes for follows of users, recipes<commit_after>import path from 'path';
import uc from '../APIv1/users/userController.js';
import rc from '../APIv1/recipes/recipeController.js';
import sc from '../APIv1/search/searchController.js';
import { handleGoogleLogin, authenticateGoogleLogin, checkAuth } from './auth.js';
import lc from '../APIv1/likes/likesController.js';
import fp from '../keys/getFPKey.js';
import * as fc from '../APIv1/follows/followsController.js';

module.exports = (app, express) => {

  /**
  * Auth
  */
  app.get('/auth/google', handleGoogleLogin);

  app.get('/auth/google/callback', authenticateGoogleLogin,
    (req, res) => { res.redirect('/'); }
  );

  app.get('/auth/signout', (req, res) => {
    req.session.destroy(() => { res.redirect('/'); });
  });


  /**
   * Users
   */

  app.get('/api/v1/user/', uc.getLoggedInUser);

  app.post('/api/v1/users/', checkAuth, uc.createUser);
  app.get('/api/v1/users/:user_id', uc.getOneUser);

  // TODO: getAllUsers should be protected for only admins, eventually.
  app.get('/api/v1/users/', uc.getAllUsers);

  // app.get('/api/v1/users/me', /* auth, */ getCurrentUser);
  // app.put('/api/v1/users/:user_id', /* auth, */ updateUser);
  // app.get('/api/v1/users/followers/:user_id', findFollowers);

  /**
   * Recipes
   */
  app.get('/api/v1/trending', rc.trendingRecipes);

  app.post('/api/v1/recipes/', checkAuth, rc.createRecipe);
  app.put('/api/v1/recipes/', rc.editRecipe);
  // app.post('/api/v1/recipes/:recipe_id', /* auth, */ forkRecipe);
  app.get('/api/v1/recipes/', rc.getMultipleRecipes);
  app.get('/api/v1/recipes/:recipe_id', rc.getOneRecipe);

  // app.put('/api/v1/recipes/:recipe', /* auth, */ updateRecipe);
  // app.get('/api/v1/recipes/:user', /* auth, */ getUsersRecipes);
  // app.get('/api/v1/recipes/me', /* auth, */ namedFn);
  // app.get('/api/v1/recipes/me', /* auth, */ namedFn);

  /**
   * Created
   */

  app.get('/api/v1/created/:user', rc.getAllCreatedRecipes);

  /**
   * Search
   */
  app.get('/api/v1/search/:q', sc.searchRecipes);

  /**
   * Likes
   */
  app.get('/api/v1/likes', lc.getLikeState);
  app.post('/api/v1/likes', checkAuth, lc.addOrDeleteRecipeLike);
  app.get('/api/v1/likes/:user', lc.getAllLikedRecipes);
  // app.get('/api/v1/favorites/:user/count', /* auth, */ getUserFavoritesCount);

   /**
   * FPKey
   */
  app.get('/api/v1/FPKey', fp.getFPKey);

  /**
   * Follows
   */
  app.get('/api/v1/follows/user', fc.getUserFollowState);
  app.get('/api/v1/follows/recipe', fc.getRecipeFollowState);



  app.post('/api/v1/follows/user/:recipe', /*checkAuth,*/ fc.addUserFollow);
  app.post('/api/v1/follows/:currentUser/:user', checkAuth, fc.addOrRemoveRecipeFollow);
  /**
   * Catch unspecified routes
   */
  app.get('*', (request, response) => {
    response.sendFile(path.resolve(__dirname, '../../client', 'index.html'));
  });
};
{'fraction_non_alphanumeric': 0.22817792667038897, 'fraction_numerical': 0.011353061604317885, 'mean_word_length': 3.1886204208885425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '777269', 'n_tokens_mistral': 2085, 'n_tokens_neox': 2050, 'n_words': 281}