commit 7e08411ece78037f0ee2021983db3cb725815c5b Author: juls0730 <62722391+juls0730@users.noreply.github.com> Date: Tue Sep 3 22:24:57 2024 -0500 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4a2a4a0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +filething \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c8f80ac --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM golang:alpine + +WORKDIR /app + +COPY . /app + +RUN apk add npm + +RUN go generate +RUN go build main.go + +ENTRYPOINT main.go \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a430e09 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,35 @@ +name: filething + +networks: + filething: + external: false + +services: + filething: + build: . + environment: + - USER_UID=1000 + - USER_GID=1000 + - DB_HOST=db:5432 + - DB_NAME=filething + - DB_USER=filething + - DB_PASSWD=filething + restart: always + networks: + - filething + depends_on: + - db + ports: + - "1323:1323" + + db: + image: postgres:14 + restart: always + environment: + - POSTGRES_USER=filething + - POSTGRES_PASSWD=filething + - POSTGRES_DB=filething + networks: + - filething + volumes: + - ./postgres:/var/lib/postgresql/data diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..79a14fd --- /dev/null +++ b/go.mod @@ -0,0 +1,16 @@ +module filething + +go 1.23.0 + +require ( + github.com/labstack/echo/v4 v4.12.0 // indirect + github.com/labstack/gommon v0.4.2 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/valyala/fasttemplate v1.2.2 // indirect + golang.org/x/crypto v0.22.0 // indirect + golang.org/x/net v0.24.0 // indirect + golang.org/x/sys v0.19.0 // indirect + golang.org/x/text v0.14.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..f8322c3 --- /dev/null +++ b/go.sum @@ -0,0 +1,23 @@ +github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0= +github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM= +github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= +github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU= +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.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +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.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= +github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +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.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= diff --git a/main.go b/main.go new file mode 100644 index 0000000..9385849 --- /dev/null +++ b/main.go @@ -0,0 +1,59 @@ +//go:generate npm --prefix ./ui run generate +package main + +import ( + "filething/ui" + "fmt" + "net/http" + + "github.com/labstack/echo/v4" +) + +func main() { + e := echo.New() + + api := e.Group("/api") + { + api.GET("/hello", func(c echo.Context) error { + return c.JSON(http.StatusOK, map[string]string{"message": "Hello, World!!!"}) + }) + } + + e.GET("/*", echo.StaticDirectoryHandler(ui.DistDirFS, false)) + + e.HTTPErrorHandler = customHTTPErrorHandler + + e.Logger.Fatal(e.Start(":1323")) +} + +func customHTTPErrorHandler(err error, c echo.Context) { + code := http.StatusInternalServerError + if he, ok := err.(*echo.HTTPError); ok { + code = he.Code + } + c.Logger().Error(err) + errorPage := fmt.Sprintf("%d.html", code) + file, err := ui.DistDirFS.Open(errorPage) + if err != nil { + c.Logger().Error(err) + } + + fileInfo, err := file.Stat() + if err != nil { + c.Logger().Error(err) + } + + fileBuf := make([]byte, fileInfo.Size()) + _, err = file.Read(fileBuf) + defer func() { + if err := file.Close(); err != nil { + panic(err) + } + }() + if err != nil { + c.Logger().Error(err) + panic(err) + } + + c.HTML(http.StatusNotFound, string(fileBuf)) +} diff --git a/ui/.gitignore b/ui/.gitignore new file mode 100644 index 0000000..4a7f73a --- /dev/null +++ b/ui/.gitignore @@ -0,0 +1,24 @@ +# Nuxt dev/build outputs +.output +.data +.nuxt +.nitro +.cache +dist + +# Node dependencies +node_modules + +# Logs +logs +*.log + +# Misc +.DS_Store +.fleet +.idea + +# Local env files +.env +.env.* +!.env.example diff --git a/ui/README.md b/ui/README.md new file mode 100644 index 0000000..f5db2a2 --- /dev/null +++ b/ui/README.md @@ -0,0 +1,75 @@ +# Nuxt 3 Minimal Starter + +Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more. + +## Setup + +Make sure to install the dependencies: + +```bash +# npm +npm install + +# pnpm +pnpm install + +# yarn +yarn install + +# bun +bun install +``` + +## Development Server + +Start the development server on `http://localhost:3000`: + +```bash +# npm +npm run dev + +# pnpm +pnpm run dev + +# yarn +yarn dev + +# bun +bun run dev +``` + +## Production + +Build the application for production: + +```bash +# npm +npm run build + +# pnpm +pnpm run build + +# yarn +yarn build + +# bun +bun run build +``` + +Locally preview production build: + +```bash +# npm +npm run preview + +# pnpm +pnpm run preview + +# yarn +yarn preview + +# bun +bun run preview +``` + +Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information. diff --git a/ui/app.vue b/ui/app.vue new file mode 100644 index 0000000..cc25a49 --- /dev/null +++ b/ui/app.vue @@ -0,0 +1,5 @@ + diff --git a/ui/assets/css/main.css b/ui/assets/css/main.css new file mode 100644 index 0000000..b5c61c9 --- /dev/null +++ b/ui/assets/css/main.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; diff --git a/ui/bun.lockb b/ui/bun.lockb new file mode 100755 index 0000000..62d9244 Binary files /dev/null and b/ui/bun.lockb differ diff --git a/ui/components/Nav.vue b/ui/components/Nav.vue new file mode 100644 index 0000000..ba53413 --- /dev/null +++ b/ui/components/Nav.vue @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/ui/embed.go b/ui/embed.go new file mode 100644 index 0000000..d16fa82 --- /dev/null +++ b/ui/embed.go @@ -0,0 +1,14 @@ +// Package ui handles the frontend embedding +package ui + +import ( + "embed" + + "github.com/labstack/echo/v4" +) + +//go:embed all:.output/public +var distDir embed.FS + +// DistDirFS contains the embedded dist directory files (without the "dist" prefix) +var DistDirFS = echo.MustSubFS(distDir, ".output/public") diff --git a/ui/nuxt.config.ts b/ui/nuxt.config.ts new file mode 100644 index 0000000..f0cc46a --- /dev/null +++ b/ui/nuxt.config.ts @@ -0,0 +1,25 @@ +// https://nuxt.com/docs/api/configuration/nuxt-config +export default defineNuxtConfig({ + compatibilityDate: '2024-04-03', + + css: ['~/assets/css/main.css'], + + ssr: true, + + modules: [ + '@nuxtjs/color-mode', + ], + + colorMode: { + classSuffix: '' + }, + + devtools: { enabled: true }, + + postcss: { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, + }, +}) diff --git a/ui/package.json b/ui/package.json new file mode 100644 index 0000000..5b3f700 --- /dev/null +++ b/ui/package.json @@ -0,0 +1,22 @@ +{ + "name": "nuxt-app", + "private": true, + "type": "module", + "scripts": { + "build": "nuxt build", + "dev": "nuxt dev", + "generate": "nuxt generate", + "preview": "nuxt preview", + "postinstall": "nuxt prepare" + }, + "dependencies": { + "@nuxtjs/color-mode": "^3.4.4", + "nuxt": "^3.13.0", + "vue": "latest" + }, + "devDependencies": { + "autoprefixer": "^10.4.20", + "postcss": "^8.4.44", + "tailwindcss": "^3.4.10" + } +} diff --git a/ui/pages/home.vue b/ui/pages/home.vue new file mode 100644 index 0000000..2eea24d --- /dev/null +++ b/ui/pages/home.vue @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/ui/pages/index.vue b/ui/pages/index.vue new file mode 100644 index 0000000..0ad8695 --- /dev/null +++ b/ui/pages/index.vue @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/ui/pages/login.vue b/ui/pages/login.vue new file mode 100644 index 0000000..d92150a --- /dev/null +++ b/ui/pages/login.vue @@ -0,0 +1,38 @@ + + + \ No newline at end of file diff --git a/ui/pages/signup.vue b/ui/pages/signup.vue new file mode 100644 index 0000000..4a8c328 --- /dev/null +++ b/ui/pages/signup.vue @@ -0,0 +1,36 @@ + + + \ No newline at end of file diff --git a/ui/public/favicon.ico b/ui/public/favicon.ico new file mode 100644 index 0000000..18993ad Binary files /dev/null and b/ui/public/favicon.ico differ diff --git a/ui/public/robots.txt b/ui/public/robots.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/ui/public/robots.txt @@ -0,0 +1 @@ + diff --git a/ui/tailwind.config.js b/ui/tailwind.config.js new file mode 100644 index 0000000..cc671d2 --- /dev/null +++ b/ui/tailwind.config.js @@ -0,0 +1,15 @@ +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: [ + "./components/**/*.{js,vue,ts}", + "./layouts/**/*.vue", + "./pages/**/*.vue", + "./plugins/**/*.{js,ts}", + "./app.vue", + "./error.vue", + ], + theme: { + extend: {}, + }, + plugins: [], +}; diff --git a/ui/tsconfig.json b/ui/tsconfig.json new file mode 100644 index 0000000..a746f2a --- /dev/null +++ b/ui/tsconfig.json @@ -0,0 +1,4 @@ +{ + // https://nuxt.com/docs/guide/concepts/typescript + "extends": "./.nuxt/tsconfig.json" +}