Skip to content

Commit 307ab6f

Browse files
authored
Merge branch 'main' into new-schemas
2 parents 374a3f8 + e239cfc commit 307ab6f

27 files changed

+552
-154
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf
Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
name: godoc_pr_preview
2-
3-
on:
4-
pull_request:
5-
types:
6-
- opened
7-
- synchronize
8-
9-
jobs:
10-
request_documentation:
11-
runs-on: ubuntu-latest
12-
13-
steps:
14-
- name: Set up Go
15-
uses: actions/setup-go@v2
16-
with:
17-
go-version: 1.21
18-
19-
- name: Generate comment
20-
id: generate_comment
21-
run: |
22-
set -x
23-
version=$(go mod download --json $REPO@$REV | jq -r .Version)
24-
echo "Module version: $version"
25-
echo "version=$version" >> "$GITHUB_OUTPUT"
26-
27-
link="https://godocs.io/$REPO@$version"
28-
comment="### godoc reference preview ready ✨<br>[![Go Documentation](https://godocs.io/github.com/acmcsufoss/api.acmcsuf.com?status.svg)]($link)"
29-
echo "comment=$comment" >> "$GITHUB_OUTPUT"
30-
env:
31-
REPO: github.com/${{ github.event.pull_request.base.repo.full_name }}
32-
REV: ${{ github.event.pull_request.head.sha }}
33-
34-
- name: Update existing issue comment
35-
uses: peter-evans/find-comment@v1
36-
id: fc
37-
with:
38-
issue-number: ${{ github.event.pull_request.number }}
39-
comment-author: "github-actions[bot]"
40-
body-includes: "### godoc reference preview ready ✨"
41-
edit-mode: replace
42-
43-
- name: Update comment
44-
if: steps.fc.outputs.comment-id != ''
45-
uses: peter-evans/create-or-update-comment@v1
46-
with:
47-
comment-id: ${{ steps.fc.outputs.comment-id }}
48-
body: ${{ steps.generate_comment.outputs.comment }}
49-
edit-mode: replace
1+
name: godoc_pr_preview
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
9+
jobs:
10+
request_documentation:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Set up Go
15+
uses: actions/setup-go@v2
16+
with:
17+
go-version: 1.21
18+
19+
- name: Generate comment
20+
id: generate_comment
21+
run: |
22+
set -x
23+
version=$(go mod download --json $REPO@$REV | jq -r .Version)
24+
echo "Module version: $version"
25+
echo "version=$version" >> "$GITHUB_OUTPUT"
26+
27+
link="https://godocs.io/$REPO@$version"
28+
comment="### godoc reference preview ready ✨<br>[![Go Documentation](https://godocs.io/github.com/acmcsufoss/api.acmcsuf.com?status.svg)]($link)"
29+
echo "comment=$comment" >> "$GITHUB_OUTPUT"
30+
env:
31+
REPO: github.com/${{ github.event.pull_request.base.repo.full_name }}
32+
REV: ${{ github.event.pull_request.head.sha }}
33+
34+
- name: Update existing issue comment
35+
uses: peter-evans/find-comment@v1
36+
id: fc
37+
with:
38+
issue-number: ${{ github.event.pull_request.number }}
39+
comment-author: "github-actions[bot]"
40+
body-includes: "### godoc reference preview ready ✨"
41+
edit-mode: replace
42+
43+
- name: Update comment
44+
if: steps.fc.outputs.comment-id != ''
45+
uses: peter-evans/create-or-update-comment@v1
46+
with:
47+
comment-id: ${{ steps.fc.outputs.comment-id }}
48+
body: ${{ steps.generate_comment.outputs.comment }}
49+
edit-mode: replace

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ result/
3131

3232
# Build artifact generated by Makefile
3333
.generate.marker
34+
35+
tmp/

.vscode/settings.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
{
2-
"editor.formatOnSave": true,
3-
"editor.defaultFormatter": "esbenp.prettier-vscode",
4-
"[go]": {
5-
"editor.defaultFormatter": "golang.go"
6-
},
7-
"[sql]": {
8-
"editor.defaultFormatter": "inferrinizzard.prettier-sql-vscode"
9-
}
10-
}
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.defaultFormatter": "esbenp.prettier-vscode",
4+
"[go]": {
5+
"editor.defaultFormatter": "golang.go"
6+
},
7+
"[sql]": {
8+
"editor.defaultFormatter": "inferrinizzard.prettier-sql-vscode"
9+
}
10+
}

