Skip to content

Commit df26030

Browse files
authored
Merge pull request #735 from bcgov/feat/srs-643
feat: initial code setup for cats
2 parents d2dab89 + c4ee42d commit df26030

File tree

137 files changed

+57410
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+57410
-0
lines changed

cats-frontend/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
build

cats-frontend/.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
.env
8+
9+
# testing
10+
/coverage
11+
12+
# production
13+
/build
14+
15+
# misc
16+
.DS_Store
17+
.env.local
18+
.env.development.local
19+
.env.test.local
20+
.env.production.local
21+
22+
npm-debug.log*
23+
yarn-debug.log*
24+
yarn-error.log*
25+
26+
# GraphQL codegen
27+
/graphql.schema.json

cats-frontend/Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# "build-stage", based on Node.js, to build and compile the frontend
2+
# pull official base image
3+
FROM node:22-alpine AS build
4+
5+
# set working directory
6+
WORKDIR /app
7+
8+
# add `/app/node_modules/.bin` to $PATH
9+
ENV PATH=/app/node_modules/.bin:$PATH
10+
11+
# install app dependencies
12+
COPY package.json ./
13+
COPY package-lock.json ./
14+
15+
# Switching to `npm ci` from `npm install` for consistent builds
16+
RUN npm ci --silent
17+
RUN npm install react-scripts@3.4.1 -g --silent
18+
19+
# create and set user permissions to app folder
20+
RUN mkdir -p node_modules/.cache && chmod -R 777 node_modules/.cache
21+
22+
# add app files
23+
COPY . ./
24+
RUN npm run build
25+
26+
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
27+
FROM nginx:alpine AS deploy
28+
RUN mkdir /app
29+
COPY --from=build /app/build /usr/share/nginx/html
30+
COPY nginx.conf /etc/nginx/nginx.conf
31+
CMD ["nginx", "-g", "daemon off;"]

cats-frontend/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Getting Started with Create React App
2+
3+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4+
5+
## Available Scripts
6+
7+
In the project directory, you can run:
8+
9+
### `npm start`
10+
11+
Runs the app in the development mode.\
12+
Open [http://localhost:4000](http://localhost:4000) to view it in your browser.
13+
14+
The page will reload when you make changes.\
15+
You may also see any lint errors in the console.
16+
17+
### `npm test`
18+
19+
Launches the test runner in the interactive watch mode.\
20+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21+
22+
### `npm run build`
23+
24+
Builds the app for production to the `build` folder.\
25+
It correctly bundles React in production mode and optimizes the build for the best performance.
26+
27+
The build is minified and the filenames include the hashes.\
28+
Your app is ready to be deployed!
29+
30+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31+
32+
### `npm run eject`
33+
34+
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
35+
36+
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37+
38+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39+
40+
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41+
42+
## Learn More
43+
44+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45+
46+
To learn React, check out the [React documentation](https://reactjs.org/).
47+
48+
### Code Splitting
49+
50+
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51+
52+
### Analyzing the Bundle Size
53+
54+
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55+
56+
### Making a Progressive Web App
57+
58+
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59+
60+
### Advanced Configuration
61+
62+
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63+
64+
### Deployment
65+
66+
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67+
68+
### `npm run build` fails to minify
69+
70+
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

cats-frontend/apollo.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
client: {
3+
service: {
4+
name: 'nr-site-registry',
5+
localSchemaFile: `./graphql.schema.json`,
6+
},
7+
includes: [`./src/**/*`],
8+
excludes: ['./src/graphql/generated.ts'],
9+
},
10+
};

cats-frontend/babel.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
presets: [
3+
'@babel/preset-typescript',
4+
'@babel/preset-env',
5+
['@babel/preset-react', { runtime: 'automatic' }],
6+
],
7+
};

cats-frontend/codegen.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { CodegenConfig } from '@graphql-codegen/cli';
2+
3+
const config: CodegenConfig = {
4+
overwrite: true,
5+
schema: 'http://host.docker.internal:4007/graphql',
6+
documents: ['src/**/*.graphql'],
7+
generates: {
8+
'./src/graphql/generated.ts': {
9+
plugins: [
10+
'typescript',
11+
'typescript-operations',
12+
'typescript-react-apollo',
13+
],
14+
},
15+
'graphql.schema.json': {
16+
plugins: ['introspection'],
17+
},
18+
},
19+
ignoreNoDocuments: true,
20+
};
21+
22+
export default config;

cats-frontend/nginx.conf

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# nginx.conf
2+
worker_processes auto;
3+
error_log /var/log/nginx/error.log;
4+
5+
pid /tmp/nginx.pid;
6+
7+
events {
8+
worker_connections 4096;
9+
}
10+
11+
http {
12+
include /etc/nginx/mime.types;
13+
client_body_temp_path /tmp/client_temp;
14+
proxy_temp_path /tmp/proxy_temp_path;
15+
fastcgi_temp_path /tmp/fastcgi_temp;
16+
uwsgi_temp_path /tmp/uwsgi_temp;
17+
scgi_temp_path /tmp/scgi_temp;
18+
default_type application/octet-stream;
19+
server_tokens off;
20+
underscores_in_headers on;
21+
22+
# Use a w3c standard log format
23+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
24+
'$status $body_bytes_sent "$http_referer" '
25+
'"$http_user_agent" "$http_x_forwarded_for"';
26+
27+
access_log /var/log/nginx/access.log main;
28+
29+
30+
server {
31+
32+
# add in most common security headers
33+
add_header Content-Security-Policy "default-src * data: blob: filesystem: 'unsafe-inline' 'unsafe-eval'; frame-ancestors 'self' https://*.apps.silver.devops.gov.bc.ca";
34+
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
35+
add_header X-Content-Type-Options "nosniff";
36+
add_header X-XSS-Protection 1;
37+
add_header X-Frame-Options SAMEORIGIN;
38+
39+
listen 8080;
40+
server_name _;
41+
42+
index index.html;
43+
error_log /dev/stdout info;
44+
access_log /dev/stdout;
45+
46+
# frontend
47+
location / {
48+
root /usr/share/nginx/html;
49+
index index.html index.htm;
50+
try_files $uri $uri/ /index.html;
51+
}
52+
53+
error_page 500 502 503 504 /50x.html;
54+
55+
location = /50x.html {
56+
root /usr/share/nginx/html;
57+
}
58+
location /health {
59+
default_type 'text/plain';
60+
access_log off;
61+
return 200;
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)