mood/inspo boards

Compare changes

Choose any two refs to compare.

+3
.dockerignore
··· 1 + *.env 2 + .gitignore 3 + *.md
+4
.gitignore
··· 1 + build 2 + .env 3 + *.db* 4 + *.shm
+32
Dockerfile
··· 1 + # syntax=docker/dockerfile:1 2 + 3 + FROM golang:1.25-alpine AS builder 4 + 5 + ENV CGO_ENABLED=1 \ 6 + GOOS=linux 7 + 8 + RUN apk add --no-cache \ 9 + gcc \ 10 + musl-dev 11 + 12 + WORKDIR /build 13 + 14 + COPY go.mod go.sum ./ 15 + 16 + RUN go mod download 17 + 18 + COPY . . 19 + 20 + RUN go build -o /app ./cmd/main.go 21 + 22 + FROM alpine:3.23 AS final 23 + 24 + COPY --from=builder /app /bin/build 25 + 26 + # https://github.com/bluesky-social/indigo/blob/main/cmd/relay/Dockerfile#L39 27 + ENV GODEBUG=netdns=go 28 + ENV TZ=Etc/UTC 29 + 30 + EXPOSE 8080 31 + 32 + CMD ["bin/build", "start"]
-30
cmd/api/api.go
··· 1 - package api 2 - 3 - import ( 4 - "database/sql" 5 - "log/slog" 6 - "net/http" 7 - 8 - "github.com/gorilla/mux" 9 - ) 10 - 11 - type Server struct { 12 - addr string 13 - db *sql.DB 14 - logger *slog.Logger 15 - } 16 - 17 - func NewServer(addr string, db *sql.DB, logger *slog.Logger) *Server { 18 - return &Server{ 19 - addr, 20 - db, 21 - logger, 22 - } 23 - } 24 - 25 - func (s *Server) Start() error { 26 - router := mux.NewRouter() 27 - 28 - s.logger.Info("app server started") 29 - return http.ListenAndServe(s.addr, router) 30 - }
+65 -3
cmd/main.go
··· 1 1 package main 2 2 3 - import "fmt" 3 + import ( 4 + "context" 5 + "os" 6 + 7 + "github.com/charmbracelet/log" 8 + _ "github.com/joho/godotenv/autoload" 9 + "github.com/urfave/cli/v3" 10 + "tangled.org/dane.is.extraordinarily.cool/pallet/internal/db" 11 + "tangled.org/dane.is.extraordinarily.cool/pallet/internal/server" 12 + ) 4 13 5 14 func main() { 6 - fmt.Println("this is the start of Pallet!") 7 - } 15 + if err := run(os.Args); err != nil { 16 + log.Fatal(err) 17 + os.Exit(-1) 18 + } 19 + } 20 + 21 + func run(args []string) error { 22 + app := &cli.Command{ 23 + Name: "pallet", 24 + Usage: "pallet app server", 25 + } 26 + 27 + app.Flags = []cli.Flag{ 28 + &cli.StringFlag{ 29 + Name: "log-level", 30 + Usage: "log verbosity level (eg: warn, info, debug)", 31 + Sources: cli.EnvVars("GO_LOG_LEVEL", "LOG_LEVEL"), 32 + }, 33 + } 34 + 35 + app.Commands = []*cli.Command{ 36 + &cli.Command{ 37 + Name: "start", 38 + Usage: "start the pallet app server", 39 + Action: runServer, 40 + Flags: []cli.Flag{ 41 + &cli.StringFlag{ 42 + Name: "port", 43 + Usage: "Port to bind the HTTP server to", 44 + Value: ":8080", 45 + Sources: cli.EnvVars("PORT"), 46 + }, 47 + }, 48 + }, 49 + } 50 + 51 + return app.Run(context.Background(), args) 52 + } 53 + 54 + func runServer(ctx context.Context, cmd *cli.Command) error { 55 + logger := log.New(os.Stdout) 56 + db, err := db.NewSQLiteDB() 57 + if err != nil { 58 + log.Fatal(err) 59 + } 60 + logger.Info("database created") 61 + 62 + server := server.NewServer(cmd.String("port"), db, logger) 63 + 64 + if err := server.Start(); err != nil { 65 + log.Fatal(err) 66 + } 67 + 68 + return nil 69 + }
+25 -1
go.mod
··· 2 2 3 3 go 1.23.4 4 4 5 - require github.com/gorilla/mux v1.8.1 // indirect 5 + require ( 6 + github.com/gorilla/mux v1.8.1 7 + github.com/mattn/go-sqlite3 v1.14.32 8 + github.com/urfave/cli/v3 v3.6.1 9 + ) 10 + 11 + require ( 12 + github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect 13 + github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect 14 + github.com/charmbracelet/lipgloss v1.1.0 // indirect 15 + github.com/charmbracelet/log v0.4.2 // indirect 16 + github.com/charmbracelet/x/ansi v0.8.0 // indirect 17 + github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect 18 + github.com/charmbracelet/x/term v0.2.1 // indirect 19 + github.com/go-logfmt/logfmt v0.6.0 // indirect 20 + github.com/joho/godotenv v1.5.1 // indirect 21 + github.com/lucasb-eyer/go-colorful v1.2.0 // indirect 22 + github.com/mattn/go-isatty v0.0.20 // indirect 23 + github.com/mattn/go-runewidth v0.0.16 // indirect 24 + github.com/muesli/termenv v0.16.0 // indirect 25 + github.com/rivo/uniseg v0.4.7 // indirect 26 + github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect 27 + golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect 28 + golang.org/x/sys v0.30.0 // indirect 29 + )
+48
go.sum
··· 1 + github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= 2 + github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= 3 + github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs= 4 + github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk= 5 + github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= 6 + github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30= 7 + github.com/charmbracelet/log v0.4.2 h1:hYt8Qj6a8yLnvR+h7MwsJv/XvmBJXiueUcI3cIxsyig= 8 + github.com/charmbracelet/log v0.4.2/go.mod h1:qifHGX/tc7eluv2R6pWIpyHDDrrb/AG71Pf2ysQu5nw= 9 + github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE= 10 + github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q= 11 + github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8= 12 + github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs= 13 + github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= 14 + github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg= 15 + github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 16 + github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 17 + github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= 18 + github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= 1 19 github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= 2 20 github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= 21 + github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= 22 + github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= 23 + github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= 24 + github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= 25 + github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= 26 + github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= 27 + github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= 28 + github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= 29 + github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs= 30 + github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= 31 + github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc= 32 + github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk= 33 + github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 34 + github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 35 + github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= 36 + github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= 37 + github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= 38 + github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= 39 + github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= 40 + github.com/urfave/cli/v3 v3.6.1 h1:j8Qq8NyUawj/7rTYdBGrxcH7A/j7/G8Q5LhWEW4G3Mo= 41 + github.com/urfave/cli/v3 v3.6.1/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso= 42 + github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= 43 + github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= 44 + golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= 45 + golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= 46 + golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 47 + golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= 48 + golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 49 + gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 50 + gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+61
internal/db/db.go
··· 1 + package db 2 + 3 + import ( 4 + "database/sql" 5 + "log" 6 + 7 + _ "github.com/mattn/go-sqlite3" 8 + ) 9 + 10 + func NewSQLiteDB() (*sql.DB, error) { 11 + db, err := sql.Open("sqlite3", "./pallet.db") 12 + _, err = db.Exec(` 13 + pragma foreign_keys = on; 14 + pragma journal_mode = wal; 15 + 16 + create table if not exists boards ( 17 + uri text primary key, 18 + cid text not null, 19 + rkey text not null, 20 + owner text not null, 21 + name text not null, 22 + description text, 23 + created_at datetime default current_timestamp, 24 + indexed_at text not null 25 + ); 26 + 27 + create table if not exists board_item ( 28 + uri text primary key, 29 + cid text not null, 30 + rkey text not null, 31 + owner text not null, 32 + board_id text not null, 33 + type text not null check(type in ('text', 'image')), 34 + text text, 35 + 36 + blob_cid text, 37 + mime_type text, 38 + width integer, 39 + height integer, 40 + alt_text text, 41 + 42 + position integer, 43 + created_at datetime default current_timestamp, 44 + indexed_at text not null, 45 + 46 + foreign key(board_id) references boards(rkey) on delete cascade, 47 + 48 + check ( 49 + (type = 'text' and text is not null and blob_cid is null) or 50 + (type = 'image' and blob_cid is not null and text is null) 51 + ) 52 + ); 53 + `) 54 + 55 + if err != nil { 56 + log.Fatal("error initializing database", err) 57 + } 58 + 59 + defer db.Close() 60 + return db, nil 61 + }
+13
internal/server/handlers.go
··· 1 + package server 2 + 3 + import "net/http" 4 + 5 + func (s *Server) handleHomeRoute(w http.ResponseWriter, r *http.Request) { 6 + w.WriteHeader(http.StatusOK) 7 + w.Write([]byte("hello world")) 8 + } 9 + 10 + func (s *Server) handleHealthCheckRoute(w http.ResponseWriter, r *http.Request) { 11 + w.WriteHeader(http.StatusOK) 12 + w.Write([]byte("reporting for duty")) 13 + }
+79
internal/server/server.go
··· 1 + package server 2 + 3 + import ( 4 + "context" 5 + "database/sql" 6 + "fmt" 7 + "net/http" 8 + "time" 9 + 10 + "github.com/charmbracelet/log" 11 + "github.com/gorilla/mux" 12 + ) 13 + 14 + type Server struct { 15 + addr string 16 + db *sql.DB 17 + logger *log.Logger 18 + } 19 + 20 + type statusRecorder struct { 21 + http.ResponseWriter 22 + status int 23 + } 24 + 25 + func NewServer(addr string, db *sql.DB, logger *log.Logger) *Server { 26 + return &Server{ 27 + addr, 28 + db, 29 + logger, 30 + } 31 + } 32 + 33 + func (s *Server) Start() error { 34 + router := mux.NewRouter() 35 + router.Use(s.requestLoggerMiddleware) 36 + router.Use(s.contextWithTimeoutMiddleware) 37 + server := &http.Server{ 38 + Addr: s.addr, 39 + WriteTimeout: 5 * time.Second, 40 + ReadTimeout: 10 * time.Second, 41 + IdleTimeout: 30 * time.Second, 42 + Handler: router, 43 + } 44 + 45 + router.HandleFunc("/healthcheck", s.handleHomeRoute) 46 + router.HandleFunc("/", s.handleHealthCheckRoute) 47 + 48 + s.logger.Info(fmt.Sprintf("app server started at 0.0.0.0%s", s.addr)) 49 + return server.ListenAndServe() 50 + } 51 + 52 + func (s *Server) contextWithTimeoutMiddleware(next http.Handler) http.Handler { 53 + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 54 + ctx, cancel := context.WithTimeout(r.Context(), time.Second*30) 55 + defer cancel() 56 + r = r.WithContext(ctx) 57 + next.ServeHTTP(w, r) 58 + }) 59 + } 60 + 61 + func (s *Server) requestLoggerMiddleware(next http.Handler) http.Handler { 62 + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 63 + recorder := statusRecorder{ 64 + ResponseWriter: w, 65 + status: http.StatusOK, 66 + } 67 + 68 + next.ServeHTTP(recorder, r) 69 + var ( 70 + ip = r.RemoteAddr 71 + method = r.Method 72 + url = r.URL.String() 73 + proto = r.Proto 74 + timestamp = time.Now().Format(time.RFC850) 75 + ) 76 + 77 + s.logger.Info(fmt.Sprintf("%s [%s] %s %s %s %d", ip, timestamp, method, url, proto, recorder.status)) 78 + }) 79 + }
+11
justfile
··· 1 + default: 2 + @just --list 3 + 4 + dev: 5 + go run cmd/*.go start 6 + 7 + build: 8 + CGO_ENABLED=1 go build -o build/pallet ./cmd/main.go 9 + 10 + clean: 11 + rm -rf build
lexicons/board.json

This is a binary file and will not be displayed.

lexicons/item.json

This is a binary file and will not be displayed.