From cb5e3be33bad7f0e52280c39eb52c9a54ac19dff Mon Sep 17 00:00:00 2001 From: marcel-bitfly <174338434+marcel-bitfly@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:52:32 +0200 Subject: [PATCH 1/2] refactor: change `:` to `=` for `environment variables` Our `bundler` vite can `handle` this formatting much better. E.g. all of these work like expected: `NUXT_PUBLIC_X= something` `NUXT_PUBLIC_X=something` `NUXT_PUBLIC_X=hello world` `NUXT_PUBLIC_X=false` `NUXT_PUBLIC_X="false"` `NUXT_PUBLIC_X=https://something.com?test=true` --- frontend/.env-example | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/frontend/.env-example b/frontend/.env-example index 8e5b8de1b..521652760 100644 --- a/frontend/.env-example +++ b/frontend/.env-example @@ -1,15 +1,15 @@ -NUXT_PUBLIC_API_CLIENT: "" -NUXT_PUBLIC_LEGACY_API_CLIENT: "" -NUXT_PRIVATE_API_SERVER: "" -NUXT_PRIVATE_LEGACY_API_SERVER: "" -NUXT_PUBLIC_API_KEY: "" -NUXT_PUBLIC_DOMAIN: "" -NUXT_PUBLIC_STRIPE_BASE_URL: "" -NUXT_PUBLIC_LOG_IP: "" -NUXT_PUBLIC_SHOW_IN_DEVELOPMENT: "" -NUXT_PUBLIC_V1_DOMAIN: "" -NUXT_PUBLIC_LOG_FILE: "" -NUXT_PUBLIC_CHAIN_ID_BY_DEFAULT: "" -NUXT_PUBLIC_MAINTENANCE_TS: "1717700652" -NUXT_PUBLIC_DEPLOYMENT_TYPE: "development" -PRIVATE_SSR_SECRET: "" +NUXT_PRIVATE_API_SERVER= +NUXT_PRIVATE_LEGACY_API_SERVER= +NUXT_PUBLIC_API_CLIENT= +NUXT_PUBLIC_API_KEY= +NUXT_PUBLIC_CHAIN_ID_BY_DEFAULT= +NUXT_PUBLIC_DEPLOYMENT_TYPE=development +NUXT_PUBLIC_DOMAIN= +NUXT_PUBLIC_LEGACY_API_CLIENT= +NUXT_PUBLIC_LOG_FILE= +NUXT_PUBLIC_LOG_IP= +NUXT_PUBLIC_MAINTENANCE_TS=1717700652 +NUXT_PUBLIC_SHOW_IN_DEVELOPMENT= +NUXT_PUBLIC_STRIPE_BASE_URL= +NUXT_PUBLIC_V1_DOMAIN= +PRIVATE_SSR_SECRET= From 5759a17cfb05737f1dbdcfa4b52cd3ceb7052ac6 Mon Sep 17 00:00:00 2001 From: marcel-bitfly <174338434+marcel-bitfly@users.noreply.github.com> Date: Thu, 17 Oct 2024 16:06:39 +0200 Subject: [PATCH 2/2] chore: add `flag` to get `mocked data` Api provides a `fall back` for `mocked data` for `testing purposes`. When `backend changes` are already merged, frontend might need a way to still get `mocked data`. See: 1fc71de --- frontend/.env-example | 1 + frontend/README.md | 8 ++++++++ frontend/composables/useCustomFetch.ts | 1 + frontend/nuxt.config.ts | 1 + frontend/types/datatable.ts | 2 +- 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/.env-example b/frontend/.env-example index 521652760..ffb100613 100644 --- a/frontend/.env-example +++ b/frontend/.env-example @@ -1,3 +1,4 @@ +NUXT_IS_API_MOCKED= NUXT_PRIVATE_API_SERVER= NUXT_PRIVATE_LEGACY_API_SERVER= NUXT_PUBLIC_API_CLIENT= diff --git a/frontend/README.md b/frontend/README.md index 678f9fb89..190640f2a 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -122,6 +122,14 @@ bun run preview Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information. +## Get mocked api data + +If your `user` was added to the `ADMIN` or `DEV` group by the `api team`, you can get +`mocked data` from the `api` for certain `endpoints` by adding `?is_mocked=true` as a +`query parameter`. + +You can `turn on` mocked data `globally` for all `configured enpoints` by setting `NUXT_PUBLIC_IS_API_MOCKED=true`. + ## Descision Record We documented our decisions in the [decisions](decisions.md) file. diff --git a/frontend/composables/useCustomFetch.ts b/frontend/composables/useCustomFetch.ts index c44ad29ba..8607af8a8 100644 --- a/frontend/composables/useCustomFetch.ts +++ b/frontend/composables/useCustomFetch.ts @@ -85,6 +85,7 @@ export function useCustomFetch() { options.query = { ...options.query, ...query, + is_mocked: true, } options.credentials = 'include' const method = options.method || map.method || 'GET' diff --git a/frontend/nuxt.config.ts b/frontend/nuxt.config.ts index 174e10fd1..2569ea263 100644 --- a/frontend/nuxt.config.ts +++ b/frontend/nuxt.config.ts @@ -89,6 +89,7 @@ export default defineNuxtConfig({ deploymentType: process.env.PUBLIC_DEPLOYMENT_TYPE, domain: process.env.PUBLIC_DOMAIN, gitVersion, + isApiMocked: '', legacyApiClient: process.env.PUBLIC_LEGACY_API_CLIENT, logFile: '', logIp: '', diff --git a/frontend/types/datatable.ts b/frontend/types/datatable.ts index e8477da55..4c4c1e56d 100644 --- a/frontend/types/datatable.ts +++ b/frontend/types/datatable.ts @@ -4,7 +4,7 @@ export type SortOrder = -1 | 0 | 1 | null | undefined export type TableQueryParams = { cursor?: Cursor, - isMocked?: boolean, + is_mocked?: boolean, limit?: number, order?: ColumnOrder, search?: string,