-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Reworked the project structure to make it easier and more maint…
…ainable, along with the structure change theres README files to document the folders.
- Loading branch information
1 parent
32651c9
commit bf819ca
Showing
104 changed files
with
1,501 additions
and
780 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Common Directory | ||
|
||
The Common directory is dedicated to shared code that is specific to the application's business logic and domain models, but needs to be reused across multiple features. Unlike core utilities, items in Common are tied to the application's domain concepts. | ||
|
||
## Purpose | ||
|
||
- Houses shared business logic and domain-specific utilities | ||
- Provides reusable components that implement business rules | ||
- Contains shared types and interfaces related to domain models | ||
- Centralizes common validation logic and business constraints | ||
|
||
## Examples of What Goes Here | ||
|
||
1. Shared business validation rules | ||
2. Common domain model transformations | ||
3. Business-specific utility functions | ||
4. Shared domain interfaces and types | ||
5. Common business calculations or formulas | ||
|
||
## When to Use Common | ||
|
||
Use the Common directory when: | ||
|
||
- The code implements business rules needed by multiple features | ||
- You have domain-specific logic that's reused across different modules | ||
- You need to share business validation or transformation logic | ||
- Multiple features need access to the same domain-specific utilities | ||
|
||
## When Not to Use Common | ||
|
||
Don't use Common for: | ||
|
||
- Generic utility functions (use Core instead) | ||
- Framework-specific code | ||
- Infrastructure concerns | ||
- Pure technical utilities with no business logic |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Config Directory | ||
|
||
The Config directory contains application-wide configuration settings, environment variables, and setup code that defines how the application behaves in different environments. | ||
|
||
## Purpose | ||
|
||
- Centralizes all configuration-related code and settings | ||
- Manages environment-specific variables and settings | ||
- Defines application-wide setup and initialization | ||
- Houses configuration interfaces and types | ||
- Provides configuration factories and providers | ||
|
||
## What Goes Here | ||
|
||
1. Environment configuration files | ||
2. Service configuration providers | ||
3. Module configuration factories | ||
4. GraphQL and API configurations | ||
5. Type generation configurations | ||
6. Path and file location configurations | ||
7. Global application settings | ||
|
||
## When to Use Config | ||
|
||
Use the Config directory when: | ||
|
||
- Adding new application-wide settings | ||
- Defining environment-specific configurations | ||
- Setting up module or service configurations | ||
- Managing external service connections | ||
- Defining global type generation settings | ||
|
||
## When Not to Use Config | ||
|
||
Don't use Config for: | ||
|
||
- Feature-specific settings (belong in respective modules) | ||
- Business logic or rules | ||
- Utility functions | ||
- Runtime data management | ||
- Local component configurations | ||
|
||
## Current Configuration Files | ||
|
||
- `graphql.config.ts` - GraphQL module configuration | ||
- `service.config.ts` - Core service settings | ||
- `filePaths.ts` - GraphQL schema file path management | ||
- `schemaToTypings.ts` - TypeScript definitions generation config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
import { join } from 'path'; | ||
|
||
const GRAPHQL_BASE_PATH = 'graphql'; | ||
/** | ||
* Gets the GraphQL schema file paths in either absolute or relative format | ||
* | ||
* Two different path formats are needed for different use cases: | ||
* | ||
* 1. Absolute paths (starting with 'src/'): | ||
* - Required by NestJS GraphQL module to properly load schema files | ||
* - Used in app.module.ts via graphql.config.ts for runtime schema loading | ||
* - The NestJS GraphQL module specifically requires paths to start with 'src/' | ||
* to properly resolve and watch schema files during development | ||
* - Example: 'src/graphql/models/Query.graphql' | ||
* | ||
* 2. Relative paths (from project root): | ||
* - Required by GraphQLDefinitionsFactory for TypeScript interface generation | ||
* - Used in schema-to-typings.ts which runs as a separate process outside NestJS | ||
* - Since this runs as a separate script, it needs full filesystem paths relative | ||
* to the project root to locate the schema files | ||
* - Example: '/path/to/project/graphql/models/Query.graphql' | ||
* | ||
* This dual path handling ensures both: | ||
* - Runtime schema loading works correctly in the NestJS application | ||
* - Type generation script can find and process schema files from the command line | ||
* | ||
* @param pathType - Whether to return absolute or relative paths | ||
* @returns Array of GraphQL schema file paths in the requested format | ||
*/ | ||
export function getGraphQLPaths(pathType: 'absolute' | 'relative' = 'absolute') { | ||
const graphqlPaths = [ | ||
// Enums used by all the graphql schemas | ||
'models/Common/CommonEnums.graphql', | ||
'models/Common/CommonPagination.graphql', | ||
|
||
// Entertainment specific models | ||
'models/Entertainment/BelongsToCollection.graphql', | ||
'models/Entertainment/Cast.graphql', | ||
'models/Entertainment/Company.graphql', | ||
'models/Entertainment/Crew.graphql', | ||
'models/Entertainment/Genre.graphql', | ||
'models/Entertainment/Keyword.graphql', | ||
'models/Entertainment/Recommendation.graphql', | ||
'models/Entertainment/Review.graphql', | ||
'models/Entertainment/Social.graphql', | ||
'models/Entertainment/Video.graphql', | ||
|
||
// Discover specific models | ||
'models/Discover/RangeFilters.graphql', | ||
'models/Discover/FiltersInput.graphql', | ||
'models/Discover.graphql', | ||
'models/Discover/DiscoverResult.graphql', | ||
'models/Discover/FiltersFormData.graphql', | ||
|
||
// Person specific models | ||
'models/Person/CreditGroup.graphql', | ||
'models/Person/Credit.graphql', | ||
'models/Person/Person.graphql', | ||
|
||
// Individual resource schemas | ||
'models/Show/Show.graphql', | ||
'models/Movie/Movie.graphql', | ||
'models/Person/Person.graphql', | ||
|
||
'models/Query.graphql' | ||
]; | ||
|
||
if (pathType === 'absolute') { | ||
// For NestJS GraphQL module (absolute paths starting with src/) | ||
return graphqlPaths.map((path) => `src/${GRAPHQL_BASE_PATH}/${path}`); | ||
} | ||
|
||
// For GraphQLDefinitionsFactory (relative paths from project root) | ||
return graphqlPaths.map((path) => join(process.cwd(), `../${GRAPHQL_BASE_PATH}/${path}`)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ApolloDriverConfig, ApolloDriver } from '@nestjs/apollo'; | ||
import { GraphQLModule } from '@nestjs/graphql'; | ||
|
||
import { getGraphQLPaths } from './filePaths'; | ||
|
||
export const graphqlConfig = GraphQLModule.forRoot<ApolloDriverConfig>({ | ||
driver: ApolloDriver, | ||
playground: true, | ||
|
||
// Must start with src/ for some reason otherwise nestjs doesn't pick up the files grr | ||
typePaths: getGraphQLPaths('absolute') | ||
}); |
Oops, something went wrong.