Skip to content

feat: add Tax CRUD API with default tax handling#1433

Open
rishabh1230 wants to merge 1 commit into
salahlalami:masterfrom
rishabh1230:feature/tax-crud
Open

feat: add Tax CRUD API with default tax handling#1433
rishabh1230 wants to merge 1 commit into
salahlalami:masterfrom
rishabh1230:feature/tax-crud

Conversation

@rishabh1230

Copy link
Copy Markdown
Screenshot 2026-03-24 200740 Screenshot 2026-03-24 200725 ## Description

Please provide a brief description of the changes or additions made in this pull request.

Related Issues

If this pull request is related to any issue(s), please list them here.

Steps to Test

Provide steps on how to test the changes introduced in this pull request.

Screenshots (if applicable)

If your changes include visual updates, it would be helpful to provide screenshots of the before and after.

Checklist

  • I have tested these changes
  • I have updated the relevant documentation
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the codebase
  • My changes generate no new warnings or errors
  • The title of my pull request is clear and descriptive
image image

if (isDefault) {
await Tax.updateMany({ isDefault: true }, { isDefault: false });
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion: taxName and taxValue are required fields in the database, but there is currently no validation to ensure they are provided. We should add proper validation and return an appropriate error if these fields are missing.

// Controller to get tax by ID
exports.getTaxById = async (req, res) => {
try {
const tax = await Tax.findById(req.params.id);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion: req.params.id is being used directly in the database query without any validation. We should validate the ID (e.g., check if it is a valid MongoDB ObjectId) before querying the database to prevent potential errors or unexpected behavior.

Comment thread backend/src/app.js
// Here our API Routes

// api routes for tax management
app.use('/api/tax', taxRoutes);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

question: The tax routes /api/tax are not protected by any authentication middleware, while other routes are using adminAuth.isValidAuthToken. Is this intentional, or should we also secure these routes to prevent unauthorized access?

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