diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 143 |
1 files changed, 40 insertions, 103 deletions
diff --git a/README.md b/README.md index 8724a7e..2577c00 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,17 @@ This directory provides a Guile web service incl. the new REST API. It is used in conjunction with the Python web services and (very much) WIP. +## Run + +1. **Navigate to the Web Directory and Start the Server** + +Running the web server is documented in [guix script](./web/.guix-shell). + +``` +curl http://127.0.0.1:8091/version +"4.0.0" +``` + # Documentation Start with this file and then the documentation in [doc](./doc/gn-guile.md). @@ -14,139 +25,65 @@ The current repository lives at git clone tux02.genenetwork.org:/home/git/public/gn-guile ``` -GNU Guile allows you to develop against a live running web server using emacs-geiser. To try this fire up the web server from the `web` directory as +or -```sh -cd web -unset GUIX_PROFILE -. .guix-shell -- guile -L .. --listen=1970 -e main ./webserver.scm 8091 +``` +git remote add gn git.genenetwork.org:/home/git/public/gn-guile ``` -Note the leading dot. The .guix-shell is defined in `gn-guile/web` and loads required packages using GNU Guix. -If you are on Debian you may need to unset GUIX_PROFILE first. - -Next fire up emacs with `emacs-geiser-guile` and connect to the running web server with `M-x geiser-connect` and the port `1970`. Now you can not only inspect procedures, but also update any prodedure on the live server using `C-M-x` and get updated output from the webserver! - -# Tools - -Some tooling and scripts that run independently are stored in `./scripts`. - -Here’s the entire markdown content combined into a single, copyable file: - - -# Gn-Markdown - -Gn-Markdown is an API endpoint to edit, parse, and commit markdown files for gn-docs. - -## How to Test the APIs - -1. **Navigate to the Web Directory and Start the Server** +GNU Guile allows you to develop against a live running web server using emacs-geiser on port 1970. To try this fire up the web server from the `web` directory as ```sh -cd web -export REPO_PATH=<repo_path> -. .guix-shell -- guile -L .. --listen=1970 -e main ./webserver.scm 8091 +guix shell -L ~/guix-bioinformatics --container --network --development --file=guix.scm -- guile -L . --fresh-auto-compile --listen=1970 -e main bin/gn-guile 8091 ``` -2. **Test Endpoints** - -The main endpoints provided are `/edit` and `/commit`. More endpoints may be added in the future. +By default the root points to the API: -## Edit (GET) +curl http://127.0.0.1:8091 -This is a GET request to retrieve a file's details. Make sure you pass a valid file_path as search_query (the path should be relative to the repo) +We also have some services -**Request Example:** +curl http://127.0.0.1:8091/home/msk +curl http://127.0.0.1:8091/home/aging -```bash +The `--container` option runs the code in an isolated container, and the `--network` option connects that container's networking to the host to allow you to access the running service. -curl -G -d "file_path=test.md" localhost:8091/edit +If you get an error `no code for module (gn packages guile)` add the appropriate guix-bioinformatics repo to the load path (`-L` switch). Note that, instead of hard-wiring guix-bioinformatics, the recommended way is to use a guix channel as defined in [guix-channel](./.guix-channel). -``` +We recommend checking the Guix documentation for manifests, channels and guix.scm definitions. -**Expected Success Response:** +To run a standalone server you should run without the listener on port 1970: -```json -{ -"file_path": "test.md", -"content": "Test for new user\n test 2 for line\n test 3 for new line\n ## real markdown two test\n", -"hash": "ecd96f27c45301279150fbda411544687db1aa45" -} ``` - -**Expected Error Response (Status 400):** - -```json -{ -"error": <error_type>, -"msg": <error_reason> -} +guix shell -L ~/guix-bioinformatics --container --network --file=guix.scm -- guile -L . --fresh-auto-compile -e main bin/gn-guile 8091 ``` -## Commit (POST) +## Welcome to the world of interactive Lisp programming -This is a POST request to commit changes to a file. +Next fire up emacs with `emacs-geiser-guile` and connect to the running web server with `M-x geiser-connect` and the port `1970`. Now you can not only inspect procedures, but also update any prodedure on the live server using `C-M-x` on code, call and get updated output from the webserver! No need to save/reload files and all that. -**Request URL:** +Note that you may have to try different versions of guile+emacs to succeed. -```bash +Also these days it may be a better bet to use Andrew Tropin's alternatives ares and arei that are very powerful alternatives to geiser (with a more common lisp type interactive experience): -curl -X POST http://127.0.0.1:8091/commit \ --H 'Content-Type: application/json' \ --d '{ -"content": "make test commit", -"filename": "test.md", -"email": "test@gmail.com", -"username": "test", -"commit_message": "init commit", -"prev_commit": "7cbfc40d98b49a64e98e7cd562f373053d0325bd" -}' +=> https://git.sr.ht/~abcdw/guile-ares-rs +=> https://git.sr.ht/~abcdw/emacs-arei -``` +# Tools +Some tooling and scripts that run independently are stored in `./scripts`. -**Expected Response for success:** - -```json -{ -"status": "201", -"message": "Committed file successfully", -"content": "Test for new user\n test 2 for line\n test 3 for new line\n ## real markdown two test\n", -"commit_sha": "47df3b7f13a935d50cc8b40e98ca9e513cba104c", -"commit_message": "commit by genetics" -} - -``` - -**If No Changes to File:** - -```json -{ -"status": "200", -"message": "Nothing to commit, working tree clean", -"commit_sha": "ecd96f27c45301279150fbda411544687db1aa45" -} -``` - -**Expected Error Response:** - -```json -{ -"error": "system-error", -"msg": "Commits do not match. Please pull in the latest changes for the current commit *ecd96f27c45301279150fbda411544687db1aa45* and previous commits." -} -``` +# Forwarding a MySQL port -## Notes +You may want to forward a mysql port if there is no DB locally you can do something like: -This is meant to be used as api endpoint only to edit any local repo; Clients are expected to handle other service e.g User Interface, authentication +ssh -L 3306:127.0.0.1:3306 -f -N tux02.genenetwork.org -# Development +# Topics -``` -git remote add gn git.genenetwork.org:/home/git/public/gn-guile -``` +* More on [gn-guile](./doc/gn-guile.md) +* Markdown editor with git backend see [markdown](./doc/git-markdown-editor.md). # LICENSE |
