- Go 54.1%
- CSS 23.6%
- templ 22.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| db | ||
| frontend | ||
| models | ||
| static | ||
| .gitignore | ||
| backup.go | ||
| go.mod | ||
| go.sum | ||
| handlers_admin.go | ||
| handlers_public.go | ||
| images.go | ||
| LICENSE | ||
| main.go | ||
| README.md | ||
| security.go | ||
| theme.go | ||
deepa-store
DeeKeeCrafts: Deepa Aunty's store for her products
Running
Set ADMIN_HASH to a bcrypt hash of the admin password (single-quote it, it contains $):
ADMIN_HASH='$2a$10$...' go run .
Settings, all environment variables:
| Variable | Default | |
|---|---|---|
ADMIN_HASH |
(required) | bcrypt hash of the admin password |
PORT |
3000 |
port to listen on |
DATA_DIR |
. |
holds store.db and uploads/ |
STATIC_DIR |
static |
the CSS, htmx, font and other static files |
SITE_URL |
unset | the site's public address, like https://example.com; needed for the link previews shown when someone shares a page |
INSECURE_COOKIES |
unset | 1 lets login and the light/dark choice work over plain HTTP, for testing from another device on the LAN only |
The server is meant to sit behind a reverse proxy (Caddy, nginx) that handles HTTPS. The port must only be reachable through that proxy: the login rate limit trusts the last X-Forwarded-For entry, which a client talking to the port directly could fake. The session cookie is Secure, so logging in only works over HTTPS (or on localhost) unless INSECURE_COOKIES=1.
Everything the pages load is served by the site itself: htmx 2.0.11 is static/htmx.min.js and the Playfair Display font (SIL Open Font License) is in static/fonts/. Nothing is fetched from other sites.
Pages follow the visitor's light or dark device setting until they use the toggle in the header, which saves their choice in a theme cookie.
Ctrl+C or SIGTERM lets requests in progress (such as uploads) finish for up to 30 seconds before exiting.
Images
Each upload is saved in DATA_DIR/uploads/ along with a smaller copy (at most 800 px, named .thumb800.jpg) that the pages show; clicking a photo opens the full-size original. At startup the server makes any missing thumbnails, deletes thumbnails of an older size, and moves other files no product refers to into DATA_DIR/orphaned-uploads/. Check that folder now and then and delete what isn't needed.
Backups
Logged in as admin, Download backup gives a zip of the database and every image. To restore, stop the server and unzip it into DATA_DIR.