<commit_before>"use strict";

var express = require("express");
var config = require("config");
var async = require("async");
var router = express.Router();
var AuthService = require("../services/AuthService.js");
var ProfService = require("../services/ProfileService.js");

module.exports = router;

router.get("/login", function(req, res) {
  AuthService.login(req.headers.authorization, function(err, token, result) {
    if (err) {
      res.status(401).json({error: err});
    } else {
      res.header({
        "Authorization": token
      });
      res.send(result);  
    };
  })
});

router.get("/ping", function(req, res) {
  AuthService.checkToken(req.headers.token, function(err, token) {
    if (err) {
      res.status(401).send({error: err});
    } else {<commit_msg>BE wired, I have no followers on the test account<commit_after>"use strict";

var express = require("express");
var config = require("config");
var async = require("async");
var router = express.Router();
var AuthService = require("../services/AuthService.js");
var FollowerService = require("../services/FollowerService.js");
var ProfService = require("../services/ProfileService.js");

module.exports = router;

router.get("/followers", function(req, res) {
  async.waterfall([
    function validateToken(callback) {
      AuthService.checkToken(req.headers.authorization, function(err, token) {
        if (err) {
          return callback({error: err});
        }
        return callback(null, token);
      });
    },
    function(token, callback) {
      FollowerService.getFollowers(function(err, followers){
        if (err) {
          return callback(err);
        }  
          return callback(null, token, followers);
      });      
    }], function(err, token, followers) {
      if (err) {
        res.status(404).json({error: err});
      } else {
        res.header({
          "Authorization": token.token
        });
        res.send({followers: followers});        
      }
  });
});

router.get("/login", function(req, res) {
  AuthService.login(req.headers.authorization, function(err, token, result) {
    if (err) {
      res.status(401).json({error: err});
    } else {
      res.header({
        "Authorization": token
      });
      res.send(result);  
    };
  })
});

router.get("/ping", function(req, res) {
  AuthService.checkToken(req.headers.token, function(err, token) {
    if (err) {
      res.status(401).send({error: err});
    } else {
{'fraction_non_alphanumeric': 0.16842961757526445, 'fraction_numerical': 0.006102522375915379, 'mean_word_length': 2.9789644012944985, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 3, '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': '3294193', 'n_tokens_mistral': 744, 'n_tokens_neox': 732, 'n_words': 152}