text: "use strict";var __awaiter=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function u(e){try{s(r.next(e))}catch(e){i(e)}}function a(e){try{s(r.throw(e))}catch(e){i(e)}}function s(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(u,a)}s((r=r.apply(e,t||[])).next())})},__generator=this&&this.__generator||function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=r[2&i[0]?"return":i[0]?"throw":"next"])&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[0,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},_this=this;Object.defineProperty(exports,"__esModule",{value:!0});var Router=require("koa-router"),Multer=require("koa-multer"),path=require("path"),login_1=require("../controllers/login/login"),index_1=require("../admin/controllers/index/index"),user_1=require("../admin/controllers/user/user"),router=new Router,storage=Multer.diskStorage({destination:function(e,t,n){n(null,"./build/uploads/")},filename:function(e,t,n){n(null,Date.now()+path.extname(t.originalname))}}),upload=Multer({storage:storage}),loginController=new login_1.default,adminIndexController=new index_1.default,adminUserController=new user_1.default,fnIsLogin=function(e,t){return __awaiter(_this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,loginController.alreadyLogged(e,t)];case 1:return[2,n.sent()]}})})};router.get("/",function(e,t){e.body=e.session}),router.get("/login",function(e,t){return __awaiter(_this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,loginController.login(e,t)];case 1:return n.sent(),[2]}})})}),router.post("/login/action",function(e,t){return __awaiter(_this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,loginController.loginAction(e,t)];case 1:return n.sent(),[2]}})})}),router.get("/register",function(e,t){return __awaiter(_this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,loginController.register(e,t)];case 1:return n.sent(),[2]}})})}),router.post("/register/action",function(e,t){return __awaiter(_this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,loginController.registerAction(e,t)];case 1:return n.sent(),[2]}})})}),router.get("/logout",function(e,t){return __awaiter(_this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,loginController.logout(e,t)];case 1:return n.sent(),[2]}})})}),router.get("/admin",fnIsLogin,function(e,t){return __awaiter(_this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,adminIndexController.init(e,t)];case 1:return n.sent(),[2]}})})}),router.get("/admin/index",fnIsLogin,function(e,t){return __awaiter(_this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,adminIndexController.init(e,t)];case 1:return n.sent(),[2]}})})}),router.get("/admin/user",fnIsLogin,function(e,t){return __awaiter(_this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,adminUserController.editInfo(e,t)];case 1:return n.sent(),[2]}})})}),router.post("/admin/user/saveinfo",function(e,t){return __awaiter(_this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,adminUserController.saveInfo(e,t)];case 1:return n.sent(),[2]}})})}),router.post("/api/upload",upload.single("imgs"),function(e,t){return __awaiter(_this,void 0,void 0,function(){var t;return __generator(this,function(n){return t={code:1,message:"上传成功",data:"/uploads/"+e.req.file.filename},e.body=t,[2]})})}),exports.default=router;