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

Comprehensive Configuration, Documentation, and Code Structure Enhancements for NestJS Starter Kit #81

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

Conversation

devalexanderdaza
Copy link

This pull request includes several changes across multiple files to improve configuration, documentation, and dependencies in the NestJS starter kit. The most important changes include updating the README.md for better clarity, restructuring the example.env file, and adding new dependencies in package.json.

Base project src struct to modular pattern

  • Changed src structure to manage a easy configuration, development and respect the modular structure on the future

Documentation and Configuration Updates:

  • README.md: Improved instructions for setting up the project, generating RSA key pairs, and running the application. Updated project structure and configuration details. [1] [2] [3]
  • .vscode/settings.json: Added configuration to ignore certain files in the file tree.
  • example.env: Restructured and added detailed comments for environment variables.

Dependency and Build System Updates:

  • package.json: Added new dependencies mongoose-autopopulate, @swc/cli, and @swc/core. Added engines field to specify the required Node.js version. [1] [2] [3]
  • nest-cli.json: Updated compiler options to use SWC for faster builds and added plugins for Swagger integration.

Codebase Cleanup:

  • src/app.config.ts: Removed the file as part of the cleanup.
  • src/app.controller.spec.ts: Removed the file as part of the cleanup.
  • src/app.controller.ts: Removed the file as part of the cleanup.This pull request includes significant updates to the nestjs-starter-kit project, focusing on configuration, documentation, and code structure improvements. The most important changes include updates to the README.md, restructuring of the example.env file, and enhancements to the nest-cli.json and package.json files.

Documentation and Configuration Updates:

  • README.md: Improved instructions for setting up the project, including more detailed steps for generating RSA key pairs and running the application. Also, the project structure section has been updated for better clarity. [1] [2] [3]

  • example.env: Restructured the environment variables for better organization and clarity, grouping them into sections like application, API, infra, database, authentication, and Swagger configuration.

Codebase Enhancements:

  • nest-cli.json: Added SWC (Speedy Web Compiler) as the builder and enabled type checking. Also, included the NestJS Swagger plugin for better API documentation.

  • package.json: Added new dependencies like mongoose-autopopulate, @swc/cli, and @swc/core. Also, specified the minimum Node.js version required. [1] [2] [3]

Code Cleanup:

  • Removed Unused Files: Deleted the src/app.config.ts, src/app.controller.spec.ts, and src/app.controller.ts files, as they were no longer needed in the updated project structure. [1] [2] [3]

Development Environment:

  • .vscode/settings.json: Added a new setting to ignore files by both the file tree and the search.

feat: new environment vars
- Implemented new environment vars on .env.example

feat: add number and validation options utilities:
- Added number.util and validation-options.util files to the utils directory.
- The number.util file exports utility functions related to numbers.
- The validation-options.util file exports validation options utility for use with NestJS validation pipes.

feat: implements swagger/cli plugin:
- NestJS swagger plugin implemented

fix: inject ConfigService into LoggerModule:
- delete app.config.ts file, and implements forRootAsync configuration for logger module.

refactor: Refactor on config folder:
- Separate all configurations of the app, into independents files into config folder, using the best practices offer for NestJS Docs.
feat: environment vars validation:
- Implemented env vars validation using class-validator

feat: database module using class and auto populate feature
- Created a database module for mongoose
- Implemented auto-populate option

feat: create log module for logger
- implemented log module to sepparate the logger configuration

refactor: base code refactor
- base code refactor creating the core module
- Refactored `app.module.ts` to improve module imports and providers organization
- Added `CoreModule` to centralize core functionalities
- Moved exception filters to `core/filters` for better modularity
- Introduced `TimeoutInterceptor` in `core/interceptors` to handle request timeouts
- Added `JwtUserAuthGuard` to `AuthModule` for enhanced security
- Updated providers to include new filters and interceptors:
  - `AllExceptionsFilter` for global exception handling
  - `ValidationExceptionFilter` for validation errors
  - `BadRequestExceptionFilter` for bad request errors
  - `UnauthorizedExceptionFilter` for unauthorized access
  - `ForbiddenExceptionFilter` for forbidden access
  - `NotFoundExceptionFilter` for handling 404 errors
  - `GatewayTimeOutExceptionFilter` for handling gateway timeouts
- Improved validation pipe configuration to use `exceptionFactory` for custom error handling

This commit enhances the overall structure and error handling mechanisms of the application, making it more modular and maintainable.
- Updated the example.env file:
  - Added a REQUEST_TIMEOUT variable with a default value of 30 seconds, to specify the request timeout in milliseconds.

- Refactored the app.module.ts file:
  - Removed unused imports and commented code.
  - Injected the ConfigService dependency to use the 'infra.requestTimeout' configuration value.
  - Passed the timeoutInMilliseconds value to the TimeoutInterceptor class.

- Updated the infra.config.ts file:
  - Added a REQUEST_TIMEOUT variable with a default value of 30 seconds, to specify the request timeout in milliseconds.

- Created the modules.module.ts file:
  - Added the ModulesModule.
  - Imported the AuthModule, UserModule, and WorkspaceModule.
feat(shared): add API error response decorator module

chore(core): enhance application structure and add error handling

chore(babel): update SWC dependencies and compiler options
* Use workspaces with slug to manage unique workspace per user
* If workspace exist, not create new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant