From the somisana/web
directory, setup your environment:
# Install Node.js (v19.9.0)
# Install chomp
npm install -g chomp
# (this downloads a large binary in the background - run "chomp --version", which will output once the binary is downloaded)
# Install dependencies
npm install
To start the application run the default chomp task as defined in chompfile.toml:
chomp --watch
chomp
is a CLI tool that allows for defining task graphs. It's an improvement of using the scripts
field via npm
as defined in package.json
(the latter doesn't allow splitting strings onto multiple lines and/or defining serial/concurrent dependencies). The chomp --watch
command runs this series of tasks (the --watch
flag restarts the task chain on file changes):
- Transpile the client source code (
JSX
) to regular JavaScript. This is done viaRollup
/SWC
. Look at the rollup.config.js for more information - Link the transpiled source code to the HTML entry points using
JSPM
(look at thehtml
task in chompfile.toml) - Start the
Koa
app (Node.js)
Navigate to <repo root>/assets/
and follow the instructions on the README to load 3rd party assets into the database
Assuming you have a PostGIS server running as a docker container with the name postgis
on a network called postgis
:
docker run \
-dt \
--restart always \
--name pg_tileserv \
-p 7800:7800 \
--net postgis \
-e DATABASE_URL=postgres://admin:password@postgis:5432/somisana_local \
pramsey/pg_tileserv:latest
Assuming you have a PostGIS server running as a docker container with the name postgis
on a network called postgis
:
docker run \
-dt \
--restart always \
--name pg_featureserv \
-p 9000:9000 \
--net postgis \
-e DATABASE_URL=postgres://admin:password@postgis:5432/somisana_local \
-e PGFS_PAGING_LIMITDEFAULT=50000 \
-e PGFS_PAGING_LIMITMAX=50000 \
pramsey/pg_featureserv:latest
The build process will automatically configure routes from specific files in the client/
directory. To add a new HTML route:
- Add a new file -
client/html/your-new-route.html
- in the same style as the other HTML files inclient/html
. Note that the<script>
tag should havesrc="index.your-new-route.js"
. - Add a new folder
client/pages/your-new-route
with 2 files (index.js
andssr.js
). This folder should be of the same format of other folders inclient/pages/*
- Update
index.importmap.js
to include an import to.client/ssr.<your-new-route>.js
so that the imports defined in the client are available at SSR time - Update
ssr/_url-rewrite.ts
so that the regex expression also matches on the new new route (this may or may not be necessary)
The Rollup
build will look for the index.js
and ssr.js
files and process them so that the Node.js application can find them. Note that the ssr.js
file should not run code except via invoking functions (otherwise browser-specific APIs cause the SSR process to fail) and there should be a default export that is the entry point to the React code.
From the root of the repository:
cd web
source env.sh
# And then use the CLI ("s" is short for somisana)
s