<commit_before>angular.module('bookstore.services', [])
.factory('Auth', function($http) {
  var login = function(data) {
    return $http({
      method: 'POST',
      url: '/api/users',
      data: JSON.stringify(data),
      ContentType: 'application/json'
    })
    .then(function(res) {
      return res.data;
    })
  };
  return {
    login: login
  }
})
.factory('Landing', function($http) {
  var getBooks = function(search, index) {
    return $http({
      method: 'GET',
      url: 'https://www.googleapis.com/books/v1/volumes?q=' + search + '&printType=books&orderBy=relevance&filter=ebooks&maxResults=40&startIndex=' + index
    })
    .then(function(res) {
      //console.log(res.data);
      return res.data;
    });
  };
  var saveBook = function(book) {
    return $http({
      method: 'POST',
      url: 'api/books',
      data: JSON.stringify(book)
    })
    .then(function(res) {
      return res.data;
    });
  };

  return {
    getBooks: getBooks,
    saveBook: saveBook
  }
})
.factory('Shelf', function($http) {
  var getShelf = function() {
    return $http({
      method: 'GET',
      url: 'api/books',
      ContentType: 'application/json'
    })
    .then(function(res) {
      return res.data;
    });
  };

  return {
    getShelf: getShelf
  };
})
.factory('Details', function($http) {
  var bookInfo = function(id) {
    return $http({
      method: 'GET',
      url: 'api/books/' + id,
      ContentType: 'application/json'
    })
    .then(function(res) {
      //console.log(res.data)
      return res.data;
    });
  }

  return {
    bookInfo: bookInfo
  }
});<commit_msg>add signin and me services to consume REST API from backend<commit_after>angular.module('bookstore.services', [])
.factory('Auth', function($http, $window) {
  var signup = function(data) {
    return $http({
      method: 'POST',
      url: '/api/users',
      data: JSON.stringify(data),
      ContentType: 'application/json'
    })
    .then(function(res) {
      return res.data.token;
    })
  };
  var signin = function(data) {
    return $http({
      method: 'POST',
      url: '/auth/signin' ,
      data: data,
      headers: $window.localStorage.getItem('access_token'),
      ContentType: 'application/json'
    })
    .then(function(res) {
      return res.data;
    });
  };
  var me = function(token) {
    return $http({
      method: 'GET',
      url: '/api/users/me',
      params: {access_token: token},
      ContentType: 'application/json'
    })
    .then(function(res) {
      return res.data;
    });
  };
  return {
    signup: signup,
    signin: signin,
    me: me
  }
})
.factory('Landing', function($http, $window) {
  var getBooks = function(search, index) {
    return $http({
      method: 'GET',
      url: 'https://www.googleapis.com/books/v1/volumes?q=' + search + '&printType=books&orderBy=relevance&filter=ebooks&maxResults=40&startIndex=' + index
    })
    .then(function(res) {
      return res.data;
    });
  };
  var saveBook = function(book) {
    return $http({
      method: 'POST',
      url: 'api/books',
      data: JSON.stringify(book),
      params: {access_token: $window.localStorage.getItem('access_token')}
    })
    .then(function(res) {
      return res.data;
    });
  };

  return {
    getBooks: getBooks,
    saveBook: saveBook
  }
})
.factory('Shelf', function($http, $window) {
  var getShelf = function(userId) {
    return $http({
      method: 'GET',
      url: 'api/books/',
      params: {userId: userId, access_token: $window.localStorage.getItem('access_token')},
      ContentType: 'application/json'
    })
    .then(function(res) {
      return res.data;
    });
  };

  return {
    getShelf: getShelf
  };
})
.factory('Details', function($http) {
  var bookInfo = function(id) {
    return $http({
      method: 'GET',
      url: 'api/books/' + id,
      ContentType: 'application/json'
    })
    .then(function(res) {
      return res.data;
    });
  }

  return {
    bookInfo: bookInfo
  }
});
{'fraction_non_alphanumeric': 0.16892230576441103, 'fraction_numerical': 0.0015037593984962407, 'mean_word_length': 2.553873552983081, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '5192984', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1352, 'n_words': 258}