Skip to content

Commit

Permalink
Add IMAGE_SERVER url
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsFlieger committed Feb 20, 2023
1 parent 1f83f23 commit a7d5b3e
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 17 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/frontend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ jobs:
NEXT_PUBLIC_API_BASE_URL_COMMAND: http://localhost:3002/commands/v1
NEXT_PUBLIC_API_BASE_URL_AUTH_SERVER: http://localhost:3001
NEXT_PUBLIC_API_BASE_URL_AUTH_CLIENT: http://localhost:3001
NEXT_PUBLIC_API_BASE_URL_IMAGE: http://localhost:3003
NEXT_PUBLIC_API_BASE_URL_IMAGE_SERVER: http://localhost:3003
NEXT_PUBLIC_API_BASE_URL_IMAGE_CLIENT: http://localhost:3003
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -104,7 +105,8 @@ jobs:
NEXT_PUBLIC_API_BASE_URL_COMMAND: http://localhost:3002/commands/v1
NEXT_PUBLIC_API_BASE_URL_AUTH_SERVER: http://localhost:3001
NEXT_PUBLIC_API_BASE_URL_AUTH_CLIENT: http://localhost:3001
NEXT_PUBLIC_API_BASE_URL_IMAGE: http://localhost:3003
NEXT_PUBLIC_API_BASE_URL_IMAGE_SERVER: http://localhost:3003
NEXT_PUBLIC_API_BASE_URL_IMAGE_CLIENT: http://localhost:3003
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ services:
- NEXT_PUBLIC_API_BASE_URL_COMMAND=${NEXT_PUBLIC_API_BASE_URL_COMMAND:-http://localhost:3002/commands/v1}
- NEXT_PUBLIC_API_BASE_URL_AUTH_SERVER=${NEXT_PUBLIC_API_BASE_URL_AUTH_SERVER:-http://auth:3001}
- NEXT_PUBLIC_API_BASE_URL_AUTH_CLIENT=${NEXT_PUBLIC_API_BASE_URL_AUTH_CLIENT:-http://localhost:3001}
- NEXT_PUBLIC_API_BASE_URL_IMAGE=${NEXT_PUBLIC_API_BASE_URL_IMAGE:-http://img:3003}
- NEXT_PUBLIC_API_BASE_URL_IMAGE_SERVER=${NEXT_PUBLIC_API_BASE_URL_IMAGE_SERVER:-http://img:3003}
- NEXT_PUBLIC_API_BASE_URL_IMAGE_CLIENT=${NEXT_PUBLIC_API_BASE_URL_IMAGE_CLIENT:-http://localhost:3003}

links:
- command-backend:cmd
- query-backend:query
Expand Down
3 changes: 2 additions & 1 deletion frontend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ NEXT_PUBLIC_API_BASE_URL_QUERY_CLIENT=http://localhost:3004/queries/v1
NEXT_PUBLIC_API_BASE_URL_COMMAND=http://localhost:3002/commands/v1
NEXT_PUBLIC_API_BASE_URL_AUTH_SERVER=http://localhost:3001
NEXT_PUBLIC_API_BASE_URL_AUTH_CLIENT=http://localhost:3001
NEXT_PUBLIC_API_BASE_URL_IMAGE=http://localhost:3003
NEXT_PUBLIC_API_BASE_URL_IMAGE_SERVER=http://localhost:3003
NEXT_PUBLIC_API_BASE_URL_IMAGE_CLIENT=http://localhost:3003
3 changes: 2 additions & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ ARG NEXT_PUBLIC_API_BASE_URL_QUERY_SERVER=PLACEHOLDER_NEXT_PUBLIC_API_BASE_URL_Q
ARG NEXT_PUBLIC_API_BASE_URL_COMMAND=PLACEHOLDER_NEXT_PUBLIC_API_BASE_URL_COMMAND
ARG NEXT_PUBLIC_API_BASE_URL_AUTH_SERVER=PLACEHOLDER_NEXT_PUBLIC_API_BASE_URL_AUTH_SERVER
ARG NEXT_PUBLIC_API_BASE_URL_AUTH_CLIENT=PLACEHOLDER_NEXT_PUBLIC_API_BASE_URL_AUTH_CLIENT
ARG NEXT_PUBLIC_API_BASE_URL_IMAGE=PLACEHOLDER_NEXT_PUBLIC_API_BASE_URL_IMAGE
ARG NEXT_PUBLIC_API_BASE_URL_IMAGE_SERVER=PLACEHOLDER_NEXT_PUBLIC_API_BASE_URL_IMAGE_SERVER
ARG NEXT_PUBLIC_API_BASE_URL_IMAGE_CLIENT=PLACEHOLDER_NEXT_PUBLIC_API_BASE_URL_IMAGE_CLIENT

RUN npm run build

Expand Down
3 changes: 2 additions & 1 deletion frontend/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export default defineConfig({
PUBLIC_API_BASE_URL_COMMAND: "http://localhost:3002/commands/v1",
PUBLIC_API_BASE_URL_AUTH_CLIENT: "http://localhost:3001",
PUBLIC_API_BASE_URL_AUTH_SERVER: "http://localhost:3001",
PUBLIC_API_BASE_URL_IMAGE: "http://localhost:3003",
PUBLIC_API_BASE_URL_IMAGE_SERVER: "http://localhost:3003",
PUBLIC_API_BASE_URL_IMAGE_CLIENT: "http://localhost:3003",
},
})
9 changes: 5 additions & 4 deletions frontend/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const API_BASE_URL_AUTH_SERVER = Cypress.env("PUBLIC_API_BASE_URL_AUTH_SERVER")
const API_BASE_URL_QUERY_CLIENT = Cypress.env("PUBLIC_API_BASE_URL_QUERY_CLIENT")
const API_BASE_URL_QUERY_SERVER = Cypress.env("PUBLIC_API_BASE_URL_QUERY_SERVER")
const API_BASE_URL_COMMAND = Cypress.env("PUBLIC_API_BASE_URL_COMMAND")
const PUBLIC_API_BASE_URL_IMAGE = Cypress.env("PUBLIC_API_BASE_URL_IMAGE")
const PUBLIC_API_BASE_URL_IMAGE_SERVER = Cypress.env("PUBLIC_API_BASE_URL_IMAGE_SERVER")
const PUBLIC_API_BASE_URL_IMAGE_CLIENT = Cypress.env("PUBLIC_API_BASE_URL_IMAGE_CLIENT")
const LOCAL_STORAGE_KEY = "session"

/**** Command helper *****/
Expand Down Expand Up @@ -192,12 +193,12 @@ Cypress.Commands.add("mockItemsList", (options) => {
})

Cypress.Commands.add("mockImageServe", () => {
cy.intercept("GET", `${PUBLIC_API_BASE_URL_IMAGE}/serve/*`, {
cy.intercept("GET", `${PUBLIC_API_BASE_URL_IMAGE_CLIENT}/serve/*`, {
statusCode: 201,
}).as("mockImageServe")

cy.task("nock", {
hostname: PUBLIC_API_BASE_URL_IMAGE,
hostname: PUBLIC_API_BASE_URL_IMAGE_SERVER,
method: "get",
path: "/*",
statusCode: 200,
Expand Down Expand Up @@ -251,7 +252,7 @@ Cypress.Commands.add("mockCreateItem", () => {
})

Cypress.Commands.add("mockUploadImage", () => {
cy.intercept("POST", `${PUBLIC_API_BASE_URL_IMAGE}/upload/image`, {
cy.intercept("POST", `${PUBLIC_API_BASE_URL_IMAGE_CLIENT}/upload/image`, {
statusCode: 201,
}).as("mockUploadImage")
})
Expand Down
3 changes: 2 additions & 1 deletion frontend/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace NodeJS {
NEXT_PUBLIC_API_BASE_URL_AUTH_SERVER: string
NEXT_PUBLIC_API_BASE_URL_AUTH_CLIENT: string
NEXT_PUBLIC_API_BASE_URL_COMMAND: string
NEXT_PUBLIC_API_BASE_URL_IMAGE: string
NEXT_PUBLIC_API_BASE_URL_IMAGE_CLIENT: string
NEXT_PUBLIC_API_BASE_URL_IMAGE_SERVER: string
}
}
10 changes: 7 additions & 3 deletions frontend/src/services/axios/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ export const authServerRequest = axios.create({
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL_AUTH_SERVER,
})

// Image API
export const imageRequest = axios.create({
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL_IMAGE,
// Image API from Server
export const imageServerRequest = axios.create({
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL_IMAGE_SERVER,
})

export const imageClientRequest = axios.create({
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL_IMAGE_CLIENT,
})
2 changes: 1 addition & 1 deletion frontend/src/services/utils/getImageUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export const getImageUrl = (image: string | undefined): string | undefined => {
string().url().validateSync(image)
return image
} catch (error) {
return `${process.env.NEXT_PUBLIC_API_BASE_URL_IMAGE}/serve/${image}`
return `${process.env.NEXT_PUBLIC_API_BASE_URL_IMAGE_CLIENT}/serve/${image}`
}
}
2 changes: 1 addition & 1 deletion frontend/src/services/utils/getImageUrl.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("getImageUrl", () => {
it("should return image url with image service when image is not URL", () => {
const image = "image.png"
const result = getImageUrl(image)
expect(result).to.equal(`${Cypress.env("PUBLIC_API_BASE_URL_IMAGE")}/serve/${image}`)
expect(result).to.equal(`${Cypress.env("PUBLIC_API_BASE_URL_IMAGE_CLIENT")}/serve/${image}`)
})

// This issue is in yup and is currently in PR (14.02.2023) https://github.com/jquense/yup/pull/1859
Expand Down
3 changes: 2 additions & 1 deletion sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ NEXT_PUBLIC_API_BASE_URL_QUERY_CLIENT=http://localhost:3004/queries/v1
NEXT_PUBLIC_API_BASE_URL_COMMAND=http://localhost:3002/commands/v1
NEXT_PUBLIC_API_BASE_URL_AUTH_SERVER=http://auth:3001
NEXT_PUBLIC_API_BASE_URL_AUTH_CLIENT=http://localhost:3001
NEXT_PUBLIC_API_BASE_URL_IMAGE=http://img:3003
NEXT_PUBLIC_API_BASE_URL_IMAGE_SERVER=http://img:3003
NEXT_PUBLIC_API_BASE_URL_IMAGE_CLIENT=http://localhost:3003

# Auth backend
# Database
Expand Down

0 comments on commit a7d5b3e

Please sign in to comment.