master
continuous-integration/drone/push Build is passing
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%