LICENSE

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2-
Version 2, December 2004
3-
4-
Copyright (C) 2004 Sam Hocevar <[email protected]>
5-
6-
Everyone is permitted to copy and distribute verbatim or modified
7-
copies of this license document, and changing it is allowed as long
8-
as the name is changed.
9-
10-
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11-
12-
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
13-
14-
0. You just DO WHAT THE FUCK YOU WANT TO.
1+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2+
Version 2, December 2004
3+
4+
Copyright (C) 2004 Sam Hocevar <[email protected]>
5+
6+
Everyone is permitted to copy and distribute verbatim or modified
7+
copies of this license document, and changing it is allowed as long
8+
as the name is changed.
9+
10+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11+
12+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
13+
14+
0. You just DO WHAT THE FUCK YOU WANT TO.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ generate: fmt $(GENERATE_MARKER)
2020
vet: fmt
2121
go vet ./...
2222

23-
run: generate
24-
go run ./cmd/api
23+
run: build
24+
./$(BIN_DIR)/$(APP_NAME)
2525

2626
build: generate
2727
mkdir -p $(BIN_DIR)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ make # Compile program
2020
```
2121
OR
2222
```sh
23-
make run # This compiles & runs the program without creating a binary
23+
make run
2424
```
2525

2626
### Other useful commands from the Makefile

cmd/api/main.go

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"context"
5-
"database/sql"
65
"fmt"
76
"log"
87
"os"
@@ -11,6 +10,7 @@ import (
1110

1211
"github.com/acmcsufoss/api.acmcsuf.com/internal/api/routes"
1312
"github.com/acmcsufoss/api.acmcsuf.com/internal/api/services"
13+
"github.com/acmcsufoss/api.acmcsuf.com/internal/db"
1414
"github.com/acmcsufoss/api.acmcsuf.com/internal/db/models"
1515
"github.com/gin-gonic/gin"
1616
_ "modernc.org/sqlite"
@@ -28,38 +28,22 @@ func main() {
2828
cancel()
2929
}()
3030

31-
// Setup SQLite database & make sure we can connect to it
32-
uri := os.Getenv("DATABASE_URL")
33-
if uri == "" {
34-
log.Fatal("DATABASE_URL must be set")
35-
}
36-
db, err := sql.Open("sqlite", uri)
31+
db, err := db.New(ctx)
3732
if err != nil {
38-
log.Fatalf("Error opening SQLite database: %vl", err)
33+
log.Fatal(err)
3934
}
4035
defer db.Close()
41-
if err := db.PingContext(ctx); err != nil {
42-
log.Fatalf("Error connecting to database: %v", err)
43-
}
44-
45-
schemaBytes, err := os.ReadFile("internal/db/sql/schemas/schema.sql")
46-
if err != nil {
47-
log.Fatalf("Error reading schema file: %v", err)
48-
}
49-
50-
if _, err := db.ExecContext(ctx, string(schemaBytes)); err != nil {
51-
log.Fatalf("Error initializing db schema: %v", err)
52-
}
5336

5437
// Now we init services & gin router, and then start the server
5538
// Should this be moved to the routes module??
5639
queries := models.New(db)
5740
eventsService := services.NewEventsService(queries)
41+
announcementService := services.NewAnnouncementService(queries)
5842
router := gin.Default()
5943
router.SetTrustedProxies([]string{
6044
"127.0.0.1/32",
6145
})
62-
routes.SetupRoutes(router, eventsService)
46+
routes.SetupRoutes(router, eventsService, announcementService)
6347
port := os.Getenv("PORT")
6448
if port == "" {
6549
port = "8080"

flake.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description = "Go Dev Environment for api.acmcsuf.com";
33

44
inputs = {
5-
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
66
flake-utils.url = "github:numtide/flake-utils";
77
};
88

0 commit comments

Comments
 (0)