Skip to content

adding in rules endpoint to api#10

Merged
CropWatchDevelopment merged 9 commits intomasterfrom
alerts-endpoints
Feb 17, 2026
Merged

adding in rules endpoint to api#10
CropWatchDevelopment merged 9 commits intomasterfrom
alerts-endpoints

Conversation

@CropWatchDevelopment
Copy link
Copy Markdown
Owner

No description provided.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api Ready Ready Preview, Comment Feb 17, 2026 8:28am

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds a new rules management endpoint to the API, allowing users to create, read, update, and delete rule configurations associated with devices and locations. The implementation includes permission checking to ensure users can only manage rules for devices and locations they have access to. Additionally, it modifies the SupabaseService to support per-request authentication tokens and adds Swagger UI persistence for authorization.

Changes:

  • Added complete CRUD endpoints for rules management with JWT authentication and permission validation
  • Enhanced SupabaseService to support creating authenticated Supabase clients with user access tokens
  • Added Swagger UI authorization persistence for improved developer experience

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 22 comments.

Show a summary per file
File Description
src/rules/rules.controller.ts New controller implementing CRUD endpoints for rules with JWT authentication guards
src/rules/rules.service.ts Service layer implementing business logic, permission checks, and database operations for rules
src/rules/rules.module.ts Module configuration importing SupabaseModule and declaring controller and service
src/rules/dto/create-rule.dto.ts DTO defining the structure for creating new rules
src/rules/dto/update-rule.dto.ts DTO extending CreateRuleDto for partial updates
src/rules/dto/rule.dto.ts DTO defining the complete rule structure for API responses
src/rules/entities/rule.entity.ts Empty entity class placeholder
src/rules/rules.controller.spec.ts Basic test setup for the rules controller
src/rules/rules.service.spec.ts Basic test setup for the rules service
src/supabase/supabase.service.ts Enhanced to accept optional access tokens and create authenticated clients dynamically
src/app.module.ts Added RulesModule to the application imports
src/main.ts Added Swagger UI option to persist authorization tokens
.vscode/launch.json Added VS Code debug configuration for NestJS

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/rules/rules.service.ts Outdated
Comment thread src/rules/rules.service.ts Outdated
Comment thread src/rules/rules.service.ts Outdated
Comment thread src/rules/rules.module.ts Outdated
Comment thread src/rules/rules.service.ts Outdated
Comment thread src/rules/rules.controller.spec.ts Outdated
Comment thread src/rules/rules.controller.ts Outdated
create(@Body() createRuleDto: CreateRuleDto, @Req() req) {
const authHeader = req.headers?.authorization;
if (!authHeader) {
throw new Error('Authorization header is required');
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

Using generic 'throw new Error' is inconsistent with error handling in the rest of the controller layer. All other controllers in the codebase use NestJS exception classes (BadRequestException, UnauthorizedException, etc.). Since the JwtAuthGuard should already handle authentication, this check may be redundant. However, if it's necessary, it should throw 'new UnauthorizedException('Authorization header is required')' to match the error handling pattern used elsewhere.

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +50
@UseGuards(JwtAuthGuard)
@ApiOkResponse({
description:
"Gets a user's rule configuration by ID.",
type: RuleDto,
isArray: false,
})
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

Missing API error response decorators. Following the pattern established in other controllers, this endpoint should include @ApiUnauthorizedResponse, @ApiInternalServerErrorResponse, and @ApiNotFoundResponse decorators (since the service can throw NotFoundException).

Copilot uses AI. Check for mistakes.
Comment thread src/rules/rules.controller.ts Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
CropWatchDevelopment and others added 7 commits February 17, 2026 17:26
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@CropWatchDevelopment CropWatchDevelopment merged commit 26ec299 into master Feb 17, 2026
2 checks passed
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.

2 participants