Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
63433be0bb | |||
1a856e575e | |||
a3e4154fb6 | |||
4839b74bf7 | |||
dcf5a16c3f | |||
932d82c1fc | |||
db509ffa8a | |||
c4392601b1 | |||
ca421b313d | |||
71df7b4711 | |||
106a43aaf1 | |||
5077682fa5 | |||
634bff4411 | |||
bce4d598fb | |||
3fd1e1f4a3 | |||
de1baa4517 | |||
be309409ad | |||
b6ef0cab53 | |||
e8d9a4adff | |||
fc90905dcf | |||
6494d74ab2 | |||
ca313960c4 | |||
0cb262524c | |||
05aff14703 |
@ -1,14 +1,19 @@
|
||||
name: Lint Workflow
|
||||
name: Check
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
types: [opened, reopened, edited, auto_merge_enabled]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
check:
|
||||
name: check
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
contains(github.event.head_commit.message, 'bump:') == false &&
|
||||
contains(github.event.head_commit.message, 'Merge pull request') == false
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@ -22,7 +27,7 @@ jobs:
|
||||
uses: cachix/cachix-action@v16
|
||||
with:
|
||||
name: trevstack
|
||||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: Run checks
|
||||
run: nix flake check
|
||||
- name: Check
|
||||
run: nix flake check
|
100
.gitea/workflows/release.yaml
Normal file
100
.gitea/workflows/release.yaml
Normal file
@ -0,0 +1,100 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v31
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
|
||||
- name: Use Cachix
|
||||
uses: cachix/cachix-action@v16
|
||||
with:
|
||||
name: trevstack
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: Check
|
||||
run: nix flake check
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: check
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v31
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
install_options: --no-daemon
|
||||
|
||||
- name: Use Cachix
|
||||
uses: cachix/cachix-action@v16
|
||||
with:
|
||||
name: trevstack
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: Build
|
||||
run: >
|
||||
nix build
|
||||
.#trevstack-linux-amd64
|
||||
.#trevstack-linux-arm64
|
||||
.#trevstack-linux-arm
|
||||
.#trevstack-windows-amd64
|
||||
.#trevstack-darwin-amd64
|
||||
.#trevstack-darwin-arm64
|
||||
|
||||
- name: Release
|
||||
uses: akkuman/gitea-release-action@v1
|
||||
with:
|
||||
files: |-
|
||||
result*/bin/*
|
||||
|
||||
# https://docs.docker.com/build/ci/github-actions/manage-tags-labels/
|
||||
package:
|
||||
runs-on: ubuntu-latest
|
||||
needs: release # Wait for binary cache to propagate
|
||||
steps:
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
# list of Docker images to use as base name for tags
|
||||
images: |
|
||||
${{ github.repository }}
|
||||
ghcr.io/${{ github.repository }}
|
||||
# generate Docker tags based on the following events/attributes
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=semver,pattern={{version}}
|
||||
|
||||
- name: Login to Gitea Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ vars.URL }}
|
||||
username: ${{ vars.USERNAME }}
|
||||
password: ${{ secrets.PASSWORD }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
39
.gitea/workflows/update.yaml
Normal file
39
.gitea/workflows/update.yaml
Normal file
@ -0,0 +1,39 @@
|
||||
name: Update
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
update:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v31
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
|
||||
- name: Use Cachix
|
||||
uses: cachix/cachix-action@v16
|
||||
with:
|
||||
name: trevstack
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
# https://github.com/actions/checkout/issues/13
|
||||
- name: Set Git Config
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
- name: Update
|
||||
run: nix run .#update
|
||||
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
title: update
|
||||
body: automatic update
|
33
.github/workflows/check.yaml
vendored
Normal file
33
.github/workflows/check.yaml
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
name: Check
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
types: [opened, reopened, edited, auto_merge_enabled]
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: check
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
contains(github.event.head_commit.message, 'bump:') == false &&
|
||||
contains(github.event.head_commit.message, 'Merge pull request') == false
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v31
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
|
||||
- name: Use Cachix
|
||||
uses: cachix/cachix-action@v16
|
||||
with:
|
||||
name: trevstack
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: Check
|
||||
run: nix flake check
|
38
.github/workflows/release.yaml
vendored
38
.github/workflows/release.yaml
vendored
@ -1,16 +1,16 @@
|
||||
name: Release Workflow
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
- "*"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
@ -25,8 +25,29 @@ jobs:
|
||||
uses: cachix/cachix-action@v16
|
||||
with:
|
||||
name: trevstack
|
||||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: Check
|
||||
run: nix flake check
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: check
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v31
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
|
||||
- name: Use Cachix
|
||||
uses: cachix/cachix-action@v16
|
||||
with:
|
||||
name: trevstack
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: Build
|
||||
run: >
|
||||
nix build
|
||||
@ -37,12 +58,13 @@ jobs:
|
||||
.#trevstack-darwin-amd64
|
||||
.#trevstack-darwin-arm64
|
||||
|
||||
- name: Create Release
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
generate_release_notes: true
|
||||
files: |-
|
||||
result*/bin/*
|
||||
|
||||
|
||||
# https://docs.docker.com/build/ci/github-actions/manage-tags-labels/
|
||||
package:
|
||||
runs-on: ubuntu-latest
|
||||
@ -85,4 +107,4 @@ jobs:
|
||||
with:
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
19
.github/workflows/update.yaml
vendored
19
.github/workflows/update.yaml
vendored
@ -1,10 +1,14 @@
|
||||
name: Update Workflow
|
||||
name: Update
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
update:
|
||||
runs-on: ubuntu-latest
|
||||
@ -21,21 +25,24 @@ jobs:
|
||||
uses: cachix/cachix-action@v16
|
||||
with:
|
||||
name: trevstack
|
||||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
# https://github.com/actions/checkout/issues/13
|
||||
- name: Set Git Config
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
|
||||
- name: Update
|
||||
run: nix run .#update
|
||||
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
delete-branch: true
|
||||
title: Bump deps
|
||||
|
||||
title: update
|
||||
body: automatic update
|
||||
|
||||
- name: Enable Automerge
|
||||
run: gh pr merge --merge --auto "1"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.PAT }}
|
||||
|
@ -3,7 +3,23 @@
|
||||
git_root=$(git rev-parse --show-toplevel)
|
||||
git_version=$(git describe --tags --abbrev=0)
|
||||
version=${git_version#v}
|
||||
next_version=$(echo "${version}" | awk -F. -v OFS=. '{$NF += 1 ; print}')
|
||||
|
||||
major=$(echo "${version}" | cut -d . -f1)
|
||||
minor=$(echo "${version}" | cut -d . -f2)
|
||||
patch=$(echo "${version}" | cut -d . -f3)
|
||||
case "${1-patch}" in
|
||||
major) major=$((major + 1)) ;;
|
||||
minor) minor=$((minor + 1)) ;;
|
||||
*) patch=$((patch + 1)) ;;
|
||||
esac
|
||||
next_version="${major}.${minor}.${patch}"
|
||||
|
||||
echo "${version} -> ${next_version}"
|
||||
|
||||
echo "bumping openapi"
|
||||
cd "${git_root}"
|
||||
sed -i -e "s/${version}/${next_version}/g" openapi.yaml
|
||||
git add openapi.yaml
|
||||
|
||||
echo "bumping client"
|
||||
cd "${git_root}/client"
|
||||
|
@ -11,6 +11,13 @@ if ! git diff --exit-code flake.lock; then
|
||||
git commit -m "build(nix): updated nix dependencies"
|
||||
fi
|
||||
|
||||
echo "updating protobuf deps"
|
||||
buf dep update
|
||||
if ! git diff --exit-code buf.lock; then
|
||||
git add buf.lock
|
||||
git commit -m "build(buf): updated buf dependencies"
|
||||
fi
|
||||
|
||||
echo "updating client"
|
||||
cd "${git_root}/client"
|
||||
npm update --save && npm i
|
||||
|
1
.vscode/extensions.json
vendored
1
.vscode/extensions.json
vendored
@ -2,6 +2,7 @@
|
||||
"recommendations": [
|
||||
"golang.go",
|
||||
"dorzey.vscode-sqlfluff",
|
||||
"zxh404.vscode-proto3",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"svelte.svelte-vscode",
|
||||
"esbenp.prettier-vscode"
|
||||
|
9
.vscode/settings.json
vendored
9
.vscode/settings.json
vendored
@ -4,6 +4,7 @@
|
||||
// Go
|
||||
"go.lintTool": "revive",
|
||||
"go.formatTool": "goimports",
|
||||
"go.buildTags": "dev",
|
||||
"go.lintFlags": ["--config=server/revive.toml"],
|
||||
"gopls": { "ui.semanticTokens": true },
|
||||
"[go]": {
|
||||
@ -12,6 +13,14 @@
|
||||
|
||||
// SQLFluff
|
||||
"sqlfluff.config": "server/db/.sqlfluff",
|
||||
"[sql]": {
|
||||
"editor.defaultFormatter": "dorzey.vscode-sqlfluff"
|
||||
},
|
||||
|
||||
// Proto
|
||||
"[proto3]": {
|
||||
"editor.defaultFormatter": "zxh404.vscode-proto3"
|
||||
},
|
||||
|
||||
// ESLint
|
||||
"eslint.workingDirectories": ["./client"],
|
||||
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Trev
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
83
README.md
Normal file
83
README.md
Normal file
@ -0,0 +1,83 @@
|
||||
## TrevStack
|
||||
|
||||
This is a CRUD app to use as a template for starting projects
|
||||
|
||||
### Features
|
||||
|
||||
- **Communicate anywhere**. Define a [protocol buffer](https://protobuf.dev/), and [Connect](https://connectrpc.com/) generates type-safe code to facilitate communication between the server and any client (web, mobile, embedded, etc). The protocol buffers can contain annotations to validate fields on the client and server. For clients that cannot use Connect, an OpenAPI spec is also generated
|
||||
- **Build anywhere**. The dev environment, testing and building is all declared in a single [Nix](https://nixos.org/) flake. Every developer and server can use the same environment
|
||||
- **Deploy anywhere**. CI/CD is already set up using github actions. New versions are automatically released for every major platform, along with a docker image. The binaries created require zero run-time dependencies and are relatively small (this app is 26 MiB)
|
||||
- Authentication is rolled in, including API key, fingerprint & passkey
|
||||
- Automatic database migration on startup
|
||||
- Light & dark modes with the [catppuccin](https://catppuccin.com/palette/) color palette
|
||||
- Really good at running as a [progressive web app](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps)
|
||||
|
||||
While I personally prefer using a Svelte frontend and Go backend, feel free to swap them out with whatever you like, you'll be surprised how easy it is.
|
||||
|
||||
## Getting Started
|
||||
|
||||
1. [Install Nix](https://nixos.org/download/)
|
||||
2. Run `nix develop`
|
||||
3. Create a `server/.env` file that looks something like
|
||||
|
||||
```env
|
||||
KEY=changeme
|
||||
PORT=8080
|
||||
URL=http://localhost:5173
|
||||
DATABASE_URL=sqlite:/home/trev/.config/trevstack/sqlite.db
|
||||
```
|
||||
|
||||
4. Run `treli`
|
||||
|
||||
It's that simple. If you're feeling fancy, install [direnv](https://direnv.net/) and the dev environment will load automatically.
|
||||
|
||||
### Useful Commands
|
||||
|
||||
- `nix run #update`: updates all of the dependencies
|
||||
|
||||
- `nix run #bump [major | minor]`: bumps the current version up one. Defaults to "patch" (0.0.1 -> 0.0.2)
|
||||
|
||||
- `buf lint` & `buf generate`: Lints and generates code from protocol buffers
|
||||
|
||||
- `sqlc vet` & `sqlc generate`: Verifies and generates code from SQL files
|
||||
|
||||
- `dbmate new` & `dbmate up`: Creates a new migration file and runs pending migrations
|
||||
|
||||
## Components
|
||||
|
||||
### Client
|
||||
|
||||
- **svelte 5** [[docs](https://svelte.dev/docs/svelte)] UI framework
|
||||
- **tailwind 4** [[docs](https://tailwindcss.com/)] CSS framework
|
||||
- **bits ui** [[docs](https://bits-ui.com/docs/)] headless components
|
||||
- [components](https://github.com/spotdemo4/trevstack/tree/main/client/src/lib/ui) from **shadcn-svelte** [[docs](https://www.shadcn-svelte.com/docs)] altered to work with tailwind 4, fit the [catppuccin](https://catppuccin.com/palette/) color palette, and use [shallow routing](https://svelte.dev/docs/kit/shallow-routing)
|
||||
- **connect rpc** [[docs](https://connectrpc.com/docs/web/)] to communicating with the server
|
||||
- **protovalidate-es** [[docs](https://github.com/bufbuild/protovalidate-es)], along with a function [coolforms](https://github.com/spotdemo4/trevstack/blob/main/client/src/lib/coolforms/) to emulate the library [sveltekit-superforms](https://superforms.rocks/)
|
||||
- **simplewebauthn** [[docs](https://simplewebauthn.dev/docs/packages/browser)] for passkey authentication
|
||||
- **scalar** [[docs](https://github.com/scalar/scalar)] for displaying openapi specs
|
||||
- **tw-animate-css** [[docs](https://github.com/Wombosvideo/tw-animate-css)] to animate with just tailwind classes
|
||||
- vite [[docs](https://vite.dev/)] for dev server and bundling
|
||||
- eslint [[docs](https://eslint.org/)] for linting
|
||||
- prettier [[docs](https://prettier.io/)] for formatting
|
||||
- prettier-plugin-svelte [[docs](https://github.com/sveltejs/prettier-plugin-svelte)]
|
||||
- prettier-plugin-tailwindcss [[docs](https://github.com/tailwindlabs/prettier-plugin-tailwindcss)]
|
||||
- prettier-plugin-sort-imports [[docs](https://github.com/IanVS/prettier-plugin-sort-imports)]
|
||||
|
||||
### Server
|
||||
|
||||
- **go** [[docs](https://go.dev/doc/)]
|
||||
- **connect rpc** [[docs](https://connectrpc.com/docs/go/)] to serve gRPC & HTTP requests
|
||||
- **protovalidate-go** [[docs](https://github.com/bufbuild/protovalidate-go)] for validating those requests
|
||||
- **sqlc** [[docs](https://docs.sqlc.dev/en/latest/)] because writing the SQL yourself is better than an ORM
|
||||
- **go-webauthn** [[docs](https://github.com/go-webauthn/webauthn)] because webauthn is hard
|
||||
- **dbmate** [[docs](https://github.com/amacneil/dbmate)] for database migrations
|
||||
- revive [[docs](https://github.com/mgechev/revive)] for linting
|
||||
|
||||
### Protocol Buffers / gRPC
|
||||
|
||||
- **buf** [[docs](https://buf.build/docs/)] CLI for linting & code generation
|
||||
- **protovalidate** [[docs](https://buf.build/docs/protovalidate/)] provides annotations to validate proto messages & fields
|
||||
- **protoc-gen-connect-openapi** [[docs](https://github.com/sudorandom/protoc-gen-connect-openapi)] generates openapi specs
|
||||
- protoc-gen-go [[docs](https://pkg.go.dev/google.golang.org/protobuf)]
|
||||
- protoc-gen-connect-go [[docs](https://connectrpc.com/docs/go)]
|
||||
- protoc-gen-es [[docs](https://connectrpc.com/docs/web/)]
|
@ -27,5 +27,5 @@ plugins:
|
||||
out: client/static/openapi
|
||||
strategy: all
|
||||
opt:
|
||||
- base=openapi.base.yaml
|
||||
- base=openapi.yaml
|
||||
- path=openapi.yaml
|
||||
|
11
client/package-lock.json
generated
11
client/package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "trevstack",
|
||||
"version": "0.0.23",
|
||||
"version": "0.0.27",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "trevstack",
|
||||
"version": "0.0.23",
|
||||
"version": "0.0.27",
|
||||
"devDependencies": {
|
||||
"@bufbuild/protovalidate": "^0.1.1",
|
||||
"@connectrpc/connect": "^2.0.2",
|
||||
@ -26,7 +26,6 @@
|
||||
"eslint": "^9.26.0",
|
||||
"eslint-config-prettier": "^10.1.5",
|
||||
"eslint-plugin-svelte": "^3.6.0",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"globals": "^16.1.0",
|
||||
"mode-watcher": "^1.0.7",
|
||||
"prettier": "^3.5.3",
|
||||
@ -2754,9 +2753,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.17.46",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.46.tgz",
|
||||
"integrity": "sha512-0PQHLhZPWOxGW4auogW0eOQAuNIlCYvibIpG67ja0TOJ6/sehu+1en7sfceUn+QQtx4Rk3GxbLNwPh0Cav7TWw==",
|
||||
"version": "20.17.47",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.47.tgz",
|
||||
"integrity": "sha512-3dLX0Upo1v7RvUimvxLeXqwrfyKxUINk0EAM83swP2mlSUcwV73sZy8XhNz8bcZ3VbsfQyC/y6jRdL5tgCNpDQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "trevstack",
|
||||
"private": true,
|
||||
"version": "0.0.23",
|
||||
"version": "0.0.27",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
@ -32,7 +32,6 @@
|
||||
"eslint": "^9.26.0",
|
||||
"eslint-config-prettier": "^10.1.5",
|
||||
"eslint-plugin-svelte": "^3.6.0",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"globals": "^16.1.0",
|
||||
"mode-watcher": "^1.0.7",
|
||||
"prettier": "^3.5.3",
|
||||
|
36
flake.nix
36
flake.nix
@ -21,7 +21,7 @@
|
||||
...
|
||||
}: let
|
||||
pname = "trevstack";
|
||||
version = "0.0.23";
|
||||
version = "0.0.27";
|
||||
|
||||
build-systems = [
|
||||
"x86_64-linux"
|
||||
@ -29,6 +29,17 @@
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
forSystem = f:
|
||||
nixpkgs.lib.genAttrs build-systems (
|
||||
system:
|
||||
f {
|
||||
inherit system;
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
host-systems = [
|
||||
{
|
||||
GOOS = "linux";
|
||||
@ -55,16 +66,6 @@
|
||||
GOARCH = "arm64";
|
||||
}
|
||||
];
|
||||
forSystem = f:
|
||||
nixpkgs.lib.genAttrs build-systems (
|
||||
system:
|
||||
f {
|
||||
inherit system;
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
}
|
||||
);
|
||||
in {
|
||||
devShells = forSystem ({pkgs, ...}: let
|
||||
protoc-gen-connect-openapi = pkgs.buildGoModule {
|
||||
@ -80,9 +81,9 @@
|
||||
in {
|
||||
default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
treli.packages."${system}".default
|
||||
git
|
||||
nix-update
|
||||
treli.packages."${system}".default
|
||||
|
||||
# Server
|
||||
go
|
||||
@ -91,7 +92,7 @@
|
||||
revive
|
||||
sqlc
|
||||
|
||||
# database
|
||||
# Database
|
||||
sqlite
|
||||
dbmate
|
||||
sqlfluff
|
||||
@ -126,7 +127,7 @@
|
||||
pname = "check-client";
|
||||
inherit version;
|
||||
src = ./client;
|
||||
npmDepsHash = "sha256-Te5HGbp7mKG3p1P4O266IpoPPBN7oQ/dZbttdgKbgWs=";
|
||||
npmDepsHash = "sha256-yZEE/3oSJGW2l1y/WZIQ5FklNlGqt7VzUOLUtLuHu8Y=";
|
||||
dontNpmInstall = true;
|
||||
|
||||
buildPhase = ''
|
||||
@ -159,9 +160,10 @@
|
||||
runtimeInputs = with pkgs; [
|
||||
git
|
||||
nix
|
||||
nodejs_22
|
||||
go
|
||||
nix-update
|
||||
go
|
||||
buf
|
||||
nodejs_22
|
||||
];
|
||||
text = builtins.readFile ./.scripts/update.sh;
|
||||
});
|
||||
@ -188,7 +190,7 @@
|
||||
client = pkgs.buildNpmPackage {
|
||||
inherit pname version;
|
||||
src = ./client;
|
||||
npmDepsHash = "sha256-Te5HGbp7mKG3p1P4O266IpoPPBN7oQ/dZbttdgKbgWs=";
|
||||
npmDepsHash = "sha256-yZEE/3oSJGW2l1y/WZIQ5FklNlGqt7VzUOLUtLuHu8Y=";
|
||||
|
||||
installPhase = ''
|
||||
cp -r build "$out"
|
||||
|
@ -3,8 +3,8 @@ servers:
|
||||
- url: /grpc
|
||||
info:
|
||||
title: Trevstack API
|
||||
version: 1.0.0
|
||||
description: API for trevstack
|
||||
version: 0.0.27
|
||||
description: API for Trevstack
|
||||
contact:
|
||||
name: Trev
|
||||
email: spam@trev.xyz
|
||||
@ -15,4 +15,4 @@ components:
|
||||
scheme: bearer
|
||||
bearerFormat: JWT
|
||||
security:
|
||||
- bearerAuth: []
|
||||
- bearerAuth: []
|
@ -1,16 +0,0 @@
|
||||
wipe: true
|
||||
|
||||
replacements:
|
||||
- match:
|
||||
db_type: "INTEGER"
|
||||
replace: "int64"
|
||||
|
||||
- match:
|
||||
db_type: "INTEGER"
|
||||
nullable: true
|
||||
replace: "int64"
|
||||
|
||||
sql:
|
||||
dialect: sqlite
|
||||
dir: db
|
||||
output: internal/models
|
@ -29,6 +29,8 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
name := "TrevStack"
|
||||
|
||||
// Get env
|
||||
env, err := getEnv()
|
||||
if err != nil {
|
||||
@ -49,7 +51,7 @@ func main() {
|
||||
|
||||
// Create webauthn
|
||||
webAuthn, err := webauthn.New(&webauthn.Config{
|
||||
RPDisplayName: env.Name,
|
||||
RPDisplayName: name,
|
||||
RPID: env.URL.Hostname(),
|
||||
RPOrigins: []string{env.URL.String()},
|
||||
})
|
||||
@ -63,9 +65,9 @@ func main() {
|
||||
log.Fatalf("failed to create validator: %s", err.Error())
|
||||
}
|
||||
|
||||
// Serve GRPC Handlers
|
||||
// Serve gRPC Handlers
|
||||
api := http.NewServeMux()
|
||||
api.Handle(interceptors.WithCORS(user.NewAuthHandler(vi, sqlc, webAuthn, env.Name, env.Key)))
|
||||
api.Handle(interceptors.WithCORS(user.NewAuthHandler(vi, sqlc, webAuthn, name, env.Key)))
|
||||
api.Handle(interceptors.WithCORS(user.NewHandler(vi, sqlc, webAuthn, env.Key)))
|
||||
api.Handle(interceptors.WithCORS(item.NewHandler(vi, sqlc, env.Key)))
|
||||
|
||||
@ -108,7 +110,6 @@ func main() {
|
||||
type env struct {
|
||||
Port string
|
||||
Key string
|
||||
Name string
|
||||
URL *url.URL
|
||||
DatabaseURL string
|
||||
}
|
||||
@ -123,7 +124,6 @@ func getEnv() (*env, error) {
|
||||
env := env{
|
||||
Port: os.Getenv("PORT"),
|
||||
Key: os.Getenv("KEY"),
|
||||
Name: os.Getenv("NAME"),
|
||||
DatabaseURL: os.Getenv("DATABASE_URL"),
|
||||
}
|
||||
|
||||
@ -135,10 +135,6 @@ func getEnv() (*env, error) {
|
||||
if env.Key == "" {
|
||||
return nil, errors.New("env 'KEY' not found")
|
||||
}
|
||||
if env.Name == "" {
|
||||
env.Name = "trevstack"
|
||||
log.Printf("env 'NAME' not found, defaulting to %s\n", env.Name)
|
||||
}
|
||||
if env.DatabaseURL == "" {
|
||||
return nil, errors.New("env 'DATABASE_URL' not found")
|
||||
}
|
||||
|
Reference in New Issue
Block a user