From 8cc6f23b04db129b7db03a4d9e5e1390b3201704 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sat, 26 Oct 2024 12:25:51 +0200 Subject: [PATCH] Add Tiltfile for local development Signed-off-by: Knut Ahlers --- README.md | 11 +++++++++++ Tiltfile | 46 ++++++++++++++++++++++++++++++++++++++++++++++ api.go | 1 + 3 files changed, 58 insertions(+) create mode 100644 Tiltfile diff --git a/README.md b/README.md index 7c4eee4..d97c9a0 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,17 @@ You will now need to supply the web application with the password in addition to In this case due to how browsers are handling hashes in URLs (the part after the `#`) the only URL the server gets to know is `https://ots.fyi/` which loads the frontend. Afterwards the Javascript executed in the browser fetches the encrypted secret at the given ID and decrypts it with the given password (in this case `mypass`). I will not be able to tell the content of your secret and just see the AES 256bit encrypted content. +## Local development + +This repo contains a `Tilefile` to be used with [tilt v0.33+](https://tilt.dev/) to build and start the server for development. + +Requirements: +- Go v1.23+ +- Node v22+ +- Tilt v0.33+ + +Just run `tilt up` and visit `http://localhost:15641/` for the development server. + ## Localize to your own language If you want to help translating the application to your own language please see the [`i18n.yaml`](https://github.com/Luzifer/ots/blob/master/i18n.yaml) file from this repository and translate the English strings inside. Afterwards please [open an issue](https://github.com/Luzifer/ots/issues/new) and attach your translation including the information which language you translated the strings into. diff --git a/Tiltfile b/Tiltfile new file mode 100644 index 0000000..766ebe9 --- /dev/null +++ b/Tiltfile @@ -0,0 +1,46 @@ +# Install Node deps on change of package.json +local_resource( + 'npm', + cmd='npm i', + deps=['package.json'], +) + +# Rebuild frontend if source files change +local_resource( + 'frontend', + cmd='node ./ci/build.mjs', + deps=['src'], + resource_deps=['npm'], +) + +# Generate translation files on source change +local_resource( + 'translations', + cmd='make translate', + deps=['i18n.yaml'], +) + +# Rebuild and run Go webserver on code changes +local_resource( + 'server', + cmd='go build .', + deps=[ + 'api.go', + 'frontend', + 'helpers.go', + 'main.go', + 'pkg', + 'storage.go', + 'tplFuncs.go', + ], + ignore=['ots', 'src'], + serve_cmd='./ots --listen=:15641', + serve_env={ + 'CUSTOMIZE': 'customize.yaml', + }, + readiness_probe=probe( + http_get=http_get_action(15641, path='/api/healthz'), + initial_delay_secs=1, + ), + resource_deps=['frontend', 'translations'], +) diff --git a/api.go b/api.go index 6911bb2..0a17feb 100644 --- a/api.go +++ b/api.go @@ -52,6 +52,7 @@ func (a apiServer) Register(r *mux.Router) { r.HandleFunc("/get/{id}", a.handleRead) r.HandleFunc("/isWritable", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusNoContent) }) r.HandleFunc("/settings", a.handleSettings).Methods(http.MethodGet) + r.HandleFunc("/healthz", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) }) } func (a apiServer) handleCreate(res http.ResponseWriter, r *http.Request) {