08d5c118d32a323eff0354206213131ed8fa82cd
The mesh builds all three images from this repository and a commit (novox/hq ADR 0069) — the Drone pipeline that built outside Docker and copied its output in retires with the predecessor. One module carries the API and every client instance: eef and filip are the same built client under two names, which is a second route contribution, not a second module (ADR 0015 — an application is one repository). The clients drop nginx and its bash startup script: the node the API already needs serves the static build too (client-server/serve.mjs — files, the SPA fallback, env-config.js from the environment), so the whole module stands on one declared base. What the machine serves does not move: the same four public names, the same four machine ports. MongoDB, the bucket and every credential arrive as mesh grants instead of hand-set environment; SUPER_ADMIN_KEY stops being a default written in code and becomes a minted secret.
Novox Photos manager
Client - Photos react app
App structure
- React application with a public facing website (
./public) and an administration panel (./private) - React router is split into
<PublicRoutes />and<PrivateRoutes /> <PrivateRoutes />is wrapped in the<Keycloak>context provider- The
<Keyclock>context provider is created using theAuthProviderfrom theoidc-reactpackage - AutoSignin is explicitly set to
falseto prevent the website from always trying to log in (even if not trying to access the admin section) - The
<AdminLayout>component handles the authentication only rendering the<Outlet>when the user is logged in and has sufficient permissions (role based) - We can access the user info using the
useAuthhook, only possible in React components or hooks - Our
privateApiservice is provided using theusePrivateApihook, it makes use of theuseAuthhook to set the authorization header - The url for the private api is set using a "environment variable" (see build process)
Build process
- The build process is quite simple and uses
react-scripts build - "Environment variables" can be set in the
.envfile. Before starting the application run./scripts/env.shto create anenv-config.jsfile in the./publicfolder which is then loaded using a<script>tag in index.html - In our docker setup, we can pass the environment variables in our docker-compose. When starting the container
the
env.shscript is executed before starting the application
Server - Photos node api
App structure
- We use Koa to setup our web api
- Our api is split into a
/api/publicand/api/privateroutes (see the 2 routers) RouterandHttpEndpointtypes can be used to add new endpoints- Following middleware is provided:
- JWT token validation
- Request/response logging
- CORS
- Error handling
@koa/multerto handle file uploads usingmultipart/form-data
Languages
JavaScript
85.2%
SCSS
11.8%
HTML
1.3%
Shell
0.8%
CSS
0.5%
Other
0.4%