Skip to content

Commit

Permalink
chore: add flag to get mocked data
Browse files Browse the repository at this point in the history
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
  • Loading branch information
marcel-bitfly committed Oct 17, 2024
1 parent dd006e8 commit e7b050e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions frontend/.env-example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
NUXT_IS_API_MOCKED=
NUXT_PRIVATE_API_SERVER=
NUXT_PRIVATE_LEGACY_API_SERVER=
NUXT_PUBLIC_API_CLIENT=
Expand Down
8 changes: 8 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions frontend/composables/useCustomFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions frontend/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand Down
2 changes: 1 addition & 1 deletion frontend/types/datatable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e7b050e

Please sign in to comment.