1
0
mirror of https://github.com/Luzifer/ots.git synced 2024-12-23 22:29:35 -05:00

Add Tiltfile for local development

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2024-10-26 12:25:51 +02:00
parent 51313d02aa
commit 8cc6f23b04
No known key found for this signature in database
3 changed files with 58 additions and 0 deletions

View File

@ -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. 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 ## 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. 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.

46
Tiltfile Normal file
View File

@ -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'],
)

1
api.go
View File

@ -52,6 +52,7 @@ func (a apiServer) Register(r *mux.Router) {
r.HandleFunc("/get/{id}", a.handleRead) r.HandleFunc("/get/{id}", a.handleRead)
r.HandleFunc("/isWritable", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusNoContent) }) r.HandleFunc("/isWritable", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusNoContent) })
r.HandleFunc("/settings", a.handleSettings).Methods(http.MethodGet) 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) { func (a apiServer) handleCreate(res http.ResponseWriter, r *http.Request) {