This repo is responsible for two things:
- the server aka form backend which runs at https://form.laji.fi
- the client which is a React component for editing forms. Available as an npm package
laji-form-builder.
/?{lang:fi | en | sv = fi}UI for selecting/deleting a form/:id?{lang:fi | en | sv = fi}UI for editing a form
REST JSON API /api:
/api?{lang?: fi | en | sv}list forms as JSON/api/:id?{lang?: fi | en | sv, format: json | schema | schema-with-enums = json, expand: true | false = true}list forms as JSON/api(POST) Create new form entry/api/:id(PUT) Update form entry/api/:id(DELETE) Delete form entry/api/transform?{lang?: fi | en | sv}(POST) Transform BODY fromjsonformat toschemaformat/api/flushflushes cache
For documentation, see how the server uses the Builder component: https://github.com/luomus/laji-form-builder/blob/master/src/server/view/app.tsx
- node
- TypeScript
- express
- React
- playwright (e2e tests)
- supertest (express tests)
Correct node version is selected with volta or nvm use default.
npm ci
Copy config.json.example to config.json, and fill the configuration file.
Start the development server (it's the same as the production server but with hot reload enabled so code changed are reflected upon file changes):
npm start
Server is tested without having to run the server. Just run:
npm run test:server
MOCK=true: Field service test API requests are mocked by default.
Server can be running or or not. If it's not running, it will be automatically started.
npm run test:client
To run the tests, you might need to install playwright dependencies:
npx playwright install
If you run into issues with browser dependencies etc, there's also a dockerized runner:
# Run all tests (builds docker image & runs it)
npm run test:docker
# Or if you want to give playwright params, run certain tests etc:
npm run test:docker -- test/client/editor.ts --project chromium
To build the server (compiles both static and build):
npm run build:server
In production, run the built server with:
npm run start:prod
To build the npm package (compiles lib):
npm run build:client
Run npm version {patch,minor,major}. This will run the linting & front end tests (and halt if they fail), build the client and publish to npm. We follow semantic versioning.