Skip to content

Commit efe4539

Browse files
committed
cleanup
Signed-off-by: plutov <[email protected]>
1 parent 589178f commit efe4539

15 files changed

+31
-52
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This approach offers a number of advantages, including:
1414

1515
## Features
1616

17-
- [x] Management API
17+
- [x] API first
1818
- [x] Survey UI: for end users (respondents)
1919
- [x] Console UI: manage surveys
2020
- [x] YAML survey configuration
@@ -27,7 +27,6 @@ This approach offers a number of advantages, including:
2727
- [x] Different database options: SQLite and Postgres
2828
- [x] Continue where you left off
2929
- [x] Advanced validation rules
30-
- [x] Detect survey changes in real time
3130
- [x] Export responses in UI or via API
3231
- [ ] Advanced question types
3332
- [ ] Pipe answers into the following questions

api/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.23-alpine AS builder
1+
FROM golang:1.24-alpine AS builder
22

33
RUN apk add build-base
44

@@ -13,7 +13,7 @@ COPY ./cmd ./cmd
1313
COPY ./pkg ./pkg
1414
COPY ./migrations ./migrations
1515
COPY ./surveys ./surveys-examples
16-
RUN CGO_ENABLED=1 GOOS=linux go build -o api -tags enablecgo cmd/console-api/api.go
16+
RUN CGO_ENABLED=1 GOOS=linux go build -o api -tags enablecgo cmd/api/api.go
1717

1818
FROM alpine:latest
1919
RUN apk --no-cache add ca-certificates tzdata bash
File renamed without changes.

api/fly.toml

-15
This file was deleted.

api/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/plutov/formulosity/api
22

3-
go 1.23
3+
go 1.24
44

55
require (
66
github.com/fsnotify/fsnotify v1.7.0

api/migrations/postgres/000001_schema.down.sql

Whitespace-only changes.

api/migrations/postgres/000001_schema.up.sql

+9
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,12 @@ CREATE TABLE surveys_answers (
5353
);
5454

5555
CREATE UNIQUE INDEX surveys_answers_unique ON surveys_answers (session_id, question_id);
56+
57+
CREATE TABLE surveys_webhook_responses (
58+
id serial NOT NULL PRIMARY KEY,
59+
created_at timestamp without time zone default (now () at time zone 'utc'),
60+
session_id integer NOT NULL,
61+
response_status integer NOT NULL,
62+
response TEXT,
63+
CONSTRAINT fk_surveys_webhooks1 FOREIGN KEY (session_id) REFERENCES surveys_sessions (id) ON DELETE CASCADE
64+
);

api/migrations/postgres/000002_webhooks.down.sql

Whitespace-only changes.

api/migrations/postgres/000002_webhooks.up.sql

-9
This file was deleted.

api/migrations/sqlite/000001_schema.down.sql

Whitespace-only changes.

api/migrations/sqlite/000001_schema.up.sql

+9
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,12 @@ CREATE TABLE surveys_answers (
4343
);
4444

4545
CREATE UNIQUE INDEX surveys_answers_unique ON surveys_answers (session_id, question_id);
46+
47+
CREATE TABLE surveys_webhook_responses (
48+
id INTEGER PRIMARY KEY AUTOINCREMENT,
49+
created_at TEXT,
50+
session_id INTEGER NOT NULL,
51+
response_status INTEGER NOT NULL,
52+
response TEXT,
53+
FOREIGN KEY (session_id) REFERENCES surveys_sessions (id) ON DELETE CASCADE
54+
);

api/migrations/sqlite/000002_webhooks.down.sql

Whitespace-only changes.

api/migrations/sqlite/000002_webhooks.up.sql

-9
This file was deleted.

api/pkg/controllers/router.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ func NewRouter(h *Handler) *echo.Echo {
2121
e.GET("/app/surveys/:survey_uuid/sessions", h.surveyUUIDMiddleware(h.getSurveySessions))
2222
e.GET("/app/surveys/:survey_uuid/download/:file_name", h.surveyUUIDMiddleware(h.downloadFile))
2323

24-
surveysGroup := e.Group("/surveys")
25-
surveysGroup.GET("/:url_slug", h.getSurvey)
26-
surveysGroup.GET("/:url_slug/css", h.getSurveyCSS)
27-
surveysGroup.PUT("/:url_slug/sessions", h.createSurveySession)
28-
surveysGroup.GET("/:url_slug/sessions/:session_uuid", h.getSurveySessionHandler)
29-
surveysGroup.POST("/:url_slug/sessions/:session_uuid/questions/:question_uuid/answers", h.submitSurveyAnswer)
24+
surveys := e.Group("/surveys")
25+
surveys.GET("/:url_slug", h.getSurvey)
26+
surveys.GET("/:url_slug/css", h.getSurveyCSS)
27+
surveys.PUT("/:url_slug/sessions", h.createSurveySession)
28+
surveys.GET("/:url_slug/sessions/:session_uuid", h.getSurveySessionHandler)
29+
surveys.POST("/:url_slug/sessions/:session_uuid/questions/:question_uuid/answers", h.submitSurveyAnswer)
3030

3131
return e
3232
}

compose.yaml

+3-8
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ services:
88
depends_on:
99
- postgres
1010
environment:
11-
- DATABASE_TYPE=postgres # postgres|sqlite
12-
- DATABASE_URL=postgres://user:pass@postgres:5432/formulosity?sslmode=disable
13-
# - DATABASE_URL=/root/sqlite3/formulosity.db
11+
- DATABASE_TYPE=sqlite # postgres|sqlite
12+
# - DATABASE_URL=postgres://user:pass@postgres:5432/formulosity?sslmode=disable
13+
- DATABASE_URL=/root/sqlite3/formulosity.db
1414
- SURVEYS_DIR=/root/surveys
1515
- UPLOADS_DIR=/root/uploads
1616
volumes:
@@ -41,8 +41,3 @@ services:
4141
- "5432:5432"
4242
volumes:
4343
- ./api/postgres-data:/var/lib/postgresql/data
44-
logging:
45-
driver: none
46-
volumes:
47-
dbvolume:
48-
driver: local

0 commit comments

Comments
 (0)