Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

new architecture #18

Open
wants to merge 75 commits into
base: main
Choose a base branch
from
Open

new architecture #18

wants to merge 75 commits into from

Conversation

l31-dev
Copy link
Contributor

@l31-dev l31-dev commented Apr 9, 2024

DO NOT PULL FOR THE MOMENT.

  • WELLLLLL .... LETS USE NX
  • feat: added prisma and auto-fill database
  • Updating gitignore
  • feat: get animes by filter
  • Update to ensure no null values are passed
  • feat: usage of rep.send instead of a return
  • feat: anime by id; cache and episode
  • fix: synopsis now back there
  • fix: fixed the search
  • Fixed minor problem in search Ex: "Status", is now "status" (snake_case for property in the where condition of findMany)
  • deserialising Episodes from anime (when checking a single Episode)
  • fix: removed unused lua file
  • fix: removed unused spec.ts
  • feature: better organization and aliases
  • doc: document the /animes route
  • doc: document the /animes/:id route
  • fix: paths
  • Loading Latest in addition
  • Adding the route animes/latest
  • feat: disconnect when end
  • fix: fetchType util & improved code quality
  • fix: reformat the code because the original dev is very bad
  • fix: ouais
  • Adding Expirity to latest
  • Minor update (adding JWT) will be used later in the process
  • fix: register properties pattern & code refactor
  • feat: moved config to env variables + validation
  • refactor(animes-routes): streamline anime list and latest endpoints, improve caching
  • refactor(auth): move authentication logic into UserService
  • style: format and standardize codebase with prettier and eslint
  • docs(app): add JSDoc comments for app initialization and database update functions
  • refactor(animes): utilize AnimeService for route handlers with enhanced JSDoc documentation
  • feat(services): introduce AnimeService for centralized anime data handling
  • feat(services): add UserService for user registration and authentication operations
  • feat(routes): Adding JSDoc to auth routes
  • BREAKING CHANGE: use biome instead of prettier and eslint
  • refactor: formatted and fixed lint prblm using biome
  • refactor: Remove redundant route comments
  • refactor: Improve query construction
  • feat(animes.ts): Enhance anime list query
  • refactor: Mark plugin and route default exports as async
  • feat(animes-route): optimize anime list fetching with caching and improve query handling
  • feat: implement required environment variable validation
  • feat(server-setup): integrate Fastify, Prisma, and Redis
  • Refactor(animeService): Streamline anime data operations and caching
  • Adding two new modules (and removing a deprecated module openssl)
  • Typing Schema changed to use "TypeBox" (More efficient, and less work)
  • Removing the JwsUtils.ts
  • Add of the plugins jwt.ts with specifieds handlers
  • Changing minors thing their (adding atest caching and puting schema to use Timestamp in database)
  • Add a route to logged in Users (Using a Bearer Token of course)
  • 🌱 a new beginning
  • 🏗️ Setup the organization
  • 🚀 clean script & enhance types integration
  • refactor: 🗑 Remove redundant @gazes/types declaration
  • chore: 🧹 Clean up packages/types directory
  • ✨ feat(api): refactor routing and enhance code readability
  • 🐛 fix(api): correct import path for RouteOptions in animeRouter
  • 🚀 feat(api): setup database schema, routing, and services
  • 📦 feat: Update dependencies and clean up project structure
  • feat(api): 🚀 Add anime data handling and environment setup
  • Add AGPL license text
  • Fix README markup and formatting
  • Update README
  • CENTER README
  • update README TO SPACE (because tabs are for noobies)
  • feat(api): Enhance API structure and introduce full text search
  • hono baby
  • Add server setup with Prisma client, Hono, and anime controller

l31-dev and others added 30 commits March 28, 2024 20:31
You now can get you anime by ID and he's cached so we reduce the
requests time. Same shit for episode videos.
Ex:  "Status", is now "status" (snake_case for property in the where condition of findMany)
l31-dev and others added 28 commits March 30, 2024 21:46
Enhanced the application's architecture by integrating Fastify for the
web server framework, Prisma as the ORM for database interactions, and
Redis for caching capabilities. This setup provides a robust foundation
for building scalable web applications.

- Initialized Fastify with custom configuration, disabling the logger by
  default for streamlined operation.
- Established a PrismaClient instance for database interactions,
  enabling advanced data management and query capabilities.
