Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes: Readme, APIs routes, front end .map bug... #21

Merged
merged 4 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ generate-diagrams: $(OUT)
$(SRCDIR)/%.$(OUTPUT_FORMAT): $(SRCDIR)/%.mdd
npm run generate-diagram -- --input $< --output $@

run: ## run Pokeshop API on docker compose
run/pokeshop: ## run Pokeshop API on docker compose
docker compose -f docker-compose.yml -f ./docker-compose.stream.yml up

down: ## stop Pokeshop API running on docker compose
down/pokeshop: ## stop Pokeshop API running on docker compose
docker compose -f docker-compose.yml -f ./docker-compose.stream.yml down

run/tracetests: ## run Trace-based tests on Pokeshop API with Tracetest
docker compose -f docker-compose.yml -f ./docker-compose.stream.yml -f ./tracetest/docker-compose.yml run tracebased-tests
docker compose -f docker-compose.yml -f ./docker-compose.stream.yml -f ./tracetest/docker-compose.yml run tracebased-tests

run: ## run Pokeshop API on Docker Compose and run Trace-based tests with Tracetest
docker compose -f docker-compose.yml -f ./docker-compose.stream.yml -f ./tracetest/docker-compose.yml up

down: ## stop Pokeshop API on Docker Compose and run Trace-based tests with Tracetest
docker compose -f docker-compose.yml -f ./docker-compose.stream.yml -f ./tracetest/docker-compose.yml down
4 changes: 2 additions & 2 deletions api/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ async function startApp() {
healthcheckHandler, // should be first than getByIdHandler since both paths could collide
createHandler,
getHandler,
getByIdHandler,
featuredHandler,
searchHandler,
getByIdHandler,
importHandler,
removeHandler,
searchHandler,
updateHandler,
];

Expand Down
2 changes: 1 addition & 1 deletion api/src/handlers/get.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { jsonResponse } from '@pokemon/middlewares/response';
import { getPokemonRepository } from '@pokemon/repositories';

