diff --git a/.gitignore b/.gitignore index 57ee5b5..77aba79 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -frontend/node_modules \ No newline at end of file +frontend/node_modules +frontend/build \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 4ea4234..643476a 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -20,12 +20,31 @@ - - - + + + + + + + + + + + + + + + + + + + + - - + + + + \ No newline at end of file diff --git a/backend/go.mod b/backend/go.mod index 3bf885a..b264353 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -6,5 +6,6 @@ require ( github.com/appleboy/gin-jwt/v2 v2.6.4 github.com/gin-contrib/cors v1.3.1 github.com/gin-contrib/pprof v1.3.0 + github.com/gin-gonic/contrib v0.0.0-20201101042839-6a891bf89f19 github.com/gin-gonic/gin v1.6.3 ) diff --git a/backend/go.sum b/backend/go.sum index 007ead2..abc3307 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -13,6 +13,8 @@ github.com/gin-contrib/pprof v1.3.0 h1:G9eK6HnbkSqDZBYbzG4wrjCsA4e+cvYAHUZw6W+W9 github.com/gin-contrib/pprof v1.3.0/go.mod h1:waMjT1H9b179t3CxuG1cV3DHpga6ybizwfBaM5OXaB0= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/contrib v0.0.0-20201101042839-6a891bf89f19 h1:J2LPEOcQmWaooBnBtUDV9KHFEnP5LYTZY03GiQ0oQBw= +github.com/gin-gonic/contrib v0.0.0-20201101042839-6a891bf89f19/go.mod h1:iqneQ2Df3omzIVTkIfn7c1acsVnMGiSLn4XF5Blh3Yg= github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do= github.com/gin-gonic/gin v1.6.2/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= diff --git a/backend/main.go b/backend/main.go index ed2104a..26d275a 100644 --- a/backend/main.go +++ b/backend/main.go @@ -1,15 +1,16 @@ package main import ( - "os" "fmt" - "log" - "time" - "github.com/gin-gonic/gin" - "github.com/gin-contrib/cors" "github.com/appleboy/gin-jwt/v2" + "github.com/gin-contrib/cors" "github.com/gin-contrib/pprof" + "github.com/gin-gonic/contrib/static" + "github.com/gin-gonic/gin" "github.com/kerberos-io/opensource/backend/src/models" + "log" + "os" + "time" ) func main(){ @@ -58,6 +59,9 @@ func main(){ MaxAge: 12 * time.Hour, })) + // Serve frontend static files + r.Use(static.Serve("/", static.LocalFile("./www", true))) + // the jwt middleware identityKey := "id" myKey := "TOBECHANGED" @@ -118,21 +122,24 @@ func main(){ log.Fatal("JWT Error:" + err.Error()) } - r.GET("/restart", func(c *gin.Context) { - c.JSON(200, gin.H{ - "restart": true, - }) - }) - - r.GET("/motion", func(c *gin.Context) { - c.JSON(200, gin.H{ - "data": "☄ Simulate motion", - }) - }) - - r.Use(authMiddleware.MiddlewareFunc()) + api := r.Group("/api") { + api.GET("/restart", func(c *gin.Context) { + c.JSON(200, gin.H{ + "restart": true, + }) + }) + api.GET("/motion", func(c *gin.Context) { + c.JSON(200, gin.H{ + "data": "☄ Simulate motion", + }) + }) + + api.Use(authMiddleware.MiddlewareFunc()) + { + + } } r.Run(":" + port) diff --git a/backend/www/asset-manifest.json b/backend/www/asset-manifest.json new file mode 100644 index 0000000..9b172e3 --- /dev/null +++ b/backend/www/asset-manifest.json @@ -0,0 +1,23 @@ +{ + "files": { + "main.css": "/static/css/main.8c8b27cf.chunk.css", + "main.js": "/static/js/main.dc5ea753.chunk.js", + "main.js.map": "/static/js/main.dc5ea753.chunk.js.map", + "runtime-main.js": "/static/js/runtime-main.d0ac5cd7.js", + "runtime-main.js.map": "/static/js/runtime-main.d0ac5cd7.js.map", + "static/js/2.5077aee4.chunk.js": "/static/js/2.5077aee4.chunk.js", + "static/js/2.5077aee4.chunk.js.map": "/static/js/2.5077aee4.chunk.js.map", + "static/js/3.7d3b22ba.chunk.js": "/static/js/3.7d3b22ba.chunk.js", + "static/js/3.7d3b22ba.chunk.js.map": "/static/js/3.7d3b22ba.chunk.js.map", + "index.html": "/index.html", + "static/css/main.8c8b27cf.chunk.css.map": "/static/css/main.8c8b27cf.chunk.css.map", + "static/js/2.5077aee4.chunk.js.LICENSE.txt": "/static/js/2.5077aee4.chunk.js.LICENSE.txt", + "static/media/logo.6ce24c58.svg": "/static/media/logo.6ce24c58.svg" + }, + "entrypoints": [ + "static/js/runtime-main.d0ac5cd7.js", + "static/js/2.5077aee4.chunk.js", + "static/css/main.8c8b27cf.chunk.css", + "static/js/main.dc5ea753.chunk.js" + ] +} \ No newline at end of file diff --git a/backend/www/favicon.ico b/backend/www/favicon.ico new file mode 100644 index 0000000..a11777c Binary files /dev/null and b/backend/www/favicon.ico differ diff --git a/backend/www/index.html b/backend/www/index.html new file mode 100644 index 0000000..e553ca9 --- /dev/null +++ b/backend/www/index.html @@ -0,0 +1 @@ +React App
\ No newline at end of file diff --git a/backend/www/logo192.png b/backend/www/logo192.png new file mode 100644 index 0000000..fc44b0a Binary files /dev/null and b/backend/www/logo192.png differ diff --git a/backend/www/logo512.png b/backend/www/logo512.png new file mode 100644 index 0000000..a4e47a6 Binary files /dev/null and b/backend/www/logo512.png differ diff --git a/backend/www/manifest.json b/backend/www/manifest.json new file mode 100644 index 0000000..080d6c7 --- /dev/null +++ b/backend/www/manifest.json @@ -0,0 +1,25 @@ +{ + "short_name": "React App", + "name": "Create React App Sample", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + }, + { + "src": "logo192.png", + "type": "image/png", + "sizes": "192x192" + }, + { + "src": "logo512.png", + "type": "image/png", + "sizes": "512x512" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/backend/www/robots.txt b/backend/www/robots.txt new file mode 100644 index 0000000..e9e57dc --- /dev/null +++ b/backend/www/robots.txt @@ -0,0 +1,3 @@ +# https://www.robotstxt.org/robotstxt.html +User-agent: * +Disallow: diff --git a/backend/www/static/css/main.8c8b27cf.chunk.css b/backend/www/static/css/main.8c8b27cf.chunk.css new file mode 100644 index 0000000..33d17e2 --- /dev/null +++ b/backend/www/static/css/main.8c8b27cf.chunk.css @@ -0,0 +1,2 @@ +body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}code{font-family:source-code-pro,Menlo,Monaco,Consolas,"Courier New",monospace}.App{text-align:center}.App-logo{height:40vmin;pointer-events:none}@media (prefers-reduced-motion:no-preference){.App-logo{animation:App-logo-spin 20s linear infinite}}.App-header{background-color:#282c34;min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:calc(10px + 2vmin);color:#fff}.App-link{color:#61dafb}@keyframes App-logo-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}} +/*# sourceMappingURL=main.8c8b27cf.chunk.css.map */ \ No newline at end of file diff --git a/backend/www/static/css/main.8c8b27cf.chunk.css.map b/backend/www/static/css/main.8c8b27cf.chunk.css.map new file mode 100644 index 0000000..8724e99 --- /dev/null +++ b/backend/www/static/css/main.8c8b27cf.chunk.css.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack://src/index.css","webpack://src/App.css"],"names":[],"mappings":"AAAA,KACE,QAAS,CACT,mJAEY,CACZ,kCAAmC,CACnC,iCACF,CAEA,KACE,yEAEF,CCZA,KACE,iBACF,CAEA,UACE,aAAc,CACd,mBACF,CAEA,8CACE,UACE,2CACF,CACF,CAEA,YACE,wBAAyB,CACzB,gBAAiB,CACjB,YAAa,CACb,qBAAsB,CACtB,kBAAmB,CACnB,sBAAuB,CACvB,4BAA6B,CAC7B,UACF,CAEA,UACE,aACF,CAEA,yBACE,GACE,sBACF,CACA,GACE,uBACF,CACF","file":"main.8c8b27cf.chunk.css","sourcesContent":["body {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',\n monospace;\n}\n",".App {\n text-align: center;\n}\n\n.App-logo {\n height: 40vmin;\n pointer-events: none;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n .App-logo {\n animation: App-logo-spin infinite 20s linear;\n }\n}\n\n.App-header {\n background-color: #282c34;\n min-height: 100vh;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n font-size: calc(10px + 2vmin);\n color: white;\n}\n\n.App-link {\n color: #61dafb;\n}\n\n@keyframes App-logo-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n"]} \ No newline at end of file diff --git a/backend/www/static/js/2.5077aee4.chunk.js b/backend/www/static/js/2.5077aee4.chunk.js new file mode 100644 index 0000000..4766695 --- /dev/null +++ b/backend/www/static/js/2.5077aee4.chunk.js @@ -0,0 +1,3 @@ +/*! For license information please see 2.5077aee4.chunk.js.LICENSE.txt */ +(this.webpackJsonpfrontend=this.webpackJsonpfrontend||[]).push([[2],[function(e,t,n){"use strict";e.exports=n(4)},function(e,t,n){"use strict";e.exports=n(5)},function(e,t,n){"use strict";var r=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;function o(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(l){return!1}}()?Object.assign:function(e,t){for(var n,u,i=o(e),s=1;s