- Configured Redis client and implemented automatic connection logic,
  including environment-specific behavior (e.g., flushing the database
  in development mode for a clean slate).
- Defined `AppOptions` interface to type-check application options,
  ensuring type safety across app components.
- Set up graceful shutdown procedures to properly close database and
  Redis connections upon application termination, enhancing resource
  management and stability.
- Refined the server's listen method to dynamically use environment
  variables for port and host settings, improving deployment
  flexibility.

This commit lays the groundwork for a modular, efficient backend
structure that leverages the strengths of each integrated technology.
This commit significantly refactors the animeService class to enhance
readability, improve cache management, and remove unused imports and
functions. Key changes include:

- Removed unused imports such as `config`, `PrismaClient`, and various
  types from "@api/contracts/animesContract".
- Simplified the `AnimeService` constructor to use `PrismaClient` and
  `CacheManager` directly, enhancing dependency injection and testing
  capabilities.
- Optimized `getAnimeById` to better utilize caching for anime details,
  reducing unnecessary database queries.
- Introduced `getAndEnrichAnimesList` to fetch and optionally enrich a
  list of animes with additional details, leveraging both database
  queries and cache for improved performance.
- Removed outdated functions responsible for updating the anime database
  and fetching the latest episodes. This functionality is presumed to be
  handled elsewhere or refactored into a more appropriate service or
  scheduled task.
- Updated routes in `animes.ts` to reflect changes in the animeService's
  API, ensuring compatibility with the refactored service methods.
- Adjusted other service classes and route handlers to align with the
  refactoring, ensuring consistent use of `PrismaClient` and
  `CacheManager`.

Overall, this commit aims to make the animeService more efficient,
maintainable, and aligned with best practices in cache usage and data
fetching.
- Set project to private in root `package.json` to avoid accidental
  publishing.
- Introduced a `clean` script in root `package.json` for easier
  workspace cleanup.
- Updated `fastify` dependency and added `@gazes/types` as a workspace
  dependency in `packages/api/package.json` to ensure consistency and
  leverage shared types.
- Refined imports and simplified the structure in
  `packages/api/src/routes/animes.router.ts` by utilizing shared types
  from `@gazes/types`, demonstrating a move towards more modular and
  maintainable code.
- Initialized `packages/types` with essential configurations and a basic
  README for better clarity and documentation.
- Enhanced TypeScript configuration across packages to better support
  modular architecture and shared types, ensuring smoother development
  and integration across workspaces.

Binary files `bun.lockb` updated to reflect new dependency resolutions
and package updates.
- Deleted the `packages/types/types/types.d.ts` file to clean up
  unnecessary type declarations. This change streamlines the types
  package, removing a redundant declaration that may have been
  superseded by direct TypeScript configurations or internal type
  definitions within the `@gazes/types` package itself.
- Removed the `.gitignore` file from `packages/types`, aligning with a
  project-wide strategy to centralize ignore patterns and reduce
  redundancy.
- Deleted `README.md` from `packages/types` to streamline documentation,
  focusing on a unified project documentation approach rather than
  package-specific instructions.
- 🎨 Improve code style in `app.ts` with better formatting and added comments for clarity.
- 🔀 Rename `animes.router.ts` to `animeRouter.ts` and move to `routers` directory for consistent naming and organization.
- 📝 Add `routeTypes.ts` for centralizing route-related type definitions, improving code maintainability.
- Correct the import path for `RouteOptions` to `@/types/routeTypes`, fixing a previously overlooked update.
- Adjust the structure within `animeRouter.ts` for better readability.
- 🚫 Add `.gitignore` to exclude `node_modules` and `.env` files from
  version control.
- 🗃️ Introduce Prisma schema for PostgreSQL integration with an initial
  `Anime` model definition.
- ✏️ Minor adjustments in `animeRouter.ts` to enhance readability with
  added whitespace.
- 🏗️ Create `animeService.ts` for future business logic related to anime
  entities.
- 🔄 Update `bun.lockb` to reflect changes in dependencies.
- ➕ Add `prisma` version "^5.12.0" to `dependencies` in `package.json`,
  supporting enhanced database interactions.
- 🗑️ Remove `.gitignore` in `packages/api` as part of reorganizing
  project configuration.
