From 0f34300a8aa88d4fb3f2c0817c3943fcad4267ab Mon Sep 17 00:00:00 2001 From: "Ricardo (XenGi) Band" Date: Thu, 19 Oct 2023 17:58:36 +0200 Subject: [PATCH 1/3] switch to go --- Dockerfile | 40 ---------------------------------------- bun.lockb | Bin 2743 -> 0 bytes flake.nix | 2 +- go.mod | 3 +++ package.json | 21 --------------------- server.ts | 32 -------------------------------- tsconfig.json | 22 ---------------------- 7 files changed, 4 insertions(+), 116 deletions(-) delete mode 100644 Dockerfile delete mode 100755 bun.lockb create mode 100644 go.mod delete mode 100644 package.json delete mode 100644 server.ts delete mode 100644 tsconfig.json diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 7693d73..0000000 --- a/Dockerfile +++ /dev/null @@ -1,40 +0,0 @@ -# use the official Bun image -# see all versions at https://hub.docker.com/r/oven/bun/tags -FROM docker.io/oven/bun:1 as base -WORKDIR /usr/src/app - -# install dependencies into temp directory -# this will cache them and speed up future builds -FROM base AS install -RUN mkdir -p /temp/dev -COPY package.json bun.lockb /temp/dev/ -RUN cd /temp/dev && bun install --frozen-lockfile - -# install with --production (exclude devDependencies) -RUN mkdir -p /temp/prod -COPY package.json bun.lockb /temp/prod/ -RUN cd /temp/prod && bun install --frozen-lockfile --production - -# copy node_modules from temp directory -# then copy all (non-ignored) project files into the image -FROM install AS prerelease -COPY --from=install /temp/dev/node_modules node_modules -COPY . . - -# [optional] tests & build -ENV NODE_ENV=production -RUN bun test -RUN bun run build - -# copy production dependencies and source code into final image -FROM base AS release -COPY --from=install /temp/prod/node_modules node_modules -COPY --from=prerelease /usr/src/app/index.ts . -COPY --from=prerelease /usr/src/app/package.json . - -# run the app -USER bun -EXPOSE 8000/tcp -EXPOSE 8080/tcp -ENTRYPOINT [ "bun", "run", "index.ts" ] - diff --git a/bun.lockb b/bun.lockb deleted file mode 100755 index 0b96ba4ffbeabf03d5d2803c8bf63807d2fbe605..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2743 zcmY#Z)GsYA(of3F(@)JSQ%EY!;{sycoc!eMw9K4T-L(9o+{6;yG6OCq1_p+>JuxSk z6r^Ubc%M95z5Jc$cP0Nf)~^hrPamHfn%LdZrp^Ua1O#jlih%=-Zh-RhUef zjz-!qR&?=SyT(>f{U-fvhtO-K`Kk>%+O4Tcj3A8^0FbXiKp2RPf%XdlX_y#DoDhJi z4FW230O|+1hlP+PBzc(r)j%;Tpng*Hf{cObe+tzP3lDe%fE3{YF#Xy*MqyqOojDP}g_(vtjbX}B$G zSF?Y-B+zXzbCJW3WxDo8o2>tlKeDI3+{Us0N>QoIb#pBZCN&nDcN6<=Jc(BMsvSDa#1O?&AmBCmwEqdcDZz2`<8a4H*Z`PPfK{qF8*uEvNHjpZ!-3& zZCsYaydgGmVZdS0>lR17XVtvHoJLcc`y9+VCf#Ea44v?)k*EY4;DYt(~Cmoj4)MNA}m8>mWmj1fcMT zl{LvZnR;2pL}~;ogM|f*CSE5(C33n#hz@tw257N!1WI$+6c;7yW#$!^B;vfm#UIR!3aGwcaQ)FnX0fFfKrfiV-C&5~1)y$7 zeFm$i1Q_E?^$he3z@p$94_1?LFy$ncq!t4!M_3&RulwMI2rMPTYC|T*I72-{kZFs6 z_JHb7SpCSvI0+~s02J|nR?Zzz8Z|D8Q*+Bwi}YM8N>YpR5_5t}iZb)k?Gy|V9#KS4nYkY7x-H*vkryL22GUdr0b3XPx)55|&_d4$7}h1}RXO?j#i_c$hEHZ%B_8d_%7CUIb9D{% zOdw{(8H3_ap{7P54kTibRjgZ*pPialjK^TO8lb6gwk}vZ$a#2l!hH?Y31 Date: Thu, 19 Oct 2023 18:01:48 +0200 Subject: [PATCH 2/3] setup echo --- .gitignore | 297 ++++++++++++++++------------------------------------- go.mod | 13 +++ go.sum | 37 +++++++ server.go | 15 +++ 4 files changed, 155 insertions(+), 207 deletions(-) create mode 100644 go.sum create mode 100644 server.go diff --git a/.gitignore b/.gitignore index e70e837..8ddc10e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,218 +1,34 @@ -# Created by https://www.toptal.com/developers/gitignore/api/linux,windows,macos,node,vim,webstorm+all,direnv -# Edit at https://www.toptal.com/developers/gitignore?templates=linux,windows,macos,node,vim,webstorm+all,direnv +# Created by https://www.toptal.com/developers/gitignore/api/linux,windows,macos,vim,goland+all,go,direnv +# Edit at https://www.toptal.com/developers/gitignore?templates=linux,windows,macos,vim,goland+all,go,direnv ### direnv ### .direnv .envrc -### Linux ### -*~ +### Go ### +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* +# Test binary, built with `go test -c` +*.test -# KDE directory preferences -.directory +# Output of the go coverage tool, specifically when used with LiteIDE +*.out -# Linux trash folder which might appear on any partition or disk -.Trash-* +# Dependency directories (remove the comment below to include it) +# vendor/ -# .nfs files are created when an open file is removed but is still being accessed -.nfs* +# Go workspace file +go.work -### macOS ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### macOS Patch ### -# iCloud generated files -*.icloud - -### Node ### -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory -.temp - -# Docusaurus cache and generated files -.docusaurus - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* - -### Node Patch ### -# Serverless Webpack directories -.webpack/ - -# Optional stylelint cache - -# SvelteKit build / generate output -.svelte-kit - -### Vim ### -# Swap -[._]*.s[a-v][a-z] -!*.svg # comment out if you don't need vector files -[._]*.sw[a-p] -[._]s[a-rt-v][a-z] -[._]ss[a-gi-z] -[._]sw[a-p] - -# Session -Session.vim -Sessionx.vim - -# Temporary -.netrwhist -# Auto-generated tag files -tags -# Persistent undo -[._]*.un~ - -### WebStorm+all ### +### GoLand+all ### # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 @@ -291,7 +107,7 @@ fabric.properties # Android studio 3.1+ serialized cache file .idea/caches/build_file_checksums.ser -### WebStorm+all Patch ### +### GoLand+all Patch ### # Ignore everything but code style settings and run configurations # that are supposed to be shared within teams. @@ -300,6 +116,73 @@ fabric.properties !.idea/codeStyles !.idea/runConfigurations +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + ### Windows ### # Windows thumbnail cache files Thumbs.db @@ -326,4 +209,4 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk -# End of https://www.toptal.com/developers/gitignore/api/linux,windows,macos,node,vim,webstorm+all,direnv +# End of https://www.toptal.com/developers/gitignore/api/linux,windows,macos,vim,goland+all,go,direnv diff --git a/go.mod b/go.mod index 32b28c0..1ec3e12 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,16 @@ module github.com/cccb/sanic go 1.20 + +require ( + github.com/labstack/echo/v4 v4.11.2 // indirect + github.com/labstack/gommon v0.4.0 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/valyala/fasttemplate v1.2.2 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e2021d0 --- /dev/null +++ b/go.sum @@ -0,0 +1,37 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/labstack/echo/v4 v4.11.2 h1:T+cTLQxWCDfqDEoydYm5kCobjmHwOwcv4OJAPHilmdE= +github.com/labstack/echo/v4 v4.11.2/go.mod h1:UcGuQ8V6ZNRmSweBIJkPvGfwCMIlFmiqrPqiEBfPYws= +github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= +github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= +github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= +github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/server.go b/server.go new file mode 100644 index 0000000..1c8e0b1 --- /dev/null +++ b/server.go @@ -0,0 +1,15 @@ +package main + +import ( + "net/http" + + "github.com/labstack/echo/v4" +) + +func main() { + e := echo.New() + e.GET("/", func(c echo.Context) error { + return c.String(http.StatusOK, "Hello, World!") + }) + e.Logger.Fatal(e.Start(":1323")) +} From 51555f4d21292b20be6e711772090a4eba03c772 Mon Sep 17 00:00:00 2001 From: "Ricardo (XenGi) Band" Date: Thu, 19 Oct 2023 18:05:16 +0200 Subject: [PATCH 3/3] add js and css files --- server.go | 1 + index.html => static/index.html | 1 + static/index.js | 0 static/style.css | 0 4 files changed, 2 insertions(+) rename index.html => static/index.html (98%) create mode 100644 static/index.js create mode 100644 static/style.css diff --git a/server.go b/server.go index 1c8e0b1..c843fc3 100644 --- a/server.go +++ b/server.go @@ -8,6 +8,7 @@ import ( func main() { e := echo.New() + e.Static("/", "static") e.GET("/", func(c echo.Context) error { return c.String(http.StatusOK, "Hello, World!") }) diff --git a/index.html b/static/index.html similarity index 98% rename from index.html rename to static/index.html index f3bc292..d734912 100644 --- a/index.html +++ b/static/index.html @@ -133,6 +133,7 @@

sanic mpd web ui - by XenGi and coon © 2023

+ diff --git a/static/index.js b/static/index.js new file mode 100644 index 0000000..e69de29 diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..e69de29