-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
1 lines (1 loc) · 14.1 KB
/
server.js
1
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r(r.s=28)}([function(e,t){e.exports=require("react")},function(e,t){e.exports=require("react-router-dom")},function(e,t){e.exports=require("@material-ui/core/Grid")},function(e,t){e.exports=require("@material-ui/core/Typography")},function(e,t){e.exports=require("@material-ui/core/styles")},function(e,t){e.exports=require("@material-ui/core/IconButton")},function(e,t){e.exports=require("@material-ui/core/Tooltip")},function(e,t){e.exports=require("react-center")},function(e,t){e.exports=require("express")},function(e,t){e.exports=require("cors")},function(e,t){e.exports=require("react-dom/server")},function(e,t){e.exports=require("@material-ui/core/CardHeader")},function(e,t){e.exports=require("@material-ui/core/Card")},function(e,t){e.exports=require("@material-ui/core/Avatar")},function(e,t){e.exports=require("@material-ui/icons/Info")},function(e,t){e.exports=require("@material-ui/core/CardContent")},function(e,t){e.exports=require("@material-ui/icons/Star")},function(e,t){e.exports=require("@material-ui/icons/Home")},function(e,t){e.exports=require("@material-ui/core/CardMedia")},function(e,t){e.exports=require("@material-ui/core/CardActions")},function(e,t){e.exports=require("react-loader-spinner")},function(e,t){e.exports=require("isomorphic-fetch")},function(e,t){e.exports=require("@material-ui/core/Tab")},function(e,t){e.exports=require("@material-ui/core/Tabs")},function(e,t){e.exports=require("@material-ui/core/AppBar")},function(e,t){e.exports=require("serialize-javascript")},function(e,t){e.exports=require("@material-ui/core/Box")},function(e,t){e.exports=require("@material-ui/lab/Skeleton")},function(e,t,r){"use strict";r.r(t);var n=r(8),o=r.n(n),a=r(9),i=r.n(a),c=r(10),u=r(0),l=r.n(u),s=r(7),p=r.n(s),f=r(3),m=r.n(f),d=r(2),y=r.n(d),h=r(4),b=Object(h.createMuiTheme)({root:{primary:"linear-gradient(to right, #fc354c, #0abfbc)",secondary:"linear-gradient(to left, #283048, #859398)"},navbarStyle:{background:"linear-gradient(to right, #fc354c, #0abfbc) !important",paddingBottom:"7px !important"},CardHeader:{background:"linear-gradient(to left, #283048, #859398) !important"},CardBottom:{background:"linear-gradient(to top, #8e9eab, #eef2f3) !important"},content:{background:"linear-gradient(to left, #ece9e6, #ffffff !important"},iconButton:{color:"black !important"},large:{width:60,height:60},font:{fontSize:"1em"},mainCon:{marginTop:"60px !important",width:"100% !important"},home:{marging:"250px !important"}});var v=r(11),g=r.n(v),x=r(12),S=r.n(x),w=r(13),E=r.n(w),O=r(14),j=r.n(O),R=r(5),_=r.n(R),q=r(15),P=r.n(q),T=r(16),A=r.n(T),C=r(17),k=r.n(C),I=r(18),D=r.n(I),B=r(6),M=r.n(B),H=r(19),z=r.n(H),U=(r(26),r(27),r(20)),F=r.n(U);function G(e){return(G="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function J(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function L(e,t){return(L=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function N(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=$(e);if(t){var o=$(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return V(this,r)}}function V(e,t){return!t||"object"!==G(t)&&"function"!=typeof t?Y(e):t}function Y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function $(e){return($=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var K=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&L(e,t)}(a,e);var t,r,n,o=N(a);function a(e){var t,r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),r=(t=o.call(this,e)).props.staticContext.data,t.state={repos:r,loading:!r},t.fetchRepos=t.fetchRepos.bind(Y(t)),t}return t=a,(r=[{key:"fetchRepos",value:function(e){var t=this;this.setState((function(){return{loading:!0}})),this.props.fetchInitialData(e).then((function(e){return t.setState((function(){return{repos:e,loading:!1}}))}))}},{key:"componentDidMount",value:function(){this.state.repos||this.fetchRepos(this.props.match.params.id)}},{key:"componentDidUpdate",value:function(e,t){window.location.reload(!1),e.match.params.id!==this.props.match.params.id&&this.fetchRepos(this.props.match.params.id)}},{key:"render",value:function(){var e=this.state,t=e.repos;function r(e){return l.a.createElement(l.a.Fragment,null,l.a.createElement(y.a,{item:!0,xs:4},l.a.createElement("div",{margin:20},l.a.createElement(S.a,null,l.a.createElement(g.a,{style:b.CardHeader,avatar:l.a.createElement(E.a,{style:b.large,src:e.repo.owner.avatar_url}),action:l.a.createElement(M.a,{title:"Github"},l.a.createElement(_.a,{style:b.iconButton},l.a.createElement(j.a,{onClick:function(){return window.open(e.repo.html_url)}}))),titleTypographyProps:{variant:"h6"},title:e.repo.name,subheader:e.repo.created_at.substr(0,10)}),l.a.createElement(D.a,null),l.a.createElement(P.a,{style:b.content},l.a.createElement(m.a,{variant:"body2",color:"textSecondary",component:"p"},e.repo.description)),l.a.createElement(z.a,{style:b.CardBottom},l.a.createElement(M.a,{title:"Starred : ".concat(e.repo.stargazers_count)},l.a.createElement(_.a,{style:b.iconButton},l.a.createElement(A.a,null))),l.a.createElement(M.a,{title:"Homepage"},l.a.createElement(_.a,{style:b.iconButton},l.a.createElement(k.a,{onClick:function(){return window.open(e.repo.homepage)}}))))))))}return!0===e.loading?l.a.createElement(p.a,{style:{margin:300}},l.a.createElement(F.a,{type:"Puff",color:"#AAAAAA",height:100,width:100})):l.a.createElement("div",{style:b.mainCon},l.a.createElement(y.a,{container:!0,spacing:3},l.a.createElement(y.a,{container:!0,item:!0,xs:28,spacing:2},t.map((function(e){return l.a.createElement(r,{repo:e})})))))}}])&&J(t.prototype,r),n&&J(t,n),a}(u.Component),Q=r(21),W=r.n(Q);function X(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"all",t=encodeURI("https://api.github.com/search/repositories?q=stars:>1+language:".concat(e,"&sort=stars&order=desc&type=Repositories"));return W()(t).then((function(e){return e.json()})).then((function(e){return e.items})).catch((function(e){return console.warn(e),null}))}var Z=[{path:"/",exact:!0,component:function(){return l.a.createElement(y.a,{justify:"center",alignItems:"center",style:b.home},l.a.createElement(m.a,{variant:"body2",color:"textSecondary"},"Material UI + REACT + SERVER Side Rendering"),l.a.createElement(m.a,{variant:"body2",color:"textSecondary"},"Server-side rendering (SSR), is the ability of an application to contribute by displaying the web-page on the server instead of rendering it in the browser. Server-side sends a fully rendered page to the client; the client’s JavaScript bundle takes over and allows the SPA framework to operate. There is also client-side rendering which slows down the procedure of viewing and interacting with the web page. Advantages of using server-side rendering It enables pages to load faster which provides a better user experience. It plays an important role in SEO (search engine optimization) and correctly indexes webpages. This happens because Google favors web pages with faster load time. It provides body to the HTML pages for all server ships. It assists with loading the page when the user has a slow internet connection. It assists in loading the page when the user has an outdated device."))}},{path:"/popular/:id",component:K,fetchInitialData:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return X(e.split("/").pop())}}],ee=r(1);function te(){return l.a.createElement("div",null,"Four oh Four")}var re=r(22),ne=r.n(re),oe=r(23),ae=r.n(oe),ie=r(24),ce=r.n(ie);function ue(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,a=void 0;try{for(var i,c=e[Symbol.iterator]();!(n=(i=c.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==c.return||c.return()}finally{if(o)throw a}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return le(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return le(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function le(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function se(){var e=ue(l.a.useState(0),2);e[0],e[1];return l.a.createElement("div",null,l.a.createElement(ce.a,{position:"fixed",style:b.navbarStyle},l.a.createElement(ae.a,{centered:!0},[{name:"All",param:"all"},{name:"JavaScript",param:"javascript"},{name:"Ruby",param:"ruby"},{name:"Python",param:"python"},{name:"Java",param:"java"}].map((function(e){var t=e.name,r=e.param;return l.a.createElement(ne.a,{key:t,label:t,className:!0,component:ee.Link,to:"/popular/".concat(r),selected:!0})})))))}function pe(e){return(pe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function fe(){return(fe=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function me(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function de(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ye(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function he(e,t){return(he=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function be(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=ge(e);if(t){var o=ge(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return ve(this,r)}}function ve(e,t){return!t||"object"!==pe(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function ge(e){return(ge=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var xe=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&he(e,t)}(a,e);var t,r,n,o=be(a);function a(){return de(this,a),o.apply(this,arguments)}return t=a,(r=[{key:"render",value:function(){return l.a.createElement("div",null,l.a.createElement(se,null),l.a.createElement(ee.Switch,null,Z.map((function(e){var t=e.path,r=e.exact,n=e.component,o=me(e,["path","exact","component"]);return l.a.createElement(ee.Route,{key:t,path:t,exact:r,render:function(e){return l.a.createElement(n,fe({},e,o))}})})),l.a.createElement(ee.Route,{render:function(e){return l.a.createElement(te,e)}})))}}])&&ye(t.prototype,r),n&&ye(t,n),a}(u.Component),Se=r(25),we=r.n(Se),Ee=o()(),Oe=new h.ServerStyleSheets;Ee.use(i()()),Ee.use(o.a.static("public")),Ee.get("*",(function(e,t,r){var n=Z.find((function(t){return Object(ee.matchPath)(e.url,t)}))||{};(n.fetchInitialData?n.fetchInitialData(e.path):Promise.resolve()).then((function(r){var n={data:r},o=Object(c.renderToString)(Oe.collect(l.a.createElement(h.ThemeProvider,{theme:b},l.a.createElement(ee.StaticRouter,{location:e.url,context:n},l.a.createElement(xe,null))))),a=Oe.toString();t.send('\n <!DOCTYPE html>\n <html>\n <head>\n <title>SSR with RR</title>\n <style id="jss-server-side">'.concat(a,'</style>\n <script src="/bundle.js" defer><\/script>\n <script>window.__INITIAL_DATA__=').concat(we()(r),'<\/script>\n </head>\n \n <body>\n <div id="app"> ').concat(o,"</div>\n </body>\n </html>\n "))})).catch(r)})),Ee.set("port",process.env.PORT||5e3),Ee.listen(Ee.get("port"),(function(){console.log("Server is listening on port: "+Ee.get("port"))}))}]);