Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ jobs:

- uses: actions/setup-go@v5
with:
go-version-file: src/go.mod
go-version-file: go.mod

- name: Build
working-directory: src
run: go build ./...

- name: Test
working-directory: src
run: go test ./...
9 changes: 5 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

## General

- This is a Go HTTP API backed by PostgreSQL. Source lives under `src/`.
- Build: `cd src && go build ./...`
- Test: `cd src && go test ./...`
- This is a Go HTTP API backed by PostgreSQL. The executable entrypoint lives under `cmd/fmsg-webapi/`, with application packages under `internal/`.
- Build: `go build ./...`
- Test: `go test ./...`
- Always run tests after making code changes to verify nothing is broken.
- This repository is an open-source implementation and not tied to one specific deployment - config should come from the environment
- Check sensitive files are not accidentally committed to git, e.g .env should NEVER be

## README

Expand All @@ -18,7 +19,7 @@
- Change build or run instructions.

The API routes table and each route's section must reflect the live code in
`src/main.go` and `src/handlers/`.
`cmd/fmsg-webapi/main.go` and `internal/handlers/`.

## Database

Expand Down
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,12 @@ shared secret in `FMSG_API_JWT_SECRET`. Required claims are `sub` and `exp`;
Requires **Go 1.25** or newer.

```bash
cd src
go build ./...
```

## Testing

```bash
cd src
go test ./...
```

Expand All @@ -110,8 +108,7 @@ export PGUSER=fmsg
export PGPASSWORD=secret
export PGDATABASE=fmsg

cd src
go run .
go run ./cmd/fmsg-webapi
```

### Plain HTTP mode (development / reverse proxy)
Expand All @@ -131,8 +128,7 @@ export PGUSER=fmsg
export PGPASSWORD=secret
export PGDATABASE=fmsg

cd src
go run .
go run ./cmd/fmsg-webapi
```

The server starts on port `8000` by default. Override with `FMSG_API_PORT`.
Expand Down
6 changes: 3 additions & 3 deletions src/main.go → cmd/fmsg-webapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"

"github.com/markmnl/fmsg-webapi/db"
"github.com/markmnl/fmsg-webapi/handlers"
"github.com/markmnl/fmsg-webapi/middleware"
"github.com/markmnl/fmsg-webapi/internal/db"
"github.com/markmnl/fmsg-webapi/internal/handlers"
"github.com/markmnl/fmsg-webapi/internal/middleware"
)

func main() {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/gin-gonic/gin"
"github.com/jackc/pgx/v5"

"github.com/markmnl/fmsg-webapi/db"
"github.com/markmnl/fmsg-webapi/middleware"
"github.com/markmnl/fmsg-webapi/internal/db"
"github.com/markmnl/fmsg-webapi/internal/middleware"
)

// AttachmentHandler holds dependencies for attachment routes.
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/handlers/messages.go → internal/handlers/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
"github.com/gin-gonic/gin"
"github.com/jackc/pgx/v5"

"github.com/markmnl/fmsg-webapi/db"
"github.com/markmnl/fmsg-webapi/middleware"
"github.com/markmnl/fmsg-webapi/models"
"github.com/markmnl/fmsg-webapi/internal/db"
"github.com/markmnl/fmsg-webapi/internal/middleware"
"github.com/markmnl/fmsg-webapi/internal/models"
)

// MessageHandler holds dependencies for message routes.
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/handlers/push.go → internal/handlers/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/gin-gonic/gin"
"github.com/jackc/pgx/v5"

"github.com/markmnl/fmsg-webapi/db"
"github.com/markmnl/fmsg-webapi/middleware"
"github.com/markmnl/fmsg-webapi/internal/db"
"github.com/markmnl/fmsg-webapi/internal/middleware"
)

// pushTimeout caps how long a single new_msg push fan-out may take. It runs on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/gin-gonic/gin"

"github.com/markmnl/fmsg-webapi/middleware"
"github.com/markmnl/fmsg-webapi/internal/middleware"
)

func TestShouldPrune(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/ws.go → internal/handlers/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"

"github.com/markmnl/fmsg-webapi/middleware"
"github.com/markmnl/fmsg-webapi/internal/middleware"
)

// WebSocket tuning constants.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading