Skip to content

Conversation

@GaoNeng-wWw
Copy link
Collaborator

@GaoNeng-wWw GaoNeng-wWw commented Dec 2, 2025

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

用户必须注释 RejectRequestGuard 才可以禁用演示模式

Issue Number: N/A

What is the new behavior?

用户只需要配置 PREVIEW_MODE=true/false 即可以在运行时动态开启是否使用演示模式。如果为true,那么后端命令行会有相关提示

image

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

Release Notes

  • New Features

    • Added preview mode configuration option (PREVIEW_MODE) with demo mode notifications when enabled.
  • Configuration

    • New environment variable available: PREVIEW_MODE (default: enabled).
  • Changes

    • Updated Docker execution configuration and application startup scripts.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 2, 2025

Walkthrough

A preview mode feature is introduced across the NestJS template through configuration updates, module initialization logic, and request guard modifications. The endpoint startup script is simplified, and Docker configuration adjusted to support the new mode.

Changes

Cohort / File(s) Summary
Configuration
template/nestJs/.env.example, template/nestJs/src/config-schema.ts
Added PREVIEW_MODE configuration option with default value true and accompanying environment variable example.
Startup & Deployment
template/nestJs/dockerfile, template/nestJs/endpoint.sh
Updated Dockerfile CMD to use explicit relative path ./endpoint.sh; simplified endpoint.sh to contain only shebang, removing migration and application startup logic.
Application Logic
template/nestJs/src/app.module.ts, template/nestJs/src/public/reject.guard.ts
AppModule injects ConfigService and emits preview mode warnings on initialization; RejectRequestGuard now checks PREVIEW_MODE to conditionally bypass request rejection checks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Straightforward boolean flag introduction across multiple files with consistent pattern of reading and conditionally logging/gating behavior
  • Minor logic additions (early returns, console warnings) with no complex control flow
  • All changes are localized and follow existing patterns

Poem

🐰 A preview mode hops into view,
With flags and configs fresh and new,
Guards check once, then let requests through,
When demo's on, the app says "ooh!"
Warnings whisper: "This isn't true!"

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: add reject request flag' accurately describes the main change: adding a PREVIEW_MODE configuration flag to control request rejection behavior at runtime instead of requiring code modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the enhancement New feature or request label Dec 2, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
template/nestJs/.env.example (1)

20-21: PREVIEW_MODE sample is clear; optionally reorder to satisfy dotenv-linter

The new comment and PREVIEW_MODE=true sample clearly document the demo-mode toggle. dotenv-linter suggests placing PREVIEW_MODE before REDIS_HOST; if your CI enforces this, consider reordering:

-AUTH_SECRET = 'secret'
-REDIS_SECONDS = 7200
-REDIS_HOST = 'localhost'
-REDIS_PORT = 6379
+AUTH_SECRET = 'secret'
+REDIS_SECONDS = 7200
+# 是否启用演示模式
+PREVIEW_MODE=true
+REDIS_HOST = 'localhost'
+REDIS_PORT = 6379
 ...
-# 是否启用演示模式
-PREVIEW_MODE=true

Otherwise, the current change is fine.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bf2c8a0 and 1ad7223.

📒 Files selected for processing (6)
  • template/nestJs/.env.example (1 hunks)
  • template/nestJs/dockerfile (1 hunks)
  • template/nestJs/endpoint.sh (0 hunks)
  • template/nestJs/src/app.module.ts (2 hunks)
  • template/nestJs/src/config-schema.ts (2 hunks)
  • template/nestJs/src/public/reject.guard.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • template/nestJs/endpoint.sh
🧰 Additional context used
🧬 Code graph analysis (2)
template/nestJs/src/public/reject.guard.ts (1)
template/nestJs/src/config-schema.ts (1)
  • Configure (3-23)
template/nestJs/src/app.module.ts (1)
template/nestJs/src/config-schema.ts (1)
  • Configure (3-23)
🪛 dotenv-linter (4.0.0)
template/nestJs/.env.example

[warning] 21-21: [UnorderedKey] The PREVIEW_MODE key should go before the REDIS_HOST key

(UnorderedKey)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: e2e-test
🔇 Additional comments (3)
template/nestJs/dockerfile (1)

27-27: Explicit ./endpoint.sh in CMD is correct

Using an explicit relative path makes the script invocation more reliable inside the container; this change looks good.

template/nestJs/src/config-schema.ts (1)

22-23: Config type and schema extension for PREVIEW_MODE look consistent

Adding PREVIEW_MODE: boolean to Configure and wiring it into CONFIG_SCHEMA with a boolean default of true is consistent and aligns with how it’s used in AppModule and the guard.

Also applies to: 43-44

template/nestJs/src/public/reject.guard.ts (1)

11-13: Guard gating on PREVIEW_MODE matches the intended behavior

Injecting config and returning early when PREVIEW_MODE is disabled cleanly turns off the preview rejection behavior while preserving the existing i18n error path when preview mode is on. This aligns well with the PR objective of toggling demo mode via an env flag.

Also applies to: 16-20, 22-24

@kagol kagol merged commit 4220e70 into opentiny:dev Dec 5, 2025
3 of 4 checks passed
@GaoNeng-wWw
Copy link
Collaborator Author

/cmd docker --check

@github-actions
Copy link

github-actions bot commented Dec 6, 2025

🐳 Docker Check Status

CI triggered by command /cmd docker --check.

Status:Building... Preparing environment and running Docker health checks.

@github-actions
Copy link

github-actions bot commented Dec 6, 2025

✅ Docker Check Status

CI triggered by command /cmd docker --check.

Status: SUCCESS! Service is built, running, and responded to health check on http://localhost:3000/healthCheck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants