You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* clone ui over, remove its git history
* Make nvmrc in granary-ui a symlink
* Install elm and elm format in scripts/update
* Add frontend building to scripts/update
* Serve model dashboard from Granary server
* serve from granary server
* spelling
* build frontend in ci _better_
* update readmes
* Add missing dependency
* map root to index
* make sure elm-stuff dir exists before first container compile
Copy file name to clipboardexpand all lines: README.md
+77-7
Original file line number
Diff line number
Diff line change
@@ -8,15 +8,18 @@ An API project that uses http4s and doobie
8
8
9
9
## Quick Setup
10
10
```
11
+
nvm use
12
+
./scripts/setup
11
13
./scripts/update
12
14
```
13
15
14
-
Then `ssh` into the machine when that is complete and start the server with `./scripts/server`. In another shell inside the VM you should be able to make a request:
15
-
16
-
`http :8080/api/hello/world`
16
+
Then start the server with `[AWS_PROFILE=<profile>] [AWS_REGION=<region>] ./scripts/server`.
17
+
You should then be able to hit `localhost:8080/index.html` in a browser.
17
18
18
19
## Developing
19
20
21
+
### API development
22
+
20
23
It's easier to test changes with the API with [HTTPie](https://httpie.org/) and the
21
24
[HTTPie JWT Auth plugin](https://github.com/teracyhq/httpie-jwt-auth) in order to make
22
25
authentication with APIs as seamless as possible. All following commands assume
@@ -25,23 +28,90 @@ you have those available.
25
28
To add a token for use with HTTPie, use `./scripts/dbshell` to insert a token like this:
26
29
`insert into tokens (id) values (uuid_generate_v4());`
27
30
28
-
### Nexus Repository Manager
31
+
####Nexus Repository Manager
29
32
30
33
When developing at the Azavea office, strongly consider use of the Nexus proxy. This is automatically configured in project setup. If you are not connected to the `vpn` you will need to disable it by deleting or moving `.sbtopts`.
31
34
32
-
### Project Organization
35
+
####Project Organization
33
36
34
37
By default the backend is organized into 3 subprojects:
35
38
- api: handles all routes, authentication, and services
36
39
- datamodel: case classes for data the api operates on
37
40
- database: handles database interaction with models
38
41
39
-
### Migrations
42
+
####Migrations
40
43
This project uses [flyway](https://flywaydb.org/) for migrations. The migrations are stored in the database subproject (`database/src/main/resources/db/migrations`). For information on the naming and formatting conventions consult the [documentation](https://flywaydb.org/documentation/migrations#naming). Each migration should be `sql` and generally follows the format of `V<number>__<description>.aql`.
41
44
42
45
Running migrations and other tasks are managed through `./scripts/migrate`.
43
46
44
-
### Development workflow
47
+
####Development workflow
45
48
Usually at least two terminals should be open for doing development. The first terminal is where `sbt` should be run (`./scripts/console sbt`). In this terminal tests can be run, projects compiled, and the server assembled.
46
49
47
50
The other terminal is where the server should be run `./scripts/server` or other one-off commands. To see changes you made to the API live you will need to first `assemble` the `jar` for the `api` server.
51
+
52
+
### UI Development
53
+
54
+
You can find files for the user interface under [`granary-ui/`](./granary-ui). To get set up with Elm, you'll
55
+
want to make sure a few things are on your path. If you followed the [Quick Setup](#quick-setup) instructions, you have these already.
Currently, the entire UI application lives in a single file. The reason for that is the note under
61
+
[Culture Shock](https://guide.elm-lang.org/webapps/structure.html) in the Elm guide, specifically:
62
+
63
+
> In JavaScript, the longer your file is, the more likely you have some sneaky mutation that will cause a really difficult bug. But in Elm, that is not possible! Your file can be 2000 lines long and that still cannot happen.
64
+
65
+
That may change as we separate pages.
66
+
67
+
#### First steps in this app
68
+
69
+
Like any of our recent frontend applications, start with `nvm use`. Whenever you make changes that you'd
70
+
like to see served, run `./scripts/update --frontend`. This will:
71
+
72
+
- recompile the application if that somehow hasn't already happened via your editor
73
+
- build the `index.html` page to serve
74
+
- copy everything in `granary-ui/public` into the magic directory under `api/src/main/resources/`.
75
+
76
+
Hot reloading is disabled because we're serving the application from Http4s instead of with Webpack,
77
+
but you don't have to restart the server when you make changes and compilation is _really_ fast, so
78
+
it's really not so bad.
79
+
80
+
#### Editor setup
81
+
82
+
There are a number of good editor integrations available for Elm. The one I'm
83
+
most used to is the [VSCode plugin](https://marketplace.visualstudio.com/items?itemName=Elmtooling.elm-ls-vscode), which
84
+
uses the Language Server Protocol and therefore feels very familiar to Scala/TypeScript development in VSCode.
85
+
86
+
If you don't want to use VSCode, there are a number of other plugins listed [here](https://github.com/elm/editor-plugins).
87
+
Anecdotally, the community seems really to like the IntelliJ plugin. I think @pcaisse has had some luck with the Vim plugin.
88
+
I've had some luck with the emacs plugin in my old Spacemacs days, but it's been a while so I have no idea what that's like
89
+
at this point.
90
+
91
+
You may end up in an annoying situation where the VSCode plugin and `nvm` stop getting along and VSCode can't find
92
+
your elm binaries. In that case, you can specify the path to `elm-format` and `elm` in the settings:
93
+
94
+
- press `Ctrl + ,`
95
+
- search `elm`
96
+
- use `which foo` to find the path that `nvm` knows about and fill it in in the appropriate box
97
+
98
+
#### Adding a dependency
99
+
100
+
Elm dependencies are fully managed. If you want to add one, use
101
+
`elm-install <maintainer>/<package-name>`. For example, to install the
102
+
`elm-ui-framework` pacakge, you'd enter:
103
+
104
+
```bash
105
+
$ elm install Orasund/elm-ui-framework
106
+
```
107
+
108
+
You'll then be prompted to confirm that Elm's plan is a good one, then you're
109
+
good to go.
110
+
111
+
#### Elm getting started
112
+
113
+
If you'd like a quick introduction to Elm, the [Architecture](https://guide.elm-lang.org/architecture/)
114
+
and [Types](https://guide.elm-lang.org/types/) sections of the guide should be
115
+
helpful. They'll at least help you get used to what the syntax looks like.
116
+
If you'd like to learn about the Elm runtime, the [Commands and Subscriptions](https://guide.elm-lang.org/effects/)
0 commit comments