Skip to content

Commit

Permalink
I404 backend update (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
pushyamig committed May 21, 2024
1 parent 4288096 commit 18c64b0
Show file tree
Hide file tree
Showing 5 changed files with 4,774 additions and 14,878 deletions.
8 changes: 4 additions & 4 deletions ccm_web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# - https://dev.to/chrsgrrtt/dockerising-a-next-js-project-1ck5

# Base stage
FROM node:16-slim AS base
FROM node:20-slim AS base
WORKDIR /base/

COPY package*.json ./
Expand All @@ -14,14 +14,14 @@ ARG PORT
EXPOSE ${PORT}

# Build stage (build client and compile server to JS)
FROM node:16-slim AS build
FROM node:20-slim AS build
WORKDIR /build/

COPY --from=base /base ./
RUN npm run build

# Prod stage
FROM node:16-slim AS prod
FROM node:20-slim AS prod
ENV NODE_ENV=production
WORKDIR /app

Expand All @@ -32,7 +32,7 @@ COPY --from=base \
/base/ecosystem.config.js \
./
RUN npm install --production
RUN npm install pm2@5.2.0 -g
RUN npm install pm2@5.3.1 -g
COPY --from=build /build/dist/ ./

# Set PM2_HOME so that .pm2 files are written in /tmp/
Expand Down
8 changes: 4 additions & 4 deletions ccm_web/client/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const jsonMimeType = 'application/json'

export const getCSRFToken = (): string | undefined => Cookies.get('CSRF-Token')

const initCSRFRequest = (headers: string[][]): RequestInit => {
const initCSRFRequest = (headers: Array<[string, string]>): RequestInit => {
const csrfToken = getCSRFToken()
if (csrfToken !== undefined) headers.push(['CSRF-Token', csrfToken])
const request: RequestInit = { headers }
Expand All @@ -25,15 +25,15 @@ const getGet = (): RequestInit => {
}

const getPost = (body: string): RequestInit => {
const headers: string[][] = [['Content-Type', jsonMimeType], ['Accept', jsonMimeType]]
const headers: Array<[string, string]> = [['Content-Type', jsonMimeType], ['Accept', jsonMimeType]]
const request = initCSRFRequest(headers)
request.method = 'POST'
request.body = body
return request
}

const getDelete = (body: string): RequestInit => {
const headers: string[][] = [['Content-Type', jsonMimeType], ['Accept', jsonMimeType]]
const headers: Array<[string, string]> = [['Content-Type', jsonMimeType], ['Accept', jsonMimeType]]
const request = initCSRFRequest(headers)
request.method = 'DELETE'
request.body = body
Expand All @@ -42,7 +42,7 @@ const getDelete = (body: string): RequestInit => {

// This currently assumes all put requests have a JSON payload and receive a JSON response.
const getPut = (body: string): RequestInit => {
const headers: string[][] = [['Content-Type', jsonMimeType], ['Accept', jsonMimeType]]
const headers: Array<[string, string]> = [['Content-Type', jsonMimeType], ['Accept', jsonMimeType]]
const request = initCSRFRequest(headers)
request.method = 'PUT'
request.body = body
Expand Down
Loading

0 comments on commit 18c64b0

Please sign in to comment.