In this project, we are using Prisma instead of TypeORM. Although the project initially had some frameworks in TypeORM, it was decided to use Prisma as the main ORM at this point.
npm install
# or
yarncp .env.example .envnpm run prisma generate
# or
yarn prisma generate
npm run prisma migrate dev
# or
yarn prisma migrate devnpm run start:dev
# or
yarn start:devOnce the application is running, you can access the GraphQL Playground at: http://localhost:4000/graphql
npm run test
# or
yarn testnpm run test:e2e
# or
yarn test:e2e- Fetch all Pokémon with optional filtering and sorting.
- Uses a cache with a TTL of 20 seconds to improve performance.
- Fetch Pokémon in a paginated format.
- Supports filtering and sorting.
- Uses a cache with a TTL of 20 seconds to improve performance.
- Create a new Pokémon with a name and types.
- Update an existing Pokémon's name and types.
- Delete a Pokémon by ID.
- After any of these operations, the cache is clean.
- Import Pokémon data from an external API (PokeAPI) and save it to the database.
- Fetch all Pokémon with optional filtering and sorting.
- Uses a cache with a TTL of 20 seconds to improve performance.
- Before, the pokemon
typeproperty was a varchar column inside thepokemonstable - Now, we have a many-to-many relationship between pokemons entity and types entity
- Then, we can have multiple types for same pokemon, allowing different abilities!
- The script below was used to make this migration works:
insert into types (name)
select distinct p.type
from pokemons AS p
where p.type is not null;
insert into pokemon_types (pokemon_id, type_id)
select p.id, t.id
from pokemons as p
join types as t on p.type = t.name;
update types
set name = lower(name);- After this, the old
typecolumn was deleted frompokemonstable.
- Limits API requests to 10 requests per 30 seconds per IP address.
- If the limit is exceeded, the user is blocked until the end of the 30 second window.
- Example: If the user makes 10 requests at t = 0s, they will be blocked until t = 30s. If the user makes 10 requests at t = 15s, they will be blocked until t = 45s.
- Add Redis as a Cache Storage:
- Replace the in-memory cache with Redis for better scalability and performance.
- Enhance Pagination Metadata:
- Add properties like total_count and has_next_page to the pagination response.
- Expand Pokémon Data:
- Add more properties (e.g., abilities, stats) to the Pokémon model.
- Improve Error Handling:
- Add more detailed error messages and logging for better debugging.
Made by @stra1g 🖤
