10 - Integrating a server-side-rendered reactApp Flashcards

1
Q

sample request-response flow with React APp

A
  • browser opens index page
  • html response sent
  • browser requests JS files
  • JS files response sent
  • some data is requested
  • order data sent
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

nextjs project setup basics

A

install react, react-dom, next
set script dev - next

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

how is rounting handled in nextjs

A

file-based routing from the pages folder

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

sample dockerfile to build a an express server image

A

FROM node:alpine
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
CMD [“npm”, “run”, “dev”]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

client kubernetes deployment with networking service

A

apiVersion: apps/v1
kind: Deployment
metadata:
name: client-deployment
labels:
app: client
spec:
replicas: 1
selector:
matchLabels:
app: client
template:
metadata:
labels:
app: client
spec:
containers:
- name: client
image: node:14 # Replace with your own image
ports:
- containerPort: 3000
resources:
limits:
memory: “512Mi”
cpu: “500m”
command: [“node”, “app.js”]

apiVersion: v1
kind: Service
metadata:
name: client-srv
spec:
selector:
app: client
ports:
- name: client
- protocol: TCP
port: 3000 # The port to expose the service on
targetPort: 3000 # The port the container is listening on
nodePort: 30080 # The port exposed on the node (for NodePort only)
type: NodePort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

adding client images to skaffold setup

A

artifacts:
- image: imageName/auth
context: auth
docker:
dockerfile: Dockerfile
sync:
manual:
- src: ‘src//.ts’
dest: .
- image: imageName/client
context: client
docker:
dockerfile: Dockerfile
sync:
manual:
- src: ‘**/
.js’
dest: .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

ingress config path

A

spec:
rules:
- host: ticketing.dev
http:
paths:
- path: /api/users/?(.)
backend:
serviceName: auth-srv
servicePort: 3000
- path: /?(.
)
backend:
serviceName: client-srv
servicePort: 3000

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

nextjs filechange detection config

A

module.exports = {
webpackDevMiddleware: config => {
config.watchOptions.poll = 300;
return config;
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

bootstrap setup for SSR

A

import ‘bootstrap/dist/css/bootstrap.css’;

export default ({ Component, pageProps }) => {
return <Component { … pageProps} />
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

handling signup inputs, email, password

A

password, email, errors, onSubmit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

useRequest hook flow

A

params: url, request method, request body

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

doRequest method, with errors jsx

A

errors hook
await axiosmethod;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

onSuccess callback to route to homepage

A

const { doRequest, errors } = useRequest({
url: ‘/api/users/signup’,
method: ‘post’,
body: {
email, password
},
onSuccess: ( ) => Router.push(“/”)
});

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

cross namespace service communication

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

getInitialProps in k8s, ingress

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

passing headers to request from server, getInitialProps

A
17
Q

creating a resuable API client

A
18
Q
A