- Introduced `.env.example` for environment variable management.
- Moved and updated `package.json` within the `apps/api` directory, adding new dependencies and scripts for development and build processes.
- Created a new Prisma migration for the `Anime` table, outlining the structure for anime data storage.
- Developed new services and routes for fetching, caching, and serving anime data.
- Configured Docker Compose with PostgreSQL and Redis services to support local development.
- Enhanced the codebase with TypeScript configurations and utility functions for environment variable and fetch operations.
Because they forgot it on the new branch, and also didn't use the valid
filename.

Signed-off-by: Nicolas Paul <[email protected]>
Please learn how to type

Signed-off-by: Nicolas Paul <[email protected]>
Signed-off-by: exatombe <[email protected]>
- Reformatted `package.json` for consistency in indentation.
- Removed an outdated Prisma migration file, indicating a possible schema or database reorganization.
- Updated Prisma schema to enable preview features like fullTextSearch and fullTextIndex, preparing the API for more advanced query capabilities.
- Refined the structure and syntax across various service and utility files for improved readability and adherence to best practices. This includes minor adjustments like consistent use of semicolons, simplified import statements, and more descriptive typing for anime data.
- Introduced a new type definition for fetched anime data, ensuring better type safety and clarity when handling anime information.
- Adjusted route handling in `animeRouter.ts` to directly return fetched anime lists, enhancing the endpoint's functionality.
- Made improvements to the caching service for more robust and clearer cache management.

This commit significantly refactors the API's codebase for better maintainability, prepares the application for future feature expansions, and optimizes data handling and type safety.
Copy link

Potential issues, bugs, and flaws:

  1. /api/.prettierrc:

    • The file .prettierrc is deleted. It's essential to have a consistent code formatting configuration for the project to maintain readability and standardization across the codebase.
  2. /api/.gitignore:

    • The file .gitignore is deleted without any replacement or alternative. It's important to have a .gitignore file in the project to exclude unnecessary files from version control.
  3. /apps/api/prisma/schema.prisma:

    • The Prisma model definition in schema.prisma lacks proper naming conventions. Ideally, model properties and table names should follow a consistent naming convention for better readability and understanding.
  4. /apps/api/prisma/zod/anime.ts:

    • The Zod validation schema for the AnimeModel seems overly permissive. It's important to validate and restrict the inputs as necessary to prevent unexpected data formats or values causing issues during runtime.
  5. /apps/api/src/controllers/animeController.ts:

    • The controller logic for fetching animes lacks proper error handling and response structure. It's crucial to handle errors more effectively and provide detailed error messages and status codes to clients for better debugging and user experience.
  6. /api/src/index.ts:

    • The error handling in the index file is minimal and can be improved. Adding more robust error handling mechanisms, such as try-catch blocks, could help capture and handle errors more effectively.

Code suggestions and improvements:

  1. Consistent Configuration Files:

    • Ensure that essential configuration files like .prettierrc and .gitignore are maintained and standardized across the codebase for consistency.
  2. Data Validation:

    • Enhance the Zod validation schema in /apps/api/prisma/zod/anime.ts to include stricter validation rules based on the expected data format and values.
  3. Error Handling:

    • Implement more robust error handling strategies in controllers like /apps/api/src/controllers/animeController.ts to provide clear error messages and appropriate status codes.
  4. Environment Variables:

    • Utilize environment variables consistently across the project to manage configuration options and secrets securely.
  5. Signal Handling:

    • Implement graceful shutdown procedures using signal handlers (SIGINT, SIGTERM) as shown in /apps/api/src/index.ts to ensure the application cleans up resources before exiting.
  6. Code Consistency:

    • Maintain consistent coding styles, naming conventions, and project structures throughout the codebase to improve readability and maintainability.

Copy link

gitguardian bot commented Apr 9, 2024

⚠️ GitGuardian has uncovered 7 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
10127395 Triggered Generic High Entropy Secret 37a9f2f nx.json View secret
10127395 Triggered Generic High Entropy Secret a1a4091 nx.json View secret
10127395 Triggered Generic High Entropy Secret 37a9f2f nx.json View secret
10127395 Triggered Generic High Entropy Secret 5a3fa06 nx.json View secret
10135732 Triggered Generic High Entropy Secret d48c9c4 apps/gazes-api/src/config.ts View secret
10135732 Triggered Generic High Entropy Secret 7ff77d3 apps/gazes-api/src/config.ts View secret
10251448 Triggered Generic Password 8c9f51c apps/api/docker-compose.yml View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants