var app=angular.module("nureech",["ui.router","nureechFactory","nureechCtrls"]);app.config(["$stateProvider","$urlRouterProvider",function(a,b){a.state("home",{url:"/home",templateUrl:"/templates/home.html",controller:"mainCtrl",resolve:{postPromise:["reeches",function(a){return a.getAll()}]}}).state("login",{url:"/login",templateUrl:"/templates/login.html",controller:"authCtrl",onEnter:["$state","auth",function(a,b){b.isLoggedIn()&&a.go("home")}]}).state("register",{url:"/register",templateUrl:"/templates/register.html",controller:"authCtrl",onEnter:["$state","auth",function(a,b){b.isLoggedIn()&&a.go("home")}]}),b.otherwise("home")}]);var nureechCtrls=angular.module("nureechCtrls",[]);nureechCtrls.controller("mainCtrl",["$scope","$http",function(a,b){}]),nureechCtrls.controller("authCtrl",["$scope","$state","auth",function(a,b,c){a.user={},a.register=function(){c.register(a.user).error(function(b){a.error=b}).then(function(){b.go("home")})},a.logIn=function(){c.logIn(a.user).error(function(b){a.error=b}).then(function(){b.go("home")})}}]),nureechCtrls.controller("navCtrl",["$scope","auth",function(a,b){a.isLoggedIn=b.isLoggedIn,a.currentUser=b.currentUser,a.logOut=b.logOut}]);var nureechFactory=angular.module("nureechFactory",[]);nureechFactory.factory("auth",["$http","$window",function(a,b){var c={},d="nureech-token";return c.saveToken=function(a){b.localStorage[d]=a},c.getToken=function(){return b.localStorage[d]},c.isLoggedIn=function(){var a=c.getToken();if(a){var d=JSON.parse(b.atob(a.split(".")[1]));return d.exp>Date.now()/1e3}return!1},c.currentUser=function(){if(c.isLoggedIn()){var a=c.getToken(),d=JSON.parse(b.atob(a.split(".")[1]));return d.username}},c.register=function(b){return a.post("/register",b).success(function(a){c.saveToken(a.token)})},c.logIn=function(b){return a.post("/login",b).success(function(a){c.saveToken(a.token)})},c.logOut=function(){b.localStorage.removeItem(d)},c}]);
var app=angular.module("nureech",["ui.router","ngtimeago","nureechFactory","nureechCtrls"]);app.config(["$stateProvider","$urlRouterProvider",function(a,b){a.state("home",{url:"/home",templateUrl:"/templates/home.html",controller:"mainCtrl",resolve:{postPromise:["reeches",function(a){return a.getAll()}]}}).state("login",{url:"/login",templateUrl:"/templates/login.html",controller:"authCtrl",onEnter:["$state","auth",function(a,b){b.isLoggedIn()&&a.go("home")}]}).state("register",{url:"/register",templateUrl:"/templates/register.html",controller:"authCtrl",onEnter:["$state","auth",function(a,b){b.isLoggedIn()&&a.go("home")}]}),b.otherwise("home")}]);var nureechCtrls=angular.module("nureechCtrls",[]);nureechCtrls.controller("mainCtrl",["$scope","reeches","auth",function(a,b,c){a.isLoggedIn=c.isLoggedIn,a.reeches=b.reeches,a.nuReech=function(){a.body&&""!==a.body&&(b.create({body:a.body}),a.body="")}}]),nureechCtrls.controller("authCtrl",["$scope","$state","auth",function(a,b,c){a.user={},a.register=function(){c.register(a.user).error(function(b){a.error=b}).then(function(){b.go("home")})},a.logIn=function(){c.logIn(a.user).error(function(b){a.error=b}).then(function(){b.go("home")})}}]),nureechCtrls.controller("navCtrl",["$scope","auth",function(a,b){a.isLoggedIn=b.isLoggedIn,a.currentUser=b.currentUser,a.logOut=b.logOut}]);var nureechFactory=angular.module("nureechFactory",[]);nureechFactory.factory("auth",["$http","$window",function(a,b){var c={},d="nureech-token";return c.saveToken=function(a){b.localStorage[d]=a},c.getToken=function(){return b.localStorage[d]},c.isLoggedIn=function(){var a=c.getToken();if(a){var d=JSON.parse(b.atob(a.split(".")[1]));return d.exp>Date.now()/1e3}return!1},c.currentUser=function(){if(c.isLoggedIn()){var a=c.getToken(),d=JSON.parse(b.atob(a.split(".")[1]));return d.username}},c.register=function(b){return a.post("/register",b).success(function(a){c.saveToken(a.token)})},c.logIn=function(b){return a.post("/login",b).success(function(a){c.saveToken(a.token)})},c.logOut=function(){b.localStorage.removeItem(d)},c}]),nureechFactory.factory("reeches",["$http","auth",function(a,b){var c={reeches:[]};return c.getAll=function(){return a.get("/reeches").success(function(a){angular.copy(a,c.reeches)})},c.get=function(b){return a.get("/reeches"+b).then(function(a){return a.data})},c.create=function(d){return a.post("/reeches",d,{headers:{Authorization:"Bearer "+b.getToken()}}).success(function(a){c.reeches.push(a)})},c}]);
Recompile and minified client js