feat: add routers pkg
This commit is contained in:
@@ -12,3 +12,4 @@ gore
|
|||||||
- [ ] actually rewrite this properly
|
- [ ] actually rewrite this properly
|
||||||
- [ ] serve `index.html` from `/`
|
- [ ] serve `index.html` from `/`
|
||||||
- [ ] pack the assetins into the [binary](https://github.com/gin-gonic/examples/tree/master/assets-in-binary)
|
- [ ] pack the assetins into the [binary](https://github.com/gin-gonic/examples/tree/master/assets-in-binary)
|
||||||
|
- [ ] mise tasks for testing, releasing, etc, [example](https://github.com/jdx/mise/blob/main/tasks.toml)
|
||||||
|
|||||||
0
backend/conf/app.toml
Normal file
0
backend/conf/app.toml
Normal file
@@ -1,4 +1,4 @@
|
|||||||
module api
|
module git.madunde.ad/madundead/obi
|
||||||
|
|
||||||
go 1.25.3
|
go 1.25.3
|
||||||
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "fmt"
|
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
@@ -12,12 +11,15 @@ import (
|
|||||||
|
|
||||||
"github.com/gin-contrib/cors"
|
"github.com/gin-contrib/cors"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
|
"git.madunde.ad/madundead/obi/routers"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
router.SetTrustedProxies([]string{"127.0.0.1"}) // TODO: fix All origins allowed by default
|
router.SetTrustedProxies([]string{"127.0.0.1"}) // TODO: fix All origins allowed by default
|
||||||
router.Use(cors.Default())
|
router.Use(cors.Default())
|
||||||
|
|
||||||
list := listFiles("/home/madundead/Syncthing/Obsidian/Personal")
|
list := listFiles("/home/madundead/Syncthing/Obsidian/Personal")
|
||||||
|
|
||||||
router.GET("/api/v1/files", func(c *gin.Context) {
|
router.GET("/api/v1/files", func(c *gin.Context) {
|
||||||
@@ -29,17 +31,11 @@ func main() {
|
|||||||
|
|
||||||
router.GET("/api/v1/files/:id", func(c *gin.Context) {
|
router.GET("/api/v1/files/:id", func(c *gin.Context) {
|
||||||
id := c.Params.ByName("id")
|
id := c.Params.ByName("id")
|
||||||
// value, ok := db[user]
|
|
||||||
// if ok {
|
|
||||||
path, _ := base64.StdEncoding.DecodeString(id)
|
path, _ := base64.StdEncoding.DecodeString(id)
|
||||||
|
|
||||||
data, _ := os.ReadFile(string(path))
|
data, _ := os.ReadFile(string(path))
|
||||||
// fmt.Print(string(dat))
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{"data": string(data)})
|
c.JSON(http.StatusOK, gin.H{"data": string(data)})
|
||||||
// } else {
|
|
||||||
// c.JSON(http.StatusOK, gin.H{"user": user, "status": "no value"})
|
|
||||||
// }
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if err := router.Run(); err != nil {
|
if err := router.Run(); err != nil {
|
||||||
3
backend/routers/go.mod
Normal file
3
backend/routers/go.mod
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module routers
|
||||||
|
|
||||||
|
go 1.25.3
|
||||||
4
backend/routers/main.go
Normal file
4
backend/routers/main.go
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package routers
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
}
|
||||||
1
backend/tmp/build-errors.log
Normal file
1
backend/tmp/build-errors.log
Normal file
@@ -0,0 +1 @@
|
|||||||
|
exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1
|
||||||
BIN
backend/tmp/main
Executable file
BIN
backend/tmp/main
Executable file
Binary file not shown.
13
mise.toml
13
mise.toml
@@ -3,13 +3,8 @@ go = "latest"
|
|||||||
bun = "latest"
|
bun = "latest"
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
# PORT = "8912" # api port
|
BE_PORT = "8912" # api port
|
||||||
# FRONTEND_PORT = "8913"
|
FE_PORT = "8913"
|
||||||
|
|
||||||
[tasks.dev]
|
[task_config]
|
||||||
description = 'Run BE & FE in tmux'
|
includes = ["tasks.toml"]
|
||||||
run = [
|
|
||||||
'tmux new-window "cd api; go install; PORT=8912 air"',
|
|
||||||
'tmux split-window "cd frontend; bun install; PORT=8913 bun src/index.tsx"',
|
|
||||||
'xdg-open "http://localhost:8913" || open "http://localhost:8913"'
|
|
||||||
]
|
|
||||||
|
|||||||
10
tasks.toml
Normal file
10
tasks.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[dev]
|
||||||
|
run = 'mise dev:tmux'
|
||||||
|
|
||||||
|
["dev:tmux"]
|
||||||
|
description = 'Run BE & FE in tmux'
|
||||||
|
run = [
|
||||||
|
'tmux new-window "cd backend; go install; PORT=8912 air"',
|
||||||
|
'tmux split-window "cd frontend; bun install; PORT=8913 bun src/index.tsx"',
|
||||||
|
'sleep 0.1 && (xdg-open "http://localhost:8913" || open "http://localhost:8913")'
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user