const get = async (ctx, next) => {
const { skip = '0', take = '20' } = ctx.request.query || {};
const { skip = '0', take = '100' } = ctx.request.query || {};
const query = { skip: +skip, take: +take };

const repository = getPokemonRepository();
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ services:

queue:
image: rabbitmq:3.9
restart: unless-stopped
ports:
- 5672:5672
- 15672:15672
Expand Down
30 changes: 22 additions & 8 deletions docs/installing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,52 @@

## Run it locally

To try it locally, you can use `docker-compose` to run the API, its Worker, and all its dependencies.
To try it locally, you can use Docker Compose to run the API, its Worker, and all its dependencies.

### Requirements
- [docker](https://www.docker.com/get-started/)
- [docker-compose](https://docs.docker.com/compose/install/)

1. [Docker](https://www.docker.com/get-started/)
2. [Docker Compose](https://docs.docker.com/compose/install/)

### Steps

1. Clone the project
2. Go to the `api` folder inside the project folder
3. Execute `docker-compose up`
2. Go to the `pokeshop` project folder
3. Execute `make run`

### Script

```$
git clone [email protected]:kubeshop/pokeshop.git
cd pokeshop/api
docker-compose up
cd pokeshop
make run
```

This will start the Pokeshop app on `http://localhost:8081` and Tracetest on `http://localhost:11633`.

The `make run` command will also trigger four **Tests** when started.

![tracetest initial tests](https://res.cloudinary.com/djwdcmwdz/image/upload/v1693846733/docs/localhost_11633__10_px4kqa.png)

As well as one **Test Suite**.

![tracetest initial test suite](https://res.cloudinary.com/djwdcmwdz/image/upload/v1693846736/docs/localhost_11633__11_coms2i.png)


## Run on a Kubernetes cluster

If you want to run this project on a real cluster, we provide a helm chart to install it. This installation doesn't create a jaeger instance for you, so you have to install it manually and set the `JAEGER_HOST` and `JAEGER_PORT` on the `env` section of the file `helm-chart/values.yml`.

### Requirements

1. [helm](https://helm.sh/)

### Steps

1. Clone the project
2. Go to the helm-chart folder inside the project folder
3. Execute `helm dependency update`
4. Update `JAEGER_HOST` and `JAEGER_PORT` on the file `helm-chart/values.yml` to reflect your cluster's jaeger instance
5. Execute `helm install -n demo -f values.yaml --create-namespace demo .`

> :warning: **This will create a namespace called "demo" on your cluster**. If you wish to change it, replace `-n demo` on step 5 with `-n <your-namespace>`.
> :warning: **This will create a namespace called "demo" on your cluster**. If you wish to change it, replace `-n demo` on step 5 with `-n <your-namespace>`.
14 changes: 14 additions & 0 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"antd": "^4.21.6",
"lodash": "^4.17.21",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-query": "^3.39.1",
Expand Down Expand Up @@ -56,6 +57,7 @@
"styled-components": "5"
},
"devDependencies": {
"@types/lodash": "^4.14.197",
"@types/styled-components": "^5.1.25",
"openapi-typescript": "^5.4.1"
},
Expand Down
10 changes: 9 additions & 1 deletion web/src/components/Header/HeaderMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DOCUMENTATION_URL, GITHUB_URL } from '../../constants/common';
import { DOCUMENTATION_URL, GITHUB_URL, DISCORD_URL } from '../../constants/common';
import * as S from './Header.styled';

interface IProps {
Expand Down Expand Up @@ -26,6 +26,14 @@ export const HeaderMenu = ({ pathname }: IProps) => {
</a>
),
},
{
key: 'discord',
label: (
<a href={DISCORD_URL} target="_blank" data-cy="discord-link">
Discord
</a>
),
},
]}
/>
);
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/PokemonList/PokemonList.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _ from 'lodash';
import { TPokemon } from '../../types/pokemon';
import PokemonCard from '../PokemonCard';
import * as S from './PokemonList.styled';
Expand All @@ -16,7 +17,7 @@ const PokemonList = ({ pokemonList, totalCount, title, isFeaturedList = false }:
{title} - {totalCount}
</S.TitleText>
<S.PokemonList>
{pokemonList.map(pokemon => (
{_.map(pokemonList, pokemon => (
<PokemonCard key={pokemon.id} pokemon={pokemon} isFeaturedList={isFeaturedList} />
))}
</S.PokemonList>
Expand Down
2 changes: 1 addition & 1 deletion web/src/constants/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const DOCUMENTATION_URL = 'https://kubeshop.github.io/tracetest/';
export const DOCUMENTATION_URL = 'https://docs.tracetest.io';
export const GITHUB_URL = 'https://github.com/kubeshop/tracetest';
export const GITHUB_ISSUES_URL = 'https://github.com/kubeshop/tracetest/issues/new/choose';
export const DISCORD_URL = 'https://discord.gg/6zupCZFQbe';
2 changes: 2 additions & 0 deletions web/src/hooks/usePokemonCrud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ const usePokemonCrud = () => {
const createPokemon = useMutation(PokemonGateway.create, {
onSuccess: () => {
queryClient.invalidateQueries(CACHE_KEY);
queryClient.invalidateQueries(FEATURED_CACHE_KEY);
},
});

const importPokemon = useMutation(PokemonGateway.import, {
onSuccess: () => {
queryClient.invalidateQueries(CACHE_KEY);
queryClient.invalidateQueries(FEATURED_CACHE_KEY);
},
});

Expand Down
8 changes: 6 additions & 2 deletions web/src/pages/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ const HomePage = () => {
<PokemonList
pokemonList={featuredPokemonList}
totalCount={featuredPokemonList.length}
title="Featured"
title="Featured Pokémon"
isFeaturedList
/>
<PokemonList pokemonList={pokemonList} totalCount={totalCount} title="All Pokemons" />
<PokemonList
pokemonList={pokemonList}
totalCount={totalCount}
title="All Pokémon"
/>
</S.Wrapper>
</Layout>
);
Expand Down